Re: bash: How to make the 'read' built-in read the trailing spaces as well?
- From: Stephane CHAZELAS <stephane_chazelas@xxxxxxxx>
- Date: Mon, 20 Oct 2008 09:39:08 +0000 (UTC)
2008-10-19, 03:10(-07), Harry:
[...]
Can I somehow make the 'read' built-in read the trailing spaces as[...]
well from a line of input?
Remove the space character from the IFS special variable. If you
also want trailing (and leading) tabs not to be stripped, remove
it as well.
IFS= read -r line
is the idiom to read one line (or to eof) from standard input
into a variable. -r is to avoid the special handling of the
backslash characters.
I tend to avoid using the read command as that means you end up
running a lot of commands to process a text files. Most tools in
the Unix toolchest do read text files by themselves, so it's
better to use those tools to process all the lines at once.
--
Stéphane
.
- References:
- Prev by Date: Re: bash: How to make a filename double-quote friendly?
- Next by Date: Re: bash: How to make a filename double-quote friendly?
- Previous by thread: Re: bash: How to make the 'read' built-in read the trailing spaces as well?
- Next by thread: bash: How to make a filename double-quote friendly?
- Index(es):
Relevant Pages
|