Coder of Salvation™ — programming / opensource / console / minimal
The ultimate dataformat for Bash: tab,space, and comma separated? But how?
I wish there was a textformat which enables me to share data between many programminglanguages including bash.
Because I want to use data from other sources (spreadsheets, applications etc).
Solution: Tabular data (SSV/TSV/CSV)
Tabular tabledata is easy to manage in bash (and if not, awk does). Space separated values (SSV) is natively supported by bash:
echo "one two three" | while read a b c; do
# outputs: one,two,three
TSV works fine too when the field separator (Default:space) is changed to tabs:
echo -e "one\ttwo\tthree" | while IFS=$'\t' read a b c; do
CSV works fine with gnu awk, which is installed on most systems:
cat foo.csv | csvget 1 3
NOTE: my personal favorite is csv since because of its import/export feature in spreadsheet editors.
Conversion between TSV, CSV, and SSV
from TSV to SSV
$ echo -e "foo\tbar" | expand
from SSV to TSV
$ echo "foo bar" | unexpand
from CSV to TSV
Bonus: nice output in the console
CSV,TSV,SSV can look messy very easily:
$ cat foo.csv
BACKLOG,"","emailtemplate: layout optimize","",
DONE,notifs,"emailtemplate: cancel subscription abstract workflow thru sb? (yes!)","",
BACKLOG,notcus,"improved error logging (using log function) + errorscreen","",
Well, this looks better:
$ cat foo.csv | csv2table
13 BACKLOG webapp transfer paypal to bank
221 BACKLOG dd variable filters+digest payed
58 BACKLOG bshlive bshlive openshift (php webpipes
Other ideas: mashup with other languages
Bash is ready for it, are you?
comments powered by
All rights reserved by Leon van Kammen under this license