Welcome to the most active Linux Forum on the web.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 07-30-2004, 12:57 PM   #1
Registered: Apr 2004
Distribution: Debian
Posts: 193

Rep: Reputation: 30
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 - - [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
Old 07-30-2004, 01:16 PM   #2
Registered: Apr 2004
Distribution: Debian
Posts: 193

Original Poster
Rep: Reputation: 30
yay! i found the answer using awk. (and searching this forum)

now for counting occurences...
Old 07-30-2004, 02:59 PM   #3
Senior Member
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140

Rep: Reputation: 242Reputation: 242Reputation: 242
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...


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Ok so my script is not working, any ideas? mago Linux - General 8 03-30-2005 11:13 PM
sed script glam1 Programming 2 08-31-2004 11:28 AM
shell script ideas marigb Linux - Newbie 8 04-24-2004 02:16 AM
ideas for a perl script LAMP_User Programming 3 03-18-2004 04:18 PM
sed in small BASH script OhLordy Linux - General 1 08-29-2003 11:32 AM

All times are GMT -5. The time now is 12:26 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration