tr
the tr
utility is used to translate specified characters into other characters or to delete them.
tr [options] set1 [set2]
set1: to be replaced or removed set2: to be substituted for the characters listed in the first argument.
tr ‘{}’ ‘()’ < inputfile > outputfile
- translate braces into parenthesis
echo " … " | tr [:space:] ‘\t’
- translate white-space to tabs
echo “This is for testing” | tr -s [:space:]
- squeeze repetition of characters using -s
echo “the geek stuff” | tr -d ’t’
- delete specified characters using -d option
echo “my username is 432234” | tr -cd [:digit:]
- complement the sets using -c option
tr -cd [:print:] < file.txt
- remove all non-printable character from a file
tr -s ‘\n’ ’ ’ < file.txt
- join all the lines in a file into a single file
tee
tee takes the output from any command, and, while sending it to standard output, it also saves it to a file. in other words, it tees the output stream from the command: one stream is displayed on the standard output and the other is saved to a file.
wc
wc -l: line wc -c: bytes wc -w: words
cut
cut -d" " -f3