The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 02-04-2008
ammu ammu is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 79
help with ls commad

hi
I want to display the latest file in script.
say for example

file.txt1
file.txt2
file.txt3(latest)

in the script

var1=`ls -ltr file.txt* | tail-1`
echo $var1


This is what i am using. But this says that file.txt*: No such file or directory


To the same script if I pass file.txt* as parameter and
when i use the below it is working

var1=`ls -ltr $1 | tail-1`
echo $var1


Can some help me with first method

Thanks in advance
Ammu