Hacker News new | ask | show | jobs
by retroafroman 5569 days ago
The command line is the most flexible way to automate day to day tasks. Yes, a graphical installer makes things easy-once. Need to change the names of multiple files in a directory? Need to delete files that match a certain type, without hunting and pecking? Want to grab every jpg from a webpage? Doing these tasks on the command line is trivial compared to pointing and clicking for every single instance.

There are many benefits from using the command line interface to software. Often it is a trade off between flexibility and speed versus learning and thinking. It takes time to build up a solid knowledge of commands and options, and effort to recall them, but once that skill is acquired, it can save a lot of time.

1 comments

Ok...so where do I get started. I've seen a lot of command lines over the last few weeks and nothing in them gave me the impression that there was any sort of logic or automation going on. The all look like just one thing is happening. (And that is one of my strikes against them is that they seem to completely lack context)
Start looking into bash scripting, for one. Learning a scripting language like python or perl can do a lot of the same things and is valuable in other ways.

To your comment of looking like just one thing is happening, that is understandable to the untrained mind. Let's take an example where I want to delete all the .bak copies of my old configuration files. To do this I would enter the directory and simply type:

    rm *.bak
It's one command, but the star is expanding it to match every file that has a .bak ending. One command line entry, many executions of the 'rm' command.

Yes, context and a trained eye are everything. I like to think that working on the command line is one of many styles of working. It works very well for me in some situations, so I suggest to others to try it out and see if it would fit their needs as well.

Bash is probably the second worst thing unix has to offer, right after vi.

The command you demonstrated is only slightly faster than sorting the directory by type in a file explorer and selecting them with mouse and selecting delete from context menu, and much more dangerous, ie. when you mistype it as rm * .bak you just deleted everything in that folder permanently, whereas in a GUI you would've seen what you actually selected, and most likely only moved them to trash, not permanently deleted them right away.