[opensuse] Bash with special pipe support
Hi, for all of those who already knowing that bash can not be used for doing things like echo 1 2 | read a b echo $a $b may test out the current bash 4.1.7 in the repository http://download.opensuse.org/repositories/shells/ for SLES11, SLES11-SP1, 11.0, 11.1, 11.2, and factory. bash> echo 1 2 | read a b; echo $a $b 1 2 bash> echo 1 2 | while read a b; do x=$a y=$b; done bash> echo $x $y 1 2 ... compare with point E4 of the FAQ of the bash e.g. at http://www.unixguide.net/unix/bash/E4.shtml Werner -- "Having a smoking section in a restaurant is like having a peeing section in a swimming pool." -- Edward Burr -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On 6/24/2010 7:43 AM, Dr. Werner Fink wrote:
Hi,
for all of those who already knowing that bash can not be used for doing things like
echo 1 2 | read a b echo $a $b
may test out the current bash 4.1.7 in the repository
http://download.opensuse.org/repositories/shells/
for SLES11, SLES11-SP1, 11.0, 11.1, 11.2, and factory.
bash> echo 1 2 | read a b; echo $a $b 1 2 bash> echo 1 2 | while read a b; do x=$a y=$b; done bash> echo $x $y 1 2
... compare with point E4 of the FAQ of the bash e.g. at http://www.unixguide.net/unix/bash/E4.shtml
Awesome. One more down, fifty more to go and someday I may finally not need ksh any more. The dude must be a genus because there are so many great killer ksh features that have been there since at least ksh88, 1988!!!, and bash still doesn't have them. My favorite use of ksh's special pipe support is to read a delimited string of values (say from a config file or csv or other data interchange file) into discrete variables, in a single line of code, like php's explode function. Been doing it for ages in ksh. grep "^$1:" config.txt |IFS=: read ACCT FTPHOST FTPUSER FTPPASS EMAIL VARIOUS OTHER STUFF... or grep "^$SOMETHING," data.csv |IFS=, read f[1] f[2] f [3] f[4] f[5] f[6] or grep "^$SOMEUSER" /etc/passwd | IFS=: xUSER xPASS xUID xGID xGECOS xHOME xSHELL echo "${SOMEUSER}'s home directory is ${xHOME}." -- bkw -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
participants (2)
-
Brian K. White
-
Dr. Werner Fink