mirror of
https://github.com/notwa/rc
synced 2024-12-21 21:49:40 -08:00
21 lines
565 B
Bash
Executable file
21 lines
565 B
Bash
Executable file
#!/usr/bin/env dash
|
|
# compat: +ash +bash +dash +zsh
|
|
|
|
# works with busybox ash.
|
|
|
|
slit() { ### @-
|
|
### view specific columns of text.
|
|
[ $# -gt 0 ] \
|
|
|| { printf '%s: too few arguments\n' "$0" >&2; return 1; }
|
|
local arg=
|
|
for arg; do
|
|
[ "$arg" -ge 0 ] 2>/dev/null \
|
|
|| { printf '%s: not a nonnegative integer: %s\n' "$0" "$arg"; return 1; };
|
|
done
|
|
awk "{ print $(printf ',$%s' $@ | cut -b2-) }"
|
|
|
|
# via: https://github.com/sorin-ionescu/prezto/
|
|
#awk "{ print ${(j:,:):-\$${^@}} }"
|
|
}
|
|
|
|
[ -n "${preload+-}" ] || slit "$@"
|