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 12-13-2008
new_learner new_learner is offline
Registered User
  
 

Join Date: Nov 2008
Posts: 15
Question problem with output of find command being input to basename command...

Hi,

I am triying to make sure that there exists only one file with the pattern abc* in path /path/. This directory is having many huge files. If there is only one file then I have to take its complete name only to use furter in my script.

I am planning to do like this:

if [ `find /path/abc* | wc -l` == 1 ]; then
x=`find /path/abc*`
y=`basename $x`
fi

I am triying to combine x=`find... and y=`basename... into one sentence using "|".

y=`find /path/abc* | basename`

But I am getting below error:

Usage: basename String [Suffix]

Can any one suggest if there is a better way to do this or help me combine these two commands into one.

Thank you.