Solved

shell script to reads lines of a file ?

Posted on 2007-11-16
2
521 Views
Last Modified: 2013-12-26
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
Comment
Question by:pillmill
2 Comments
 
LVL 84

Expert Comment

by:ozo
Comment Utility
#!/bin/bash
f=$1
while read d ; do
  echo  $d
done < $f
0
 
LVL 51

Accepted Solution

by:
ahoffmann earned 500 total points
Comment Utility
(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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This tutorial will discuss fancy secure registration forms, with AJAX technology support. In this article I assume you already know HTML and some JS. I will write the code using WhizBase Server Pages, so you need to know some basics in WBSP (you mig…
In this tutorial I will show you how to make a simple HTML bar chart with the usage of WhizBase, If you want more information about WhizBase please read my previous articles at http://www.experts-exchange.com/ARTH_5123186.html (http://www.experts-ex…
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now