Re: bash: How to make the 'read' built-in read the trailing spaces as well?



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
.



Relevant Pages

  • Re: Icon with a URL in Shortcut
    ... have to call it in the command. ... I don't use Firefox and won't know where you chose to install it. ... except you never have to quote the URL. ... So a web site that foolishly used a space character ...
    (microsoft.public.windows.vista.general)
  • Re: Command line quotes
    ... | Since the space character acts as the separator between commands in the ... | command line it doesn't make much sense to enclose the whole command line ... | command line in quote characters makes sense since the quote characters ...
    (microsoft.public.vb.general.discussion)
  • Re: Converet plain text to table
    ... then try surrounding the space character (but not the ... by an assortment of spaces and tabs. ... wildcard search by using the expression ... To search for multiple tabs, use an expression like the one above with the ^9 ...
    (microsoft.public.word.newusers)
  • Re: How do you set the dircmd environmental variable in XP?
    ... there is NO "REM" before this line, so it should execute. ... insert a space character between the switches. ... However, the page at the link above showed examples of using the "dir" command with parameters which weren't separated by commas or spaces, only forward slashes. ...
    (microsoft.public.windowsxp.general)
  • Re: An index {puzzle}.
    ... If you want to index a space character, ... also fails because the category of % is also changed: ... I had a problem like this with a similar command ... TeX's tokenization mechanism is invoked and since ...
    (comp.text.tex)