mirror of
https://github.com/notwa/rc
synced 2024-11-05 04:39:03 -08:00
18 lines
608 B
Bash
18 lines
608 B
Bash
#!/usr/bin/env dash
|
|
# YES_ZSH
|
|
# YES_BASH
|
|
# YES_DASH
|
|
|
|
slitt() { ### @-
|
|
### view specific columns of text.
|
|
### this version of `slit` uses tabs for its field separators.
|
|
[ $# -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:,:):-\$${^@}} }"
|
|
}
|
|
|
|
[ "${SOURCING:-0}" -gt 0 ] || slitt "$@"
|