The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Grep question. saurabhsinha23 UNIX for Dummies Questions & Answers 3 12-11-2007 01:58 AM
Question about GREP Adriel UNIX for Dummies Questions & Answers 16 03-22-2007 08:03 AM
Another grep question kingdbag UNIX for Dummies Questions & Answers 6 10-27-2006 02:56 AM
grep & sed question der Kopf Shell Programming and Scripting 1 11-22-2004 04:49 AM
Grep question eloquent99 UNIX for Dummies Questions & Answers 4 02-20-2003 10:49 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-18-2006
nazri76 nazri76 is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 16
Question Grep Question

Hello Everybody,

I have files; yyyymmdd.log which the data look like this;

[20/Jun/2006:00:00:56 +0800] "Txid=9426043&MsgTxt=Thankyou&UserId=john&Password=jh2501"
[21/Jun/2006:19:15:56 +0800] "Txid=9426150&MsgTxt=Thankyou&UserId=john&Password=jh2501"
.
.
.
[29/Jun/2006:12:00:26 +0800] "Txid=9426200&MsgTxt=Thankyou&UserId=john&Password=jh2501"

Question 1:
How to grep the data based on date i.e. from 20/Jun/2006 untill 25/Jun/2006?

Question 2:
How to grep specific word only i.e. "Txid=9426043" which the output must be "Txid=9426043" only instead of the whole statement ([20/Jun/2006:00:00:56 +0800] "Txid=9426043&MsgTxt=Thankyou&UserId=john&Password=jh2501")

Question 3:
Normally I do wc-l yyyymmdd.log to check total number of line but how i can create the output file with total number of line e.g. yyyymmdd_"total number of line".log when i run wc .

Appreciate your answers.
  #2 (permalink)  
Old 08-18-2006
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,798
Here is a sed solution.


Code:
1. sed -n -e '/20.Jun.2006/,/25.Jun.2006/p' input.txt

2. sed -n -e 's!.*\(Txid=[^&]*\)&.*!\1!p' input.txt

3. line=$(wc -l yyyymmdd.log)
    mv "yyyymmdd.log" "yyyymmdd_$line.log"

  #3 (permalink)  
Old 08-18-2006
slayer666 slayer666 is offline
Registered User
  
 

Join Date: Aug 2006
Posts: 10
for question three u can use this

cat yyyymmdd.log | wc -l > <filename>
  #4 (permalink)  
Old 08-18-2006
vgersh99's Avatar
vgersh99 vgersh99 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,131
Quote:
Originally Posted by slayer666
for question three u can use this

cat yyyymmdd.log | wc -l > <filename>
and why exactly do you need a 'cat' here?
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 02:26 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0