Labeled Tab-Separated Value parser / manipulator for shell
Shell
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
COPYING
LTSV.sh
README.markdown
test.sh

README.markdown

Labeled Tab-Separated Value parser / manipulator for shell

What's this?

See http://ltsv.org/ and the following example:

#!/bin/bash
# or
#!/bin/ksh

. ./LTSV.sh

## Define a hash to store values
typeset -A hash
## Parse an LTSV in a string
LTSV_decode hash "foo:Foo	bar:Bar	baz:*baz*"
## Parse an LTSV read from STDIN
#LTSV_decode hash

echo "${hash[foo]}"
echo "${hash[bar]}"
echo "${hash[baz]}"

for key in "${!hash[@]}"; do
  echo "$key: ${hash[$key]}"
done

## Manipulate an LTSV from a hash
LTSV_encode hash

Requirements

  • bash or ksh (ksh93)

TODO

  • Add more test
  • Support zsh
  • LTSV_encode: Reject or escape TAB and CR character in values