If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > grep space problem

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-03-06, 15:55
pavan_test pavan_test is offline
Registered User
 
Join Date: Oct 2005
Posts: 45
grep space problem

Hello.,

1 gggggg C2052EX 15 Mar 31 13:03
1 rrrrrr C2052EX 15 Apr 3 12:00

todaydat=`date | awk -F" " '{print $2" "$3 }'` (# the output must be like Apr 3, or March 31 or Oct 8 etc)

find DIR_PATH/START.*.*.*.ctl* -exec ls -ltr {} \; -mmin +200 | grep "$todaydat" | awk -F" " {'print $9'}

I have a peculiar spacing problem.when i used the above find comman on march 31st it worked fine. but on april 3 it did not work.

the reason: Mar 31
Apr 3
the space between r and 3 in Marc 31 is one
but the space between r and 3 in Apr 3 is two.

so the same find command which worked on march 31st is not working on april 3rd.

can anyone please give me a suggestion to solve this.

thanks
pavi
Reply With Quote
  #2 (permalink)  
Old 04-04-06, 03:07
pdreyer pdreyer is offline
Registered User
 
Join Date: May 2005
Location: South Africa
Posts: 1,268
delete the space with sed
Code:
todaydat=`date '+%b %e' | sed 's/  / /g'`
Reply With Quote
  #3 (permalink)  
Old 04-04-06, 03:27
pdreyer pdreyer is offline
Registered User
 
Join Date: May 2005
Location: South Africa
Posts: 1,268
I think I misread what you want. I think you want the extra space i.e.
Code:
todaydat=`date '+%b %e'`
Reply With Quote
  #4 (permalink)  
Old 04-04-06, 12:20
pavan_test pavan_test is offline
Registered User
 
Join Date: Oct 2005
Posts: 45
grep

thanks a lot guys..
it is working fine for me now.

thanks once again
pavi
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On