Skip to main content

Posts

Showing posts from January 15, 2015

Linux Commands-3

// Invert Search in grep $ cat < xyz asd anuj anuj@anuj-G31M-ES2L:~$ grep -v "asd" xyz anuj //Some more results on grep $ grep "a.." xyz asd anuj anuj@anuj-G31M-ES2L:~$ grep "a..$" xyz asd anuj@anuj-G31M-ES2L:~$ grep "a*$" xyz asd anuj // Use of brackets in grep command grep [a-z]n xyz anuj $ grep [a-z][sn] xyz asd anuj // To show the line number of lines that match the string or pattern. $ grep -n [a-z]n xyz 2:anuj //Count no.of lines that match the pattern $ grep -c [a-z] xyz 2 //Display file names matching the pattern $ grep -l [a] xy* xy2 xy2_file xyz xyz2 //Match both uppercase and lowercase letters $ grep -i [a-z] xy* xy2:as xy2_file:i want to append this to xy_file xyz:asd xyz:anuj xyz2:asd xyz2:anuj xyz2:hello xyz2:i am your teacher $ grep -ic [a-z] xy*