Skip to main content

echo, printf, tr, wc

 


echo

Built-in Linux feature to print out arguments as standard output.

echo {string}

printf

Similar to echo, but allows for more control over the formatting of output.

printf {string}
OptionFunction
\nnewline
printf "hello \n how are you"




tr

tr performs operations like removing repeated characters, converting uppercase to lowercase, and basic character removal

 or replacement.

tr {character 1} {character 2}
echo 'linuxize' | tr 'lin' 'red'
reduxeze

In this example, tr has been used to replace the occurrence of 'lin' with 'red'.


wc

wc, or wordcount, is a function used for counting a part of an output. wc can be used to count the number of words, lines, characters, or bytes in a file or output.

wc [options] {filename}
OptionFunction
-lLine count
-cbyte count
-m

character count

-w

word count


sort

Linux utility for sorting lines of text files.

sort [options] {filename}
OptionFunction
-k {column number)Sort by values in a specified column.
-nSorts based on numerical value
-rSorts fields in descending order
-tSeperate one field from another

cut

Extracts specified lines of text from a file.

cut [options] {filename}
OptionFunction
-cSpecify the number of characters to cut from each line.
-d {delimter}Seperate one field from another.
-f {fieldnumber)Specify the field numbers to cut as separated by the delimiter. IE f2 would be the field between the first and second instances of the delimiter.
-sSuppress a line if a delimiter is not found.

paste