Re: "for" and line by line

From: Chris F.A. Johnson (cfajohnson_at_gmail.com)
Date: 10/29/04


Date: 29 Oct 2004 07:34:21 GMT

On 2004-10-29, Markus Wenke wrote:
> Hi,
>
> I want to write a "for"-loop in bash such like this one:
>
> for LINE in `cat /etc/passwd`; do
> echo $LINE
> done
>
> But I get every word, and not every line. and if I set "IFS=^M" like this:
>
>
> IFS=[CTRL V][ENTER] for LINE in `cat /etc/passwd`; do
> echo $LINE
> done
>
> the bash can't read the command.
>
> How can I realise it?

while IFS= read -r LINE
do
   echo $LINE
done < /etc/passwd

-- 
    Chris F.A. Johnson                  http://cfaj.freeshell.org/shell
    ===================================================================
    My code (if any) in this post is copyright 2004, Chris F.A. Johnson
    and may be copied under the terms of the GNU General Public License


Relevant Pages

  • Re: dir /b
    ... > Bash (at the command line, ... > $ echo qw!er ... GNU bash, version 2.05b.0-release ... [root@halo root]# mkdir -p example/1 ...
    (comp.unix.shell)
  • Re: Probably very stupid script/bash question
    ... The following extract is from 'man bash';-),although what it ... Process substitution is supported on systems that support ... the current command as the result of the expansion. ... $ read list <(echo this is a test) ...
    (Debian-User)
  • Re: ffmpeg for mass conversion
    ... can anyone tell me what is the command for mass conversion? ... I do such things mostly with a for bash provides. ... This will echo all files and directories found in the working dir (the ...
    (Ubuntu)
  • Re: modifying case of dirs and files name
    ... > problem is how bash manage something into the command I create. ... on echo, quoting, and command substitution. ... built-ins for many of the more modern shells and implementations ...
    (comp.unix.shell)
  • Re: Not working in bash or csh
    ... You have to look for info about the echo command, ... I don't know about csh, but for bash try: ...
    (comp.unix.shell)