2021-07-29 05:44:12 -07:00
|
|
|
#!/usr/bin/env dash
|
|
|
|
# this version of slit uses tabs for input/output field separators.
|
2021-07-29 00:37:35 -07:00
|
|
|
# YES_ZSH
|
2021-07-29 05:44:12 -07:00
|
|
|
# YES_BASH
|
|
|
|
# YES_DASH
|
2021-07-29 00:37:35 -07:00
|
|
|
|
|
|
|
slitt() {
|
2021-07-29 05:44:12 -07:00
|
|
|
[ $# -gt 0 ] || { printf "%s\n" "$0: too few arguments" >&2; return 1; }
|
|
|
|
#echo "$@" | awk '{for(i=1;i<NF;i++)printf"$%s,",$(i);print"$"$NF}'
|
|
|
|
local fields="$(printf ',$%s' $@ | cut -b2-)"
|
|
|
|
awk "BEGIN { FS=\"\\t\"; OFS=\"\\t\" } { print $fields }"
|
|
|
|
|
|
|
|
# via: https://github.com/sorin-ionescu/prezto/
|
|
|
|
#awk "BEGIN { FS=\"\\t\"; OFS=\"\\t\" } { print ${(j:,:):-\$${^@}} }"
|
2021-07-29 00:37:35 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
[ "${SOURCING:-0}" -gt 0 ] || slitt "$@"
|