LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 11-28-2003, 03:49 PM   #1
nkendrick
LQ Newbie
 
Registered: Nov 2003
Posts: 16

Rep: Reputation: 0
Truncating a string


Folks, still getting my head around sed, awk and cut etc..

I'm running logresolve on my apache access logs but I would like the screen output to only display the resolved domain name and timestamp, so how would I pipe the output into one of the above filters (or something else?) to, for example, truncate lines like the following before the first double quote:

somedomainname - - [28/Nov/2003:20:39:08 +0000] "GET /images/1px.gif HTTP/1.1" 304

Thanks
 
Old 11-28-2003, 03:59 PM   #2
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
What about:
IFS="
"
for i in `cat /path/to/log`;do echo $i | cut -f1 -d\";done
 
Old 11-28-2003, 04:18 PM   #3
nkendrick
LQ Newbie
 
Registered: Nov 2003
Posts: 16

Original Poster
Rep: Reputation: 0
That does the trick thank you very much for the quick reply - I ended up with the following because I'm looking for instances of a specific request to track accesses to a specific page:

IFS="
"
for i in `cat /var/log/httpd/access*`;do echo $i | grep 1px.gif | cut -f1 -d\";done
 
Old 11-28-2003, 04:34 PM   #4
nkendrick
LQ Newbie
 
Registered: Nov 2003
Posts: 16

Original Poster
Rep: Reputation: 0
..er..actually...can we get logresolve in somewhere, so IP addresses are resolved in the output?

Thanks

NK
 
Old 11-28-2003, 05:11 PM   #5
nkendrick
LQ Newbie
 
Registered: Nov 2003
Posts: 16

Original Poster
Rep: Reputation: 0
Well, my learning curve has got me to the following- - can it be made more elegant?

IFS="
"
rm -f tmplog.tmp
for i in `cat /var/log/httpd/access*`;do echo $i | grep 1px.gif >> tmplog.tmp; done
logresolve < tmplog.tmp | cut -f1 -d\"
rm -f tmplog.tmp
 
Old 11-29-2003, 09:12 AM   #6
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
You could use:
IFS="
"
for i in `logresolve < /path/to/log`;do echo $i | grep 1px.gif | cut -d\" -f1; done
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Error with cpio: truncating inode number abefroman Linux - Software 2 08-30-2006 10:52 AM
Samba truncating files to 0 bytes KimVette Linux - Networking 6 01-30-2005 06:42 PM
cpio message "truncating inode number" serik Linux - Software 2 12-18-2004 03:34 AM
Truncating trailing characters liguorir Programming 0 05-23-2004 04:00 AM
java test if string in string array is null. exodist Programming 3 02-21-2004 01:39 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 02:45 PM.

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