[ale] Shell scripting
Geoffrey
esoteric at 3times25.net
Sat Feb 8 22:41:50 EST 2003
Thomas Holmquist wrote:
> Im writing a shell script that will put unique lines of text in a file
>
> then I want to be able to delete the lines of text that contain a certan
> keyword, how would I do this?
Hmmm, I'm not sure what it is exactly you want to do. There are a host
of tools for such pleasures.
check out:
uniq
sort
awk
sed
Perl would probably be the proper tool, but would have the greatest
learning curve.
When you say unique lines of text, what exactly do you mean? If you
have a file that contains many duplicates and you want each unique line
just once:
sort -u filename
will accomplish this.
As for deleting a line of text from a file if it contains a particular
keyword, wow, there's all kinds of ways to do that. The easiest way is:
grep -v $KEYWORD filename
This will give you every line that DOES NOT contain the value of KEYWORD.
Now if you want to apply both of these to the same data, then it's simply:
sort -u filename |grep -v $KEYWORD
--
Until later: Geoffrey esoteric at 3times25.net
The latest, most widespread virus? Microsoft end user agreement.
Think about it...
_______________________________________________
Ale mailing list
Ale at ale.org
http://www.ale.org/mailman/listinfo/ale
More information about the Ale
mailing list