4 ms·
I disagree. To me that is the value. If I wanted to write a script I'd use Python. If I want to do something as a oneliner I use Awk and don't worry about anyth
by 3rdAccount 8y ago
I disagree. To me that is the value. If I wanted to write a script I'd use Python. If I want to do something as a oneliner I use Awk and don't worry about anything as it isn't saved.
- mehrdadn 8y ago> To me that is the value. Interesting... to me the value (er, a value) is that you can write /PATTERN/ { print $3 } instead of import re, sys for line in sys.stdin: if re.search('PATTERN', line): print(line.split()[2]) And another value is that it's more likely to be preinstalled than Python.
- 3rdAccount 8y agoI think you misunderstand me as we might agree. Python is great for small to medium scripts, but can be verbose for the really small stuff that works better as a combination of Linux and Awk commands. Python has a lot of stuff in the standard library that I'm going to guess is missing from Awk (Sqlite, Sets, Classes...etc).
- mehrdadn 8y agoI guess the example I gave you was a one-liner but I didn't intend to constrain it to such. Just a week or two ago I wrote a 33-line script (that seems to fall squarely in your "small-to-medium" category) to calculate the minimal set of packages I need to install on Ubuntu in order to obtain the same set of packages I have right now. 28 of those 33 lines were an awk script consisting of three /PATTERN/{} blocks and one END{} block. It seemed about as simple as it could possibly be, and doing it in Python would've probably been twice as verbose.
- fireattack 8y agoDoes this python example actually work? What does line.split()[2] do?
- mehrdadn 8y agohttps://onlinegdb.com/SkTP0yfW7 https://onlinegdb.com/SkTP0yfW7
- fireattack 8y agoThanks. I thought /PATTERN/ { print $3 } is about to extract 3rd group of the regex.
- detaro 8y agoit splits line into substrings at spaces, and then selects the third substring.
- cup-of-tea 8y agoIsn't saved? I log my bash history forever and have tools to help with grepping. Also for any serious data processing not saving the process is unacceptable. But I guess you're talking more sysadmin type tasks and yeah, I write throwaway awks all the time.
- 3rdAccount 8y agoI have a variety of dev machines at work and the history can't be counted on. Yea, reproducible data analysis is good, but some tasks are just really simple and aren't worth it. Most of my terminal stuff is just running processes and grep/awk. Any major data analysis is probably in a SQL query which I do save on our wiki page. I really like the concept of Wolfram Mathematica Notebooks as you can essentially embed everything into a reproducible analysis (what they call a computational essay). The free and open source equivalent is Jupyter notebooks.
- cup-of-tea 8y agoYou could do it with a little extra effort. I used to work on a cluster and ran bash on any of hundreds of machines. Having my entire history available at all times saved me countless times.