bash script and sed
Hi,
I'm trying to write a bash script to find all lines containing two different strings in many files. I don't have access to egrep so I want to use sed for this purpose. The files will look like this: FileX ------ Info:18 Data:76 Contact:me@home.com Start:1500 I want to generate a new file from these files with only the rows containing Data and Start. Something like this: for y in `ls /file*.db`; do sed '/Data|Start/p' $y > newfile done I'v tried to find a solution to this but not found it. Anyone have a suggestion for this? Thanks, Goran |
Hi,
Use this as sed statement: Code:
sed -rn '/Data|Start/p' $y > newfile |
Are you using the GNU version of sed? If so, you want "\|", rather than "|" as per the manual. Also, you probably want to use the -n option, to stop it printing out the entire pattern space.
|
Thank you druuna. It works. So simple.
|
You're welcome :)
|
Great you have a solution. Please mark as SOLVED :)
|
My solution also works.
|
Quote:
|
All times are GMT -5. The time now is 04:14 PM. |