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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Scripting/spaces in filenames

Status
Not open for further replies.

mikeEd

Programmer
Nov 26, 2001
160
GB
I'm never sure how to deal with spaces in filenames with bash scripting.

e.g. If I have a line like
for i in `find . -name '*.txt'` ...
and one of the filenames in the current directory has spaces in it, it will return an 'i' for each word in the name.

What's the correct way to deal with this?
 
Hi,

Try
find . -name "*.txt" -print | while read ITEM; do
# do what you want with ITEM
done

Don't know why it works better ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top