Unix ls --- No such file or directory

I need to capture the condition when jversion returns No such file or directory... ..


jversion=`ls -1td /sbcimp/run/tp/sun/jre/*-64bit* | head -1 | cut -d'/' -f7 | sed 's/v//' | tr -s " " | sed 's/^[ ]//g'`
 
if [????] 
else
fi

Open in new window

LVL 2
tomerpsAsked:
Who is Participating?
 
ozoConnect With a Mentor Commented:
you can make the ls -1td /sbcimp/run/tp/sun/jre/*-64bit* send the No such file or directory error down the pipe to $jversion with ls -1td /sbcimp/run/tp/sun/jre/*-64bit* 2>&1

or you can test for $jversion being blank with
if [ ! $jversionjversion ] ; then
   echo No such file or directory
else
   echo $jversionjversion
fi
0
 
ozoCommented:
is No such file or directory returned in $jversion? or is $jversion blank when ls -1td /sbcimp/run/tp/sun/jre/*-64bit*  prints No such file or directory on stderr?
0
 
tomerpsAuthor Commented:
Hi ozo, thanks for asking...it is done now. i captured the condition with followig code

if [ "$jversion"  = "No match" ] || [ "$jversion" = "0" ] || [ "$jversion" = "" ]
then
....


0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
mikelfritzCommented:
I think ozo answered and should be rewarded to some degree.
0
 
mikelfritzCommented:
agreed
0
 
tomerpsAuthor Commented:
n/a
0
 
mikelfritzCommented:
Do as you like.  I was not involved until the end - on points and fairness only.  I think ozo's answer is perectly valid and shows how the pipes work; beyond that he/she deserves some credit.



0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.