How to grep a string in todays file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to grep a string in todays file
# 1  
Old 04-05-2010
How to grep a string in todays file

Hello guys - I am new to Unix.

I am trying to understand how to grep a perticular string in todays file?

I am trying this syntax but not getting what I am looking for:

% grep `date '+%d/%b/%Y'`

For instance there are 2 files generated today with same data. I am trying to find them and then search inside either one of them.

Thank you
# 2  
Old 04-05-2010
Hello,

You should give 2 arguments to grep command. 1 is search string (`date '+%d/%b/%Y'`) in your case & file to search for. So you want to find (date '+%d/%b/%Y') string in file ?

-Nithin.
# 3  
Old 04-05-2010
Hi i am actually looking for a string "lostER" in a file that is generated today.

So would it be like this:

grep -i 'lostER' | grep date '+%d/%b/%Y
# 4  
Old 04-05-2010
I recommend you read the grep man page.
To look for a string in a file :
Code:
grep <STRING> <FILE>

# 5  
Old 04-05-2010
No thats not what I am looking for. I already know basic grep commands.

This is about searching for todays file and then looking for a string inside it.
# 6  
Old 04-05-2010
Quote:
Originally Posted by DallasT
...This is about searching for todays file ...
Ok, assuming that today is 5th April, 2010 what would be the name of "today's file" in your file system ?

tyler_durden
# 7  
Old 04-05-2010
It would be something like this:

ERProcessBD04052010*****.txt

The * represent a random changing numeric value.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Replace string of a file with a string of another file for matches using grep,sed,awk

I have a file comp.pkglist which mention package version and release . In 'version change' and 'release change' line there are two versions 'old' and 'new' Version Change: --> Release Change: --> cat comp.pkglist Package list: nss-util-devel-3.28.4-1.el6_9.x86_64 Version Change: 3.28.4 -->... (1 Reply)
Discussion started by: Paras Pandey
1 Replies

2. UNIX for Beginners Questions & Answers

How to list todays file in perticular folder?

How to list todays file in perticular folder Moved thread to appropriate forum (9 Replies)
Discussion started by: pspriyanka
9 Replies

3. Shell Programming and Scripting

Grep string in files and list file names that contain the string

Hi, I have a list of zipped files. I want to grep for a string in all files and get a list of file names that contain the string. But without unzipping them before that, more like using something like gzcat. My OS is: SunOS test 5.10 Generic_142900-13 sun4u sparc SUNW,SPARC-Enterprise (8 Replies)
Discussion started by: apenkov
8 Replies

4. Shell Programming and Scripting

grep exact string from files and write to filename when string present in file

I am attempting to grep an exact string from a series of files within a directory and append that output to the filename when it is present in the file. I've been after this all day with no luck. Thanks for your help in advance :wall:. (4 Replies)
Discussion started by: JC_1
4 Replies

5. Shell Programming and Scripting

Find and copy files based on todays date and search for a particular string

Hi All, I am new to shell srcipting. Problem : I need to write a script which copy the log files from /prod/logs directory based on todays date like (Jul 17) and place it to /home/hzjnr0 directory and then search the copied logfiles for the string "@ending successfully on Thu Jul 17". If... (2 Replies)
Discussion started by: mail.chiranjit
2 Replies

6. Shell Programming and Scripting

Grep a string from input file and delete next three lines including the line contains string in xml

Hi, 1_strings file contains $ cat 1_strings /home/$USER/Src /home/Valid /home/Review$ cat myxml <projected value="some string" path="/home/$USER/Src"> <input 1/> <estimate value/> <somestring/> </projected> <few more lines > <projected value="some string" path="/home/$USER/check">... (4 Replies)
Discussion started by: greet_sed
4 Replies

7. Shell Programming and Scripting

how to get todays file name

Hi ! there can you please tell me how to get full files having today date like if i have files like this(below) , i want to grep only sra + today's date + what ever thing is there after date . grep `sra*$date*.csv` >>> i tried this one but its not working . sra28-08-2011xyz.csv... (1 Reply)
Discussion started by: sravan008
1 Replies

8. Shell Programming and Scripting

How to list todays file

Hi Friends, How to list todays file from a directory listing of files for amny dates. I tried with the following options but not working : find . -name "esi01v*" -mtime 1 -ls find . -name "esi01v*" -ctime 1 -ls find . -name "esi01v*" -mtime 1 Please advise (19 Replies)
Discussion started by: unx100
19 Replies

9. Shell Programming and Scripting

using todays date to create a report using grep

What i'm trying to do is to use grep to search through a few files for a selected daemon and only report on today's date. I think I got it sorted apart from in the txt file the date has 2 gaps between the month and the day, and the way I have the date format only puts in one gap any help to get... (3 Replies)
Discussion started by: MBN
3 Replies

10. Shell Programming and Scripting

want to delete timestamp from todays file

i want to delete the time stamp from the file which have a date of yester day 640878 Nov 6 09:08 fbres.01.20031106:09:08:30 here is what my ls -lt command shows in current directory it want it to be 640878 Nov 6 09:08 fbres.01.20031106 thanks (5 Replies)
Discussion started by: maverick
5 Replies
Login or Register to Ask a Question