User Tools

Site Tools


python_cli

using python instead of tr

get_column_names.py $filename | grep -i coupon | \
python -c "import sys; print(','.join(line.strip() for line in sys.stdin))"

sort lines by length

import fileinput
print("".join(sorted(fileinput.input(), key=len)))

On the command line:

% cat random_snippets.txt | python -c 'import fileinput; print("".join(sorted(fileinput.input(), key=len)))'

Ref:- https://stackoverflow.com/questions/34401683/how-to-use-awk-to-sort-lines-by-length/

See also:

sql string in clause

cat junk3.txt | \
python -c "import sys; print('\'', '\', \''.join(line.strip() for line in sys.stdin), '\'', sep='')"
python_cli.txt · Last modified: 2021/02/28 06:27 by raju