🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.unix.shell
1 messages
1 total messages Started by Tom Parker Wed, 14 Nov 1990 21:24
Reading a file from within a C-shell script
#1774
Author: 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
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