|
|
|
|
|
by Klasiaster
2209 days ago
|
|
Inspired by a remark about Python's default split behavior in comment https://news.ycombinator.com/item?id=23446146 I wrote a Python oneliner for field selection works similar to "choose" but throws exceptions when the field cannot be found: $ echo " a b c" | choose 1 2
b c
$ echo " a b c" | python3 -c 'import sys; [print(f[1], f[2]) for line in sys.stdin if (f := line.split()) or True]'
b c
|
|