?
Solved

shell script to reads lines of a file ?

Posted on 2007-11-16
2
Medium Priority
?
530 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

Understanding Linux Permissions

Linux for beginners: How to view the permissions associated with files and directories and also how you can change them.

Question has a verified solution.

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

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…
Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses

777 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