- 3,129 hits
Place for playing with commands…
ODOC:Mutiple search using grep.
eg: $ grep -i ‘foss \| gnu \| linux \| os’ news.txt. It will return lines where ever the above 3 words r matching in the news.txt.
ODOC: $grep arul names.txt. It will return, matching patterns/characters in the names.txt file.It used to find the strings in any file or files in any directories.
eg: $grep -i ArUl names.txt. It ll do search by case-insensitive. -n for searching nos. -v will give non-matching characters of lines in the names.txt. 🙂
ODOC:pipe(|).A pipe channels the output of one program to the input of another program.Use the vertical bar: | called as \’pipe\’ char.[\'rev\' = reverse the sting]…
ODOC:pipe the output of \’echo\’ into the program \’rev\’.eg:\$echo Happy | rev .Ans: yppaH. i.e.It will do both echo and rev program simultaneously using pipe:-)
ODOC: $sed.Use the s/pattern/replacement/ command to substitute text matching the ‘pattern’ with the ‘replacement’. ….
eg: $ sed -e ’s/thru/through/g’ in-file >out-file.It will replace ‘thru’ with ‘through’ in in-file &stored in out-file./g for replacing in all occurances.:-)
ODOC:$tr start-set end-set.tr translates one set of charas to another.It replaces all chars in start-set with corresponding chars in end-set….
eg:$tr a-z A-Z< foo.txt.It will replace small a-z to A-Z in it. $tr -d a
ODOC: $tac foo.txt. It will print the content of foo.txt in reverse order. i.e. Its quitely opposite to $cat foo.txt.:-)
ODOC: $split -l 10 foo.txt out_ .It will split the input foo.txt by 10 lines and saved into out_aa,out_ab,out_ac,etc.,correspondingly. i.e.Output files are named using the specified output name with aa, ab, ac, etc., added to the end of the prefix. 🙂
ODOC: $ cat -n foo.txt.It will display each line of foo.txt with corresponding line numbers in front of every line.It counts lline no for the empty lines also:-)
ODOC: $ cut -c 3-10 foo.txt.It will cut characters from 3rd to 10th chars of each lines in foo.txt.It used to select columns/fields from each line of input. 🙂
ODOC: $uniq -u foo.txt.It prints the uniq lines of foo.txt. -d prints only duplicated lines. $sort -u foo.txt,ll return sorted & unique content of foo.txt. 🙂