grep command with changing file name


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting grep command with changing file name
# 1  
Old 01-26-2010
grep command with changing file name

Hello,

I have a grep command as follows:

grep Found original_2010.01.26 | cut -f 5 -d ' '


However the file name changes each day and gets appended with today's date. For ex:

on January 27th it would be

original_2010.01.27 ... etc

The files from previous days exist on the same server/ same location.

How do i change my grep command to input the changing filename?

Any thoughts would be appreciated.

Thanks,
# 2  
Old 01-26-2010
Code:
# capture today date
sys_year=`date +'%Y'`
sys_month=`date +'%m'`
sys_day=`date +'%d'`

grep original_$sys_year.$sys_month.$sys_day


Last edited by Scott; 01-26-2010 at 03:32 PM.. Reason: Added code tags
# 3  
Old 01-26-2010
Code:
grep "Found"  original_`date '+%Y.%m.%d'` | cut -f 5 -d ' '

Smilie
# 4  
Old 01-26-2010
MySQL

Thanks all for your replies. It worked.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Search file pattern using grep command

I 'm writing a script to search particular strings from log files. The log file contains lines start with *. The file may contain many other lines start with *. I need to search a particular line from my log file. The grep command is working in command line , but when i run my script, Its printing... (7 Replies)
Discussion started by: vinus
7 Replies

2. Shell Programming and Scripting

Command for changing date format in a file

Hi... I have an inputfile name as :- abc_test_20120213.dat (date in yyyymmdd format) I need the output file name as abc_test_13022012.dat (date in ddmmyyyy format) Please help me on this... Thanks in advance. (5 Replies)
Discussion started by: gani_85
5 Replies

3. Shell Programming and Scripting

command to grep the variable from file

Hi, I am looking for the following: 1. A command to 'grep' the variable from a file 2. And check whether the entered variable is empty in that file I have a file as given below: IAGLOBAL_USERID=admin I want to check with a whether the variable contains a value, say here its admin if... (2 Replies)
Discussion started by: dbashyam
2 Replies

4. UNIX for Dummies Questions & Answers

grep command on a line from a file

Dear forum, Please excuse my ignorance. I have looked through various forum posts and tried various solutions but have not been able to solve my problem. File1.txt consist of a list of 100 names (one per line). File2.txt contains details for 1000 people (one per line), with the first field... (7 Replies)
Discussion started by: beginner0302
7 Replies

5. Shell Programming and Scripting

Getting file names in GREP command

Hi friends, It gives me 3 lines in output which contain word "automation". But along with it I want the script to return file name from which it got the word. How to do it? Plz guide me Anu (4 Replies)
Discussion started by: anushree.a
4 Replies

6. UNIX and Linux Applications

How to redirect grep command output to same file

Hi Everyone, Can anyone please tell me, how can I redirect the grep command output to same file. I am trying with below command but my original file contains no data after executing the command. $grep pattern file1 > file1 Kind Regards, Eswar (5 Replies)
Discussion started by: picheswa
5 Replies

7. UNIX for Dummies Questions & Answers

trying to grep -v multiple changing sequences from a file

Hello All - I am looking for help on how to solve a re-occuring problem. I have a file with certain sequences in it that need to be removed. The sequences are always different but the fix is always the same remove those sequences and leave the rest. Another team ID's the bad sequences and then I... (3 Replies)
Discussion started by: candyluv030
3 Replies

8. Shell Programming and Scripting

grep command to retrieve one file

The Sed/Grep command is really confusing me. I know I'm missing something that should be really easy to fix. My program displays multiple names after I ask it to display only one, How do I get it to do only one?? it looks like this: Please enter a name to display? >> John (A list then... (9 Replies)
Discussion started by: toejam
9 Replies

9. Shell Programming and Scripting

How to from grep command from a file which contains matching words?

Hi all I have a file with below content (content is variable whenever new product is launched). I need form a grep command like this egrep "Unknown product|Invalid symboland so on" How to do it using a script? Unknown product Invalid symbol No ILX exch found exceeds maximum size AFX... (4 Replies)
Discussion started by: johnl
4 Replies

10. Shell Programming and Scripting

how to grep the oldest file under ls command

Hi, Please help me out I want to grep the oldest file in a directory, could I use "ls" command? and how? thanx in advance (7 Replies)
Discussion started by: ericaworld
7 Replies
Login or Register to Ask a Question