Return value error

view full story

http://www.unix.com – Hi All, I am new to shell sciprting and i have written a small script to get the filename if it exists. I need to capture the file name using the script and i also need the exit status. The problem i am facing is,though my file does not exists, iam getting the exit status as '0'. Please help me out. My scripts is as follows; Code: #!/usr/bin/ksh folder='/stagep03/cca/data/' cd $folder wild='*' dated=`date +%m%d%y` filename=`ls -l $1$dated$wild | tail -1 |grep ^-|awk '{print $9}'` echo $filename echo $? The output iam getting is; Code: $ sh test.ksh PROCESS1.CAIRP.SSZCKST.A_R. (HowTos)