LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   sed command help (https://www.linuxquestions.org/questions/programming-9/sed-command-help-623885/)

viveksnv 02-26-2008 03:59 AM

sed command help
 
Hai.

My file has
proxy-connection
connection
server-connection

i try to print only the 2 line
connection

sed -n "connection" filename
but print all the lines

slakmagik 02-26-2008 04:16 AM

grep '^connection$' FILE

but, with sed:

sed -n '/^connection$/p' FILE

-- The slashes tell sed it's a regex. ^ and $ anchor the expression at the beginning and end of the line. The 'p' flag prints. The regex is the same in grep but it knows it's a regex and always prints only matching lines by default.

syg00 02-26-2008 04:18 AM

Presuming no whitespace interference ...

pixellany 02-26-2008 07:40 AM

Really good SED tutorial here:
http://www.grymoire.com/Unix/Sed.html

Look at the part about addresses


All times are GMT -5. The time now is 05:57 AM.