🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.unix.shell
Article #1780

Re: Reading a file from withing a C-shell script

#1780
From: 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
Technical Details
Message-ID: <1990Nov15.142750.27306@cid.aes.doe.CA>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!crdgw1!rpi!zaphod.mps.ohio-state.edu!usc!cs.utexas.edu!news-server.csri.toronto.edu!clyde.concordia.ca!cidsv01.cid.aes.doe.CA!afsipmh
References: <2945@uc.msc.umn.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!crdgw1!rpi!zaphod.mps.ohio-state.edu!usc!cs.utexas.edu!news-server.csri.toronto.edu!clyde.concordia.ca!cidsv01.cid.aes.doe.CA!afsipmh
From: afsipmh@cid.aes.doe.CA (Patrick Hertel)
Newsgroups: comp.unix.shell
Subject: Re: Reading a file from withing a C-shell script
Message-ID: <1990Nov15.142750.27306@cid.aes.doe.CA>
Date: 15 Nov 90 14:27:50 GMT
References: <2945@uc.msc.umn.edu>
Reply-To: afsipmh@cid.aes.doe.CA (Patrick Hertel)
Organization: Environment Canada
Lines: 37