Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2004
    Posts
    28

    Unanswered: 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?

  2. #2
    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 | ...

  3. #3
    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

  4. #4
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •