|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
I have a file (a.lst) that has a list of fully pathed filenames, 1 per line - in this format:
"/path/to/the/name_of_file.doc" "/path/to/the/other/name of the doc noting spaces.doc" I need to know how I can loop through this file, a.lst, and for each entry, perform a test -s on it. If it exists, I want to put the entry into exists.txt, if it does not, I want to put the entry in noexist.txt - Can someone please help me? (I've tried for foo in `cat a.lst`, but due to the spaces in 90% of the filenames, it pukes, as it appears to be using space as the delimiter) Thanks again, Michael ![]() |
|
#2
|
|||
|
|||
|
I think you can use awk options -
awk '{print $0}' list will print each line and you can use -F to define the field separator |
|
#3
|
|||
|
|||
|
input has to be redirected & variable double quoted:
#! /bin/sh while read foo do echo "$foo" test -f "$foo" && echo "$foo" >> exists.txt || echo "$foo" >> noexists.txt done < a.txt or (same thing) cat a.txt | while read foo ... done |
![]() |
| Viewing: Dev Shed Forums > Operating Systems > UNIX Help > Unix Scripting Question |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|