🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.unix.shell
3 messages
3 total messages Started by Wes Barris Wed, 14 Nov 1990 20:22
Reading a file from withing a C-shell script
#1773
Author: Wes Barris
Date: Wed, 14 Nov 1990 20:22
27 lines
1383 bytes
Suppose one has a file containing names of other files like this:

data.0001.rle
data.0020.rle
data.0025.rle
data.0085.rle

From a C-shell script, I would like to, one-by-one, get the names out
of this data file and do something with them like this:

#!/bin/csh -f
#
#
foreach file (my_file_list)
   echo $file
   process $file
end

Does anyone know how I do that?

      o o o o o o o . . .   ________________________________ _____=======_____
    o      _____            |Wes Barris                    | | wes@msc.edu   |
  .][__n_n_|DD[  ====_____  |Minnesota Supercomputer Center| |(612) 626-1854 |
 >(________|__|_[_________]_|University of Minnesota_______|_|_FAX:_624-6550_|_
 _/oo OOOOO oo`  ooo   ooo  'o^o^o                    o^o^o` 'o^o         o^o`
-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
Noblemen make promises, but peasants have to keep them. -- Russian proverb
Re: Reading a file from withing a C-shell script
#1780
Author: Patrick Hertel
Date: Thu, 15 Nov 1990 14:27
37 lines
1376 bytes
In article <2945@uc.msc.umn.edu> wes@msc.edu writes:
>Suppose one has a file containing names of other files like this:
>
>data.0001.rle
>data.0020.rle
>data.0025.rle
>data.0085.rle
>
>From a C-shell script, I would like to, one-by-one, get the names out
>of this data file and do something with them like this:
>
>#!/bin/csh -f
>#
>#
>foreach file (my_file_list)
>   echo $file
>   process $file
>end
>
>Does anyone know how I do that?

where $1 is the name of your list file 
in the scipt call:

#!/bin/csh -f
#
#
foreach file (`cat $1`)
   echo $file
   process $file
 end

-- 
Pat Hertel                 Canadian Meteorological Centre
Analyst/Programmer         2121 N. Service Rd.        % rm God
phertel@cmc.aes.doe.ca     Dorval,Quebec              rm: God non-existent
Environment Canada         CANADA           H9P1J3
Re: Reading a file from withing a C-shell script
#1784
Author: David I. Berg
Date: Thu, 15 Nov 1990 20:38
18 lines
936 bytes
In article <2945@uc.msc.umn.edu> wes@msc.edu writes:
>Suppose one has a file containing names of other files .......
>..........
>From a C-shell script, I would like to, one-by-one, get the names out
>of this data file and do something with them like this:
>
>............
>foreach file (my_file_list)
>   echo $file
>   process $file
>end
>
>Does anyone know how I do that?

foreach file (`cat my_file_list`)
   echo $file
   process $file
end
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads