grep problem with date


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting grep problem with date
# 1  
Old 12-01-2010
grep problem with date

Hi,

can you correct the below syntax for me?

echo `grep "Issue" new`date +'%y%m%d'`.csv`

I am not able to execute above.

PS: "Issue" is a keyword I am seraching in a new<date>.csv
I am going to use above in i statement as below:

if [ `grep "Issue" new`date +'%y%m%d'`.csv` -eq 0 ]
then
do this
else
do that
# 2  
Old 12-01-2010
Code:
echo "grep Issue new`date +'%y%m%d'`.csv"

the whole script can be updated:
Code:
grep "Issue" new`date +'%y%m%d'`.csv
if [[ "$?" == "0" ]];
then
   do this  #find 
else 
   do that # not find 
fi

# 3  
Old 12-01-2010
Thanks Smilie
WorkedSmilie I m happy.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

sed Or Grep Problem OR Terminal Problem?

I don't know if you guys get this problem sometimes at Terminal but I had been having this problem since yesterday :( Maybe I overdid the Terminal. Even the codes that used to work doesn't work anymore. Here is what 's happening: * I wanted to remove lines containing digits so I used this... (25 Replies)
Discussion started by: Nexeu
25 Replies

2. UNIX for Dummies Questions & Answers

Grep using date issue

I'm using the below to grep two strings from my log file. grep "09:49.*yellow" out.logNow, i wish to search for all times within 3 minutes of the greped time i.e All time starting from 09:49:00 to 09:51:00. Currently it searches only for 09:49:* and also searches incorrect entry like... (14 Replies)
Discussion started by: mohtashims
14 Replies

3. Shell Programming and Scripting

grep with date

I have few files in one directory as below and I require the files that were created today... $ls -ltr -rw-r--r-- 1 abc abc 0 Dec 5 17:34 file4.txt -rw-r--r-- 1 abc abc 0 Dec 5 17:34 file5.txt -rw-r--r-- 1 abc abc 0 Dec 7 17:34 file6.txt -rw-r--r-- 1... (7 Replies)
Discussion started by: giridhar276
7 Replies

4. Shell Programming and Scripting

Calculating expiry date using date,sed,grep

Hi, I would greatly appreciate it if someone can help me with my problem. I have a crawler which collects spam URLs everyday & this data needs to be published in a blacklist. Here's the catch: The "Time To Live" (TTL) for each URL is 3 months (or whatever for that matter). If i see the... (5 Replies)
Discussion started by: r4v3n
5 Replies

5. UNIX for Dummies Questions & Answers

How do I grep a Date correctly

I am still a novice at this stuff, but I have searched everywhere and I cant seem to get this working. I am using a database program that I need to pull information from. The command I am using is the following. search /project | grep "date -v -1m "+%Y-%m"" This returns no results, however... (1 Reply)
Discussion started by: trezero
1 Replies

6. Shell Programming and Scripting

grep based on date

Hello! I have a circular log file which contains data that looks like this: 01/23/09 08:24:19:04 treadle_data = L3^M 01/23/09 08:24:19:09 STRIP 3 LOW 01/23/09 08:24:19:09 treadle_data = L4^M 01/23/09 08:24:19:09 STRIP 4 LOW 01/23/09 08:24:19:09 treadle_data = FF^M 01/23/09 08:24:19:09... (8 Replies)
Discussion started by: sdilucca
8 Replies

7. Shell Programming and Scripting

grep tomorrow's date

Hi guys, I need to find tomorrows date in date fomat and should be in variable. as I need to grep this date in a flat file ie. if today's date is '09 JAN 2009' output should be '10 JAN 2009' unix/perl script will be fine. (21 Replies)
Discussion started by: ssachins
21 Replies

8. Shell Programming and Scripting

Grep date from ls -l

I have a script which required the month and day as the input ex : ./script <Month> <date> from this I get the list of files to do further logics. The problem is when I assign these $1 and $2 to variables, and use grep command in the script ls -l |grep "$1 $2" it works fine for two... (1 Reply)
Discussion started by: GenMen
1 Replies

9. Shell Programming and Scripting

grep using date format

i have few persistance apps like below pipe 1118370 1200312 0 Dec 18 - 192:03 java - _AppName=DBSyncController pipe 2523376 1568906 0 feb 25 - 386:15 java -Xms128m -Xmx1024m -D_AppName=DBMaint com pipe 7462996 2531452 0 march 18 - 23:22 java... (4 Replies)
Discussion started by: ali560045
4 Replies

10. Shell Programming and Scripting

ls -l | grep $date (failing)

Example file list > ls -l -rwxr-xr-x 1 ....... ...... 1707 Feb 5 2004 file1 -rwxr-xr-x 1 ....... ...... 175 Jan 21 2005 file2 -rwxr-xr-x 1 ....... ...... 95 Apr 1 16:15 file3 The Script #!/bin/ksh # date variables start_date_Y=`date +%Y` # year (ie:... (1 Reply)
Discussion started by: yongho
1 Replies
Login or Register to Ask a Question