Space problem in files


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Space problem in files
# 1  
Old 05-22-2007
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
# 2  
Old 05-22-2007
Are you trying to check whether files in list.txt exists? Can you show list.txt?
# 3  
Old 05-22-2007
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"
# 4  
Old 05-22-2007
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.
# 5  
Old 05-22-2007
Okay,

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

like:

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

Then ...
# 6  
Old 05-22-2007
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

# 7  
Old 05-22-2007
Great,

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

Any way of doing this for loop.

Thanks
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

SDiff Two files with space problem

Hello guys, I have a problem. I'm trying to use SDiff with two files which are containing spaces. My problem is that I want to save the output with > in an extra file. If I try to use it like this. sdiff "test file1" "test file2" > OutputfileI get this message: usage: diff ... (11 Replies)
Discussion started by: Mariopart
11 Replies

2. AIX

Problem space used on AIX 5.3

Hello everyone, Sorry for my English but i'm French. I have a problem on an AIX 5.3 server on the occupation of a file system. When i run a df -m, this is what i get : Filesystem MB blocks Free %Used Iused %Iused Mounted on /dev/fslv09 3936.00 340.94 92% 7255 ... (8 Replies)
Discussion started by: Veis
8 Replies

3. HP-UX

Problem running out of space by copying files to identical filesystems

I am trying to copy a filesystem from one server to another using rsync over the WAN. As far as I can tell, the two filesystems are identical but for some reason I cannot copy the last file because I keep running out of space. SERVER 1: mkfs -m <lvol> mkfs -F vxfs -o... (1 Reply)
Discussion started by: keelba
1 Replies

4. UNIX for Dummies Questions & Answers

File Space Problem

I have a file which have 2 columns. chris doc,male test,female So in order to store the content of the first column i am doing this :- for line in $( cat $test.csv ); do FIRST_COLUMN_VAR=$( echo $line | cut -d"," -f1 ) SECOND_COLUMN_VAR=$( echo $line | cut -d"," -f2 ) ... (18 Replies)
Discussion started by: chris1234
18 Replies

5. UNIX for Advanced & Expert Users

Swap space problem

Hy! Recently i had a problem with one of mine Tru64 machines. It started to kill processes because of low amount of swap space. It said that it went below 10 %. But when i ran swapon -s it said: In-use space: 12 % So, the system couldn't accept any new ssh connections plus it killed most of... (1 Reply)
Discussion started by: veccinho
1 Replies

6. Shell Programming and Scripting

Everywhere space problem

Solved.... (1 Reply)
Discussion started by: redbeard_06
1 Replies

7. UNIX for Dummies Questions & Answers

when I try to run rm on multiple files I have problem to delete files with space

Hello when I try to run rm on multiple files I have problem to delete files with space. I have this command : find . -name "*.cmd" | xargs \rm -f it doing the work fine but when it comes across files with spaces like : "my foo file.cmd" it refuse to delete it why? (1 Reply)
Discussion started by: umen
1 Replies

8. UNIX for Advanced & Expert Users

Swap Space Problem?

Over the last couple of days my laptop has been stalling terribly on bootup and when starting up applications (even a terminal takes ages to come up) Whilst trying to figure out whats happened I noticed that nothing is being swapped out. Output from top command shows that I have approx 500mb... (2 Replies)
Discussion started by: silvaman
2 Replies

9. Filesystems, Disks and Memory

problem with swap space

I have sun solaris 8 for intell with 128m physiccal ram and swap of 148. Oracle requires to have 512M swap space. Is there a way I can change the swap space on intell machine without repartioning the box:? what if i create a link to /swap from another place???? pls advise Jigar (1 Reply)
Discussion started by: jigarlakhani
1 Replies

10. UNIX for Advanced & Expert Users

Problem with space

I am in the initial stage of learning UNIX. I got PC with Intel SUN SOLARIS S/W. I am planning to install Oracle on the same machine. I have created /export with more than 3gb space, when I have installed the OS. As a Oracle user when I am trying to create a directory I am able to get only 512... (4 Replies)
Discussion started by: suraj
4 Replies
Login or Register to Ask a Question