python_cli
Table of Contents
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:
- https://www.google.com/books/edition/The_Python_3_Standard_Library_by_Example/KtcnDwAAQBAJ?hl=en&gbpv=0 - The Python 3 Standard Library by Example - Doug Hellmann - 2017 . This book gives many sample scripts that make use of fileinput; The scripts are very practical in nature and explained well.
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