Re: Read/Write files from a script?
2006. július 19. 16:31,
Mladen Adamovic <firstname.lastname@example.org>
-> Debian User <email@example.com>,:
> Tony Terlecki wrote:
> >> Is there a shell command to read files? I want to open a text file,
> >> loop through each line and parse the line of text.
> > Depending on what you want to do:
> > man sed
> > man awk
> Yeah, but he asked about shell commands which read files, and that is 'cat'
> so my addon to your answer is : see also 'man cat'
"The purpose of cat is to concatenate (or "catenate") files. If it's only one
file, concatenating it with nothing at all is a waste of time, and costs you
a process." — Randal L. Schwartz
> In bash script you might use something like
> for i in $(cat yourfile);
> do_something_with $i
In a bash script you should use something like this:
for i in $(<yourfile)