Live data from Hacker News

Ask HN: What am I missing re: fascination with command lines

news.ycombinator.com

11–15 of 15 posts

Re: Ask HN: What am I missing re: fascination with command lines

#11
Hmm. What's your workflow for reencoding every file in a directory with a name matching a certain pattern and then renaming the reencoded files with a number based on the order that the original files were in? For example, M2441j.avi (an MPEG) should be reencoded into H.264 and then renamed to 23.mp4. All files not matching M###j.avi should be ignored.

Yes, I know that this probably isn't something that you ever do, but humor me. Would you go hunting through, identify all those files and then reencode and rename them by hand? I certainly wouldn't, I would spend maybe five minutes writing and testing a script to do it for me, and then just invoke it every time I needed to do so again in the future.

Programming is all about automation, and the command line is perfect for making programs that do easily repeatable tasks. It's also far easier to debug. As an analogy, do you prefer writing programs by hand or putting together building blocks? It's the exact same thing.

Re: Ask HN: What am I missing re: fascination with command lines

#12
I think that whenever there is only a single likely goal (such as "having installed something"), anything more than one command is a problem, and installers are useful.

But any site that gives a list of 25 commands is Doing It Wrong. The whole point of a script is to perform sequences of commands, and a link to a script is just as useful as an installer GUI would be. Except that it's actually better:

- When a script is used, it seems more likely that someone has actually run it. (Who knows if they've updated their document?) There also won't be copy/paste errors.

- A script is transparent; an installer isn't (even when it dumps logs, they're usually a bit vague). It's easier to see that a script will work, and easier to explain what happened if it didn't work.

- Many people don't want step-by-step or excessive explanations, and a script nicely solves this through embedded comments and code. If you need explanations or details, there's a place for them that's out of the way. And if you don't, you can blindly run the script. It's a nice separation.

Re: Ask HN: What am I missing re: fascination with command lines

#13
post #9

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 ma…

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.

Re: Ask HN: What am I missing re: fascination with command lines

#14
post #9

Earlier quoted context omitted.

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 *…

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.

Re: Ask HN: What am I missing re: fascination with command lines

#15
Well do you want a gadget or a toolbox? GUI's are gadgets, they do what the person who wrote it thinks is a good idea. There is nothing wrong with this. The command line is a toolbox, there is all sorts of stuff you can do to make uniq things happen.

Now from the POV of putting something out there for developers to use which is easier to publish and get out there:

* Several installer GUI's: mac, linux, windows

* about a page of instructions on how to get this done

Which would be the Minimum Viable Product and let you ship now?

Post reply on HN