Re: script question
- From: Stephane CHAZELAS <this.address@xxxxxxxxxx>
- Date: Sat, 24 Mar 2007 08:12:55 GMT
2007-03-23, 14:04(-07), Mike:
[...]containing the word "END".From a script, I want to print all the lines of a file up to a line
Something like:
# grep -avw -m 1 "END" -f bla.txt
or
# cat bla.txt | while read line; do
echo $line
if [ "$line" == "END" ]; then break; fi
done
...except a script that actually works. The second one above does not
work because
the "read line" corrupts the lines by removing whitespace. I don't
know why the
first one doesn't work.
sed /END/q < bla.txt
Remember a shell is a command line interpreter, pick up the
command most suited for the job. Using a while read loop is the
most alien way to do shell programming.
--
Stéphane
.
- References:
- script question
- From: Mike
- script question
- Prev by Date: Re: script question
- Next by Date: cron job under Cygwin, Cygwin runs on WinXP
- Previous by thread: Re: script question
- Next by thread: cron job under Cygwin, Cygwin runs on WinXP
- Index(es):
Relevant Pages
|