grep is your friend.dukebound85 said:How would one go about searching many lines of a file for a word, or more specifically, searching for a line that doesnt contain some desired word.
For just getting the first or last lines in a file, head and tail are far more straightforward.dukebound85 said:what about copying certain line numbers from one file and exporting to another?
I am guessing sed may be an option
sed -c "1,5" file > new
this will copy lines 1-5 of file and export to new right?
thanks for all the help so far
grep, sed, and awk are probably the 3 most underused commands in unix (in that people may use them, but rarely truly exercise what they can do).balamw said:You can play all kinds of lovely games with grep, sed and awk. So much so they wrote a nice O'Reilly book about them.
I run my own mailserver, and let any address come in, so when I give emails I can make them up on the fly (company name) so I can track spam. I run this periodically on my Spam folder:with -A and -B so you can look for strings in lines adjacent to matches etc...
I only recently started using xargs (to moitor and clean up the Spam Maildirs on our mail gateway), so I know exactly what you mean!stcanard said:grep, sed, and awk are probably the 3 most underused commands in unix (in that people may use them, but rarely truly exercise what they can do).
Although find and xargs are pretty good candidates too.
Master those 5 commands, and it is amazing what you can do in a single line.