Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Shell programming: Search a blank

Status
Not open for further replies.

cadbilbao

Programmer
Apr 9, 2001
233
ES
Hi!

I'm creating a shell script, and I want to execute a command only if there is a blank in ${FILE}.

How could I carry it out?

if _?_?_?_ then
[command]
fi

Thank you very much.
 
simple if you want an underscore char:
here is a shellfunction that does the trick.

glob_under() {
_dir=$1

for x in `ls $_dir`
do

if [ -f "$x" ]
then
echo $x | grep _
else
continue
fi
done
}

called like:
glob_under /tmp

Now if you are talking about real whitespace
between name elements: there are file conversion utilities for this: sort the filename data first or use one of these to rename these files.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top