Skip to main content
1 of 2
slm
  • 379.7k
  • 127
  • 793
  • 897

If you're using turbo C shell (tcsh) you can use the following approach. Say I had this sample file:

$ cat afile 
1
2
3
4
5

And this script:

$ cat cmd.csh 
#!/bin/tcsh

foreach i (`cat afile`) 
  echo "$i" 
end

Running it will produce this output:

$ ./cmd.csh
1
2
3
4
5
slm
  • 379.7k
  • 127
  • 793
  • 897