grep user /etc/passwd ==> this will show the lines contains text "user"
grep ^user /etc/passwd ==> this will show the lines contains and the lines starts with text "user"
Version of grep ==> grep --version
Version of sed ==> sed --version
Cat file in using sed ==> sed 'p' /etc/passwd => each line is printed twice in output
Without duplicate as above ==> sed -n 'p' /etc/passwd
Range of lines say 1 to 5 ==> sed -n '1,5 p' /etc/passwd
Line start with user ==> sed -n ' /^user/ p' /etc/passwd
sed ' /^#/ d' /etc/ntp.conf ==> will delete lines with # in output
sed ' /^#/ d ; /^$/ d' /etc/ntp.conf ==> This will delete lines with # and empty lines in output.
*Above two commands are not modifying the file but only showing updated output.
grep ^user /etc/passwd ==> this will show the lines contains and the lines starts with text "user"
Version of grep ==> grep --version
Version of sed ==> sed --version
Cat file in using sed ==> sed 'p' /etc/passwd => each line is printed twice in output
Without duplicate as above ==> sed -n 'p' /etc/passwd
Range of lines say 1 to 5 ==> sed -n '1,5 p' /etc/passwd
Line start with user ==> sed -n ' /^user/ p' /etc/passwd
sed ' /^#/ d' /etc/ntp.conf ==> will delete lines with # in output
sed ' /^#/ d ; /^$/ d' /etc/ntp.conf ==> This will delete lines with # and empty lines in output.
*Above two commands are not modifying the file but only showing updated output.
No comments:
Post a Comment