Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to set a variable date in a script file ?

Status
Not open for further replies.

zoby

Technical User
Mar 5, 2001
35
FR
With a script file, I would like to extract day by day some lines from a file which have been added day by day. The format of these lines are :

...
root pts/17 10.81.0.58 Tue Feb 13 09:20 - 09:21 (00:01)
...

So in this file I would like all the lines which the date : Tue Feb 13.

How can I do that ? I know the grep command to extract but what are the arguments to extract only the date I would like? Thanks for helping me.
 

Hi, zoby!

To extract lines which date is 'Tue Feb 13', use this awk command:

awk '/Tue Feb 13/' file

You can redirect output to newfile:

awk '/Tue Feb 13/' file > newfile

For this kind of problems, awk is an excellent solution.

Jesus loves you.

KP.


Jesus loves you!
 
Hi Krunek,

Yes I 've just tested it and it works but instead of setting the date 'Tue Feb 13' with the awk command, is there a variable for the date which generate day by day the date of the day whitout change the script file all the days ?
Sorry if my english is not well-understanding

Zoby
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top