grep -v "^#|^$" filename
^# :- line start with comment #
^$ :- empty lines
[a-zA-Z0-9_] :- alpha numeric with _
grep -o "^.\{1,10\}" filename :- find first 10 character word at the beginning of line.
grep -o ".\{1,10\}$" filename :- find last 10 character word at the end of line.
grep -o "^." filename :- find one character for beginning of each line.
grep -o ".$" filename :- find one character for end of the each line.
grep -e "^$" filename :- find the empty lines in the file.
grep -e "$" filename :- end of the line.
grep -e "^[a-zA-Z\]\{0,255\}\+\@\+[a-zA-Z\]\{0,255\}\+\:\+\~\+\\$" fun.txt : kayyum@AbdulKayyum:~$
grep -v "^[a-zA-Z\]\{0,255\}\+\@\+[a-zA-Z\]\{0,255\}\+\:\+\~\+\\$" fun.txt : kayyum@AbdulKayyum:~$
kayyum@AbdulKayyum:~$ cat new.txt | grep -e "grep\|#" | grep -o "grep.*\|#.*"
# grep :- remove empty lines
grep -v "^$" sample.txt
# grep :- remove commented lines.
grep -v "^#" sample.txt
# grep :- to find oracle datafiles
grep -o "[a-zA-Z0-9_\]\{0,255\}\.dbf" sample.txt
# grep :- find first 10 characters each line
grep -o "^.\{1,10\}" sample.txt
# grep :- find last 10 characters each line
grep -o ".\{1,10\}$" sample.txt
# grep :- remove commented and empty lines
grep -v "^#\|^$" sample.txt
# grep :- to find ' " ' double quotes in the file
grep -e "\"" file.txt
# grep :- to find '{ ' and '}' curly braces
grep -e "\{" file.txt
grep -e "\}" file.txt
# combine
grep -e "\{\|\}" file.txt
grep -e "\"\.\"" file.txt
grep -e "[a-zA-Z\]\{0,255\}" file.txt
No comments:
Post a Comment