[Techtalk] weirdness piping to a variable
Peggy Russell
prusselltechgroup at gmail.com
Thu Oct 3 20:11:28 UTC 2013
> name and assign it to the piped sequence of commands in backticks, but
> that's always felt clumsy to me, especially if the chain of piped
> commands was long.
Hi Miriam,
Here's a possible option to address the look:
a=$(echo "quick brown fox" |
cut -d' ' -f2)
The pipe `|` is also considered a continuation character.
Have you worked with index or associative arrays in bash.
They might might work for your processing. IFS is very
powerful in separating words. And then there is a slew
of powerful parameter expansions. And don't forget
regular expressions and BASH_REMATCH.
A Few Bash Resource Favorites
=============================
1) Bash man page
NOTE: Change the format:
* Create PDF doc from man: man -t bash | ps2pdf - bash.pdf
* Create HTML doc from man: man --html=firefox bash
* Create TEXT doc from man: man bash | col -b | kate -i
2) Bash Reference Manual GNU (info page)
http://www.gnu.org/software/bash/manual/bash.html
3) Bash change log
http://tiswww.case.edu/php/chet/bash/CHANGES
NOTE: Could also look at installation package
rpm -q --changelog bash |less
4) Greg Wooledge's Bash Pitfalls, Bash FAQ, Bash Guide
http://mywiki.wooledge.org/
5) Linux Doc Project - Advanced Bash-Scripting Guide
http://tldp.org/LDP/abs/html/abs-guide.html
1) Book - Writing shell scripts
http://linuxcommand.org/writing_shell_scripts.php
2) Handling filenames
http://www.dwheeler.com/essays/fixing-unix-linux-filenames.html
3) Bash One-Liners Explained
http://www.catonmat.net/blog/bash-one-liners-explained-part-one/
4) A lot of good articles on bash here (i.e., Bash by example, Part 1-3)
http://www.ibm.com/search/csass/search/?q=bash
5) The Architecture of Open Source Applications - The Bourne-Again Shell
by Chet Ramey
http://www.aosabook.org/en/bash.html
Peggy Russell
More information about the Techtalk
mailing list