Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 537
  • Last Modified:

shell script to reads lines of a file ?

The following script should read lines of the input file, but just
returns the file name. How do I get it to read the lines of the file,
one at a time ?

#! /bin/csh

set f = $1

foreach d ( $f  )

echo  $d

end
0
pillmill
Asked:
pillmill
1 Solution
 
ozoCommented:
#!/bin/bash
f=$1
while read d ; do
  echo  $d
done < $f
0
 
ahoffmannCommented:
(t)csh has no command to read files line by line 'cause there're countless other tools (awk, sed, perl, ...) which do it in a better way
Either switch to sh (or friends like bash) as ozo suggested
or use something like:
  foreach d ("`cat $f`")
    echo $d
  end
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now