spaceherpe61
Technical User
I am looking for some help on using a wildcard in a bash script. I am trying to find the oldest file in directory. When I run the script using [user@server /usr/utilities]$sh -x script.sh <directory> the script works fine. It sets the variable to the oldest file. However when I run the script like this [user@server /usr/utilities]$./script.sh <directory>
it never sets the variable which blows up my script. Here is how I am setting the variable.
cd $1
getoldestfile=`ls -lat *.TXT | grep ^- | tail -1 | head -1`
file=`echo $getoldestfile |cut -d " " -f 9`
Any help would greatly be appreciated.
it never sets the variable which blows up my script. Here is how I am setting the variable.
cd $1
getoldestfile=`ls -lat *.TXT | grep ^- | tail -1 | head -1`
file=`echo $getoldestfile |cut -d " " -f 9`
Any help would greatly be appreciated.