LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   sed script help/ideas (https://www.linuxquestions.org/questions/programming-9/sed-script-help-ideas-211532/)

rjcrews 07-30-2004 12:57 PM

sed script help/ideas
 
i have a simple sed script to pull certain lines from a log on my server, and dump it to another file.

my question is, what would be the easiest way modify these lines to remove all the stuff i dont want from them, say everything but the something.txt

example of line

255.255.255.255 - - [20/Jul/2004:23:18:34 -0400] "GET /files/blah/something.txt HTTP/1.1" 200 1538048

script is like

sed -n '/txt/ p' logfile >results.txt

any suggestions are welcome. thx

rjcrews 07-30-2004 01:16 PM

yay! i found the answer using awk. (and searching this forum)

now for counting occurences...

Cedrik 07-30-2004 02:59 PM

I would use Perl like :


perl -p -e 's/^.*GET\s//;s/\s.*$//' /var/log/server-logs > parsed-logs
cat parsed-logs | wc -l # counting occurences...


All times are GMT -5. The time now is 06:01 PM.