Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Quick Question 1

Status
Not open for further replies.

Scunningham99

Programmer
Sep 20, 2001
815
GB
Hi

i have the following script to find the latest file with a *.arc extension. However the following code produes error when run as a script:-

*.arc: No such file or directory

#find the latest archive file
FILE=`ls -tr '*.arc' /findata/u04/oracle/proddata/archive | tail -1`

thanks in advance
 
Simon, try:

FILE=`ls -tr /findata/u04/oracle/proddata/archive/*.arc | tail -1`

HTH.
 
Thanks for reply!

this is strange as the command
ls -tr /findata/u04/oracle/proddata/archive/*.arc | tail -1

works from command line as does the one i was using previousy. But when run from a script does not.

Instead when run from a script
ls -tr /findata/u04/oracle/proddata/archive/*.arc | tail -1 produces nothing, even when i remove tail -1.
 
SORRY IGNORE MY LAST QUOTE --MISSED OFF echo $FILE

HOWEVER NOW IT IS RETURNING FULL PATH. INSTEAD I WOULD LIKE TO ONLY RETURN THE FILE *.arc NOT

/findata/u04/oracle/proddata/archive/arch_1_535.arc

 
Simon,

try cd'ing to the appropriate directory first. Hopefully this will work.

Cheers.
 
You could also use `basename /path/to/file` to get just the filename. //Daniel
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top