The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Swap space problem veccinho UNIX for Advanced & Expert Users 1 05-26-2008 06:15 AM
Everywhere space problem redbeard_06 Shell Programming and Scripting 1 03-01-2007 06:30 AM
when I try to run rm on multiple files I have problem to delete files with space umen UNIX for Dummies Questions & Answers 1 09-20-2005 12:20 AM
problem with swap space jigarlakhani Filesystems, Disks and Memory 1 04-04-2002 07:42 AM
Problem with space suraj UNIX for Advanced & Expert Users 4 03-03-2002 07:58 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-21-2007
Registered User
 

Join Date: Jan 2005
Posts: 212
Stumble this Post!
Space problem in files

Hi,

I have a file containing a list of entries.

Want to do ls on them.

for a in `cat <list.txt>`; do ls $a; done;

Now some entries contain spaces.
How do i incorporate space in $a.

Quoting $a in "" doesn't help.

Thanks
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 05-21-2007
Registered User
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,397
Stumble this Post!
Are you trying to check whether files in list.txt exists? Can you show list.txt?
Reply With Quote
  #3 (permalink)  
Old 05-21-2007
Registered User
 

Join Date: Jan 2005
Posts: 212
Stumble this Post!
List contains name of files:

eg.

A.txt
The hell.txt
etc.

I want to perform some operations on all.

Now how do i go about with "The Hell.txt"
Reply With Quote
  #4 (permalink)  
Old 05-21-2007
Registered User
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,397
Stumble this Post!
Quote:
Originally Posted by vibhor_agarwali
List contains name of files:

eg.

A.txt
The hell.txt
etc.

I want to perform some operations on all.

Now how do i go about with "The Hell.txt"
Code:
while read file
do
    echo "$file"
done < list.txt
Since some of the filename contain spaces use quotes to do your operation.
Reply With Quote
  #5 (permalink)  
Old 05-21-2007
Registered User
 

Join Date: Jan 2005
Posts: 212
Stumble this Post!
Okay,

And if i have to take it directly from command substitution:

like:

for a in `find . -type f`; do ......

Then ...
Reply With Quote
  #6 (permalink)  
Old 05-21-2007
Registered User
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,397
Stumble this Post!
Quote:
Originally Posted by vibhor_agarwali
Okay,

And if i have to take it directly from command substitution:

like:

for a in `find . -type f`; do ......

Then ...
Code:
find . -type f | while read file
do
         ....
done
Reply With Quote
  #7 (permalink)  
Old 05-21-2007
Registered User
 

Join Date: Jan 2005
Posts: 212
Stumble this Post!
Great,

I generally do my work with for, not pretty convercent with while.

Any way of doing this for loop.

Thanks
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 03:13 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0