Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

shell script to reads lines of a file ?

Posted on 2007-11-16
2
Medium Priority
?
532 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 84

Expert Comment

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

Accepted Solution

by:
ahoffmann earned 2000 total points
ID: 20303812
(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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently I have been answering a lot of questions like this in IT forums that I frequent. The question posed is usually something along the lines of "We have software X installed and need to uninstall it for reason Y" or some other variant of the sa…
I hope you'll find this tutorial useful and interesting. So let's try to extend Tcl with a new package.  For anyone more deeply interested please check out the book "Practical Programming in Tcl and Tk". It's really one of the best written books abo…
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses

604 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