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 > how to do in generic manner?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-09-04, 02:15
calyan calyan is offline
Registered User
 
Join Date: Jan 2004
Posts: 28
how to do in generic manner?

Hi my script goes like this.

gzcat Jan06.gz | awk 'BEGIN { FS = "|" } ; $2 ~ /^[A-Z]{3}$/ { print $2 }' > cnt

sort -n cnt | uniq -c | sort -n > cnt1

cat cnt1 | awk 'BEGIN{OFS="|"} {print $1,$2}' > rep

here i am hard coded Jan06.gz .
but it is inside the dir /gns/gnsadm/notify/bpdcc/work/
every day new file will be generated (ex Jan07,jan08)

how to do in generic manner?
Reply With Quote
  #2 (permalink)  
Old 01-09-04, 09:30
chillies chillies is offline
Registered User
 
Join Date: Jul 2003
Location: Edinburgh
Posts: 35
Re: how to do in generic manner?

To run the script using the most recently modified file in the directory:

LATESTFILE=`ls -t /path/to/directory | head -1`
gzcat $LATESTFILE | ...
Reply With Quote
  #3 (permalink)  
Old 01-12-04, 00:06
calyan calyan is offline
Registered User
 
Join Date: Jan 2004
Posts: 28
What you have said is correct. But other files are also there.
So based on the format is there any way?

Usually file is generated like this

Jan05.gz, Jan06.gz

rgds
s.kalyan
Reply With Quote
  #4 (permalink)  
Old 01-12-04, 04:10
chillies chillies is offline
Registered User
 
Join Date: Jul 2003
Location: Edinburgh
Posts: 35
/bin/date can take arguments to format the output and generate the filename. Something like

FILENAME=$(date +%b%d)

should work, but check the man pages.
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