07-18-2016
12,296,
3,792
Join Date: Nov 2008
Last Activity: 1 January 2021, 1:47 AM EST
Location: Amsterdam
Posts: 12,296
Thanks Given: 679
Thanked 3,792 Times in 3,282 Posts
I think one-liners tend to have a bad rep for the wrong reasons.
One-liners are typically used for programming on the command line, where a single line is your real estate. They are very useful as one-off, terse and personal small scripts for an ad-hoc parsing result, for example for general information, problem determination or security forensics. Developing such a small script is usually a lot quicker than editing a file, exiting, running it, re-editing, etc... Typically sysadmins use one-liners a lot for this purpose.
Once a one liner is working and if it proves to be useful for multiple occasions, then it can be turned into a script in a file and then vertical real estate can be used and short names can be replaced by mnemonic names and comments can be added for maintainability and it can be made fool-proof with error conditions. In a script file one-liners are to be a avoided.
These are just two different types of application.
If a one-liner is posted here, it shows the principle or mechanism that can be used to tackle a problem or create an application. The user is free to use it and turn it into a fully maintainable script if he so chooses, or execute it as such on the command line and get his/her result..
Last edited by Scrutinizer; 07-18-2016 at 06:31 AM..