[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: bash "while do echo" can't function correctly
From: |
Stephane Chazelas |
Subject: |
Re: bash "while do echo" can't function correctly |
Date: |
Wed, 13 Apr 2016 15:28:02 +0100 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
2016-04-13 08:55:16 -0400, Greg Wooledge:
[...]
> > And if you want to keep eventual spurious characters after the
> > last NL character in the file:
> >
> > while IFS= read -r line; do printf '%s\n' "$line"; done < test.txt
> > [ -z "$line" ] || printf %s "$line"
>
> Another way to write that is:
>
> while IFS= read -r line || [[ $line ]]; do ... done < test.txt
[...]
Except that it would add an extra newline character (which may
be desired as well).
--
Stephane