Quote:
Originally posted by wantabescripter
So I used
grep OPEN file.txt | sed -n '1p;' | awk -F: '{ print $1 }'
|
You need to redirect your output somewhere to save it...
grep OPEN file.txt | sed -n '1p;' | awk -F: '{ print $1 }' > newFile
There are a lot of unnecessary pipes in your command, you could actually do the whole lot in sed or awk.
I can guess the awk solution from what you have posted...
awk -F":" '/OPEN/ {print $1; exit}' yourFile > newFile
And the sed solution will be something like this...
sed -n '/OPEN/{x;/1stValueIsFound/{;x;q;}
s/^.*/1stValueIsFound/;x;s/:.*//;p;}' yourFile > newFile
I prefer the awk because it it is far easier to read and you can tell it to exit once a match has been found.
For sed, you have to keep a value in the holdspace to check against to see if the match has been found ('1stValueIsFound'). You have to keep reading the file unfortunately.
Damian