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
Finding & Moving Oldest File by Parsing/Sorting Date Info in File Names nikosey Shell Programming and Scripting 6 07-30-2008 10:46 PM
Perl: Extracting date from file name and comparing with current date MKNENI Shell Programming and Scripting 4 03-26-2008 04:01 PM
Date parsing into string, help! martyb555 Shell Programming and Scripting 5 02-17-2008 10:12 PM
parsing a system log file via the 'date' command cjones Shell Programming and Scripting 5 05-10-2007 01:26 PM
Changing Creation Date to a Prespecified Date of a File In Unix monkfan UNIX for Dummies Questions & Answers 4 11-28-2006 07:15 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-2008
pk_eee pk_eee is offline
Registered User
  
 

Join Date: Jul 2008
Posts: 18
Parsing Date to a file name

Hi All

There is a file "apple_2008-08-15.log".

I have to use grep on this file to collect my test log. There are 45 such files. Is there a command that I can use to dynamically substitute the daily date as part of the file name? As of now Iam renaming the file to the new date and running my shell script. Please help me.

Also please let me know how to a create folder with the current date as its name dynamically.
  #2 (permalink)  
Old 08-18-2008
Tytalus's Avatar
Tytalus Tytalus is offline Forum Advisor  
echo {1..9}^2\;|bc
  
 

Join Date: Jun 2003
Location: Scotland
Posts: 431
for your first part - why not do a


Code:
for i in $(ls)
do
...
done

loop, and for your 2nd question, the following should set you on the right path:


Code:
#  date +%Y-%m-%d
2008-08-18

  #3 (permalink)  
Old 08-18-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
That's a Useless Use of ls right there.


Code:
for i in *
do
  ...
done

  #4 (permalink)  
Old 08-18-2008
pk_eee pk_eee is offline
Registered User
  
 

Join Date: Jul 2008
Posts: 18
Hi All

Thanks for your replies...

But what Iam looking for is something like

cat apple_<command to substitute the current date>.log
  #5 (permalink)  
Old 08-18-2008
Tytalus's Avatar
Tytalus Tytalus is offline Forum Advisor  
echo {1..9}^2\;|bc
  
 

Join Date: Jun 2003
Location: Scotland
Posts: 431
:-)

ok - what I should have said was


Code:
for i in $(ls apple*.log)

bu I was being lazy ;-)
  #6 (permalink)  
Old 08-18-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
That's still a Useless Use of ls


Code:
for i in apple*.log

  #7 (permalink)  
Old 08-18-2008
pk_eee pk_eee is offline
Registered User
  
 

Join Date: Jul 2008
Posts: 18
Hi All

Thanks for all your replies..

The following satisfied me with the output.

cat apple_`date +%Y-%m-%d`.log


Thanks...
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 03:46 PM.


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