On Fri, 04 Aug 2000, Daniel Woods pushed some small plastic letters in this order:
> > > I am new to shell scripting, 
> > > I would like to create a script in bash shell.
> > > that would do the following
> > > 
> > > 1) find out the latest file ( text file)in a directory
> > > ( there are bunch of files in a dir)
> 
> This will work...
>     cd {directory}
>     ls -t | head -1
> or
>     ls -t $HOME | head -1
> 
> Using ksh (on Unix), this next line works to only accept files
>     x=`ls -t | head -1`; if [[ -f $x ]]; then echo $x ;fi
> except that I could not get this to work with bash as
>     x=`ls -t | head -1`; if [ -f $x ]; then echo $x ;fi
> since the '-f $x' seems to fail the test. Anyone know why ?
> 

As far as each shell goes those lines are direct equivalents. Is the directory
that you're working in changing? Only regular files will show up with either
command.

Tony

Reply via email to