Possible Duplicate:
Get the newest file based on timestamp
I primary want to select latest dump file from specific folder so i can store in variable and use it import using import script
I want to list specific files from a specific, I tried:
a= $(ls -ltr /home/oracle/testora/MAUL01*.dmp | awk '{print $9}' | tail -1)
echo $a
I want output as:
MAUL01.DP.09-27-2012_09_15.dmp
instead of:
/home/oracle/testora/MAUL01.DP.09-27-2012_09_15.dmp
Problems:
ls is not working for me inside sh (working fine from unix)
file name is shown with path (I trid using basename, but cannot make it work)
In bash, you can use the
${parameter##word}syntax to remove everything before the last/.You can also use
ls -tr1, then you won’t needawk.This is shown below: