🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.unix.shell
Article #1774

Reading a file from within a C-shell script

#1774
From: Tom Parker
Date: Wed, 14 Nov 1990 21:24
41 lines
1374 bytes
wes@uh.msc.umn.edu (Wes Barris) 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?
>
 
Here is a C-shell script to read lines from a file
 
# Read lines from a file.
    set noglob
    set cmd = $0
    set file = $1
    if ("$file" == "") then
       echo "Usage:   $cmd:t file"
       exit 4
       endif
    @ i = 1
    set lines = `wc -l $file` || exit
    while ($i <= $lines[1])
       set a = `sed -n "${i}p;${i}q" $file`
       echo $i $#a $a
       @ i++
       end
    exit
Technical Details
Message-ID: <9172@ncar.ucar.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!ncar!bierstadt.scd.ucar.edu!tparker

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!ncar!bierstadt.scd.ucar.edu!tparker
From: tparker@bierstadt.scd.ucar.edu (Tom Parker)
Newsgroups: comp.unix.shell
Subject: Reading a file from within a C-shell script
Message-ID: <9172@ncar.ucar.edu>
Date: 14 Nov 90 21:24:53 GMT
Sender: news@ncar.ucar.edu
Reply-To: tparker@bierstadt.scd.ucar.edu (Tom Parker)
Organization: Scientific Computing Division/NCAR, Boulder, CO
Lines: 41