bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Read stdin delimited fails on empty field


From: Todd Merriman
Subject: Read stdin delimited fails on empty field
Date: Thu, 7 Jul 2016 15:01:31 -0400
User-agent: SquirrelMail/1.4.22-4.el6

Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64'
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-redhat-linux-gnu'
-DCONF_VENDOR='redhat' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash'
-DSHELL -DHAVE_CONFIG_H   -I.  -I. -I./include -I./lib  -D_GNU_SOURCE
-DRECYCLES_PIDS -DDEFAULT_PATH_VALUE='/usr/local/bin:/usr/bin'  -O2 -g
-pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong
--param=ssp-buffer-size=4 -grecord-gcc-switches   -m64 -mtune=generic
uname output: Linux orion.toolz.com 3.10.0-327.18.2.el7.x86_64 #1 SMP Thu
May 12 11:03:55 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
Machine Type: x86_64-redhat-linux-gnu

Bash Version: 4.2
Patch Level: 46
Release Status: release

Description:
        IFS='   ' # TAB
        program_outputting_tab_delimited_fields |
        while read -r FLD1 FLD2 FLD3 FLD4
        do
                echo field1=$FLD1
                echo field2=$FLD2
                echo field3=$FLD3
                echo field4=$FLD4
        done

Repeat-By:
        If any fields are empty, the data is read into the preceding field.
        In other words, if in the example FLD3 is empty, FLD4 is read into
        FLD3.  If FLD2 and FLD3 are empty, FLD4 is read into FLD1.






reply via email to

[Prev in Thread] Current Thread [Next in Thread]