PDA

View Full Version : select a certain line from file



quo
05-31-2012, 10:57 AM
hi again!

I'm writing a bash script and I wonder how can I select a certain line from a file.For example I only want the line that starts with
a specific word(given that there's only one starting with this word)
and then by using sed perform an operation to this certain line


Residence: info info2 info2

So I want the line that starts with Residence: and then do something with sed to this line

Salem
05-31-2012, 11:09 AM
Given that sed will find the line for you as well, what's the point of using something else?

sed '/pattern/x' file

pattern is what you want to look for
x is what you want to do