16 ms·
The Art of Command Line (2015)
- merricksb 7y agoA big discussion 4 years ago: https://news.ycombinator.com/item?id=9720813 https://news.ycombinator.com/item?id=9720813 (Provided for interest purposes, not suggesting it's a dupe - https://news.ycombinator.com/newsfaq.html https://news.ycombinator.com/newsfaq.html)
- mychael 7y agoI feel grateful for learning these tools before repos like this existed. Discovering new CLI tools back then was like learning about new bands by word of mouth – it made it more special.
- iamaelephant 7y agoI don't need my job to be "special", I just want to be effective.
- unmole 7y agoSome of use these outside our jobs.
- hazz99 7y agoI remember finding out about ctrl+r, I thought it was incredible. The shell has so many helpful features and I'm continuously discovering more.
- Insanity 7y agoI was so happy when I found out ctrl+r. I can't believe I went so many years without using it, and now I use it constantly.
- legends2k 7y agoNow couple that with infinite bash command history and you never have to type out any command more than once. Search for eternal bash history and set it up once. I can point out its usefulness more.
- virusduck 7y agoFeast your eyes on this, then: https://github.com/junegunn/fzf https://github.com/junegunn/fzf
- enriquto 7y agoBefore "repos" existed there already were widely available manuals, with exactly equivalent content as this repo. And excellent printed books, for example, "the unix programming environment" by Kernighan and Pike is a beautiful read, even if somewhat dated.
- schwurb 7y agoJust yesterday in the students room I whiteness the awe-inducing effect and joy of discovery that a proficient use of Vim has on someone who has never seen something like this before ;)
- commandlinefan 7y agoI often wonder if I would have been able to achieve command-line fluency if I had been born 10 years later. GUIs just weren’t a thing when I was learning computers, so I had no choice but to learn to work on the command line. I can tell that it was time well spent now - I can script solutions to things that GUI-only folks sometimes spend hours repetitively doing “by hand”, but it took years to get to that point. I can’t entirely blame somebody for giving up and saying, “meh, the ‘long way’ is good enough”.
- asdff 7y agoI'm considering going on a GUI cleanse and working command line only for a while to build my chops. Bold idea, or absolutely insane?
- commandlinefan 7y agoProbably insane, but if we were sane we wouldn’t be programmers, would we? ; ) I actually sometimes develop Java apps entirely on the command line using only shell scripts (no maven or gradle), so I have to download all the dependencies and resolve all the transitive dependencies myself. It’s a bit time consuming, but I end up discovering a lot of intricacies of some of the libraries I work with that I would never have come across otherwise. You can even debug using jdb, although at times System.out.println is less painful.
- dTal 7y agoIt's perfectly possible, and not that insane. Much more possible than most people likely think. The primary pain point is mostly web browsing - for a long time Elinks was the only halfway-viable web browser, and it has a lot of pain points. But maybe brow.sh is better these days - I've never tried it (although, arguably, running Firefox through a shoddy GUI inside a terminal doesn't really count as a "GUI cleanse".) It's worth doing, purely for the enlightenment of freeing you from the busted, "macho" notion that a GUI is inferior to a command line. GUIs are awesome.
- mattxxx 7y agoI was ready to knock it, but it's actually a decent reference. If you're just picking it up, check it out.
- ImaCake 7y agoSlight tangent, but forcing biology undergrads to work their way through this would probably help them a lot when they suddenly get saddled with some sequencing output and have literally never heard of Bash let alone used it. My lab of 40+ people has maybe 2 or 3 people who know how to use the command line.
- yitchelle 7y agoGenuine curious of the use case of command line by biology students. Can you elaborate?
- deleted 7y ago[deleted]
- joycian 7y agoWhen you have DNA sequencing data, you often have to use bash / command line to glue together the various tooling. As an example: https://bedtools.readthedocs.io/en/latest/ https://bedtools.readthedocs.io/en/latest/
- cure 7y agoYes, this is very common. But there are also many people who use Common Workflow Language (https://www.commonwl.org/ https://www.commonwl.org/) for this purpose. CWL allows for workflow portability between execution engines. The open source engine my team creates (Arvados - https://arvados.org https://arvados.org) is ideal for large-scale processing work. We store, process and manage petabytes of genome data with it, and execute workflows that span hundreds of simultaneous compute nodes.
- joycian 7y agoThis looks very cool! Thanks for sharing it. I'm definitely going to mention this in the next technical meeting at the research group.
- JdeBP 7y ago
- fuckyah 7y agoI love the fish shell. it comes nicely configured out of the box! just awesome: https://fishshell.com https://fishshell.com
- Zardoz84 7y agoIt's missing nmon and bmon
- Cthulhu_ 7y agoDo I really have to point out that it's an open source project and you're free to write it and open up a pull request instead of merely pointing out things in a comment thread? At least make the effort and open up an issue in the project itself - provide your motivation, link to resources, etc.
- Zardoz84 7y agoI thought about doing it, but I can't do it from a phone on a train.
- smith-kyle 7y ago> Learn basic Bash. Actually, type man bash and at least skim the whole thing; it's pretty easy to follow and not that long Skimming The Grapes of Wrath would be shorter. Thank you, but no thank you.
- heinrichhartman 7y agoHow large is it? Like 40p when you put it on a printer? Let me help you with this: man -t bash > man.ps && lpr man.ps Then, grab a coffee, sit in the sun and spent some quality time with your tools. :)
- acqq 7y agoThe man pages are the worst form of information ever for anybody trying to really solve any real-life problem which is not specified as "learn all unnecessary switches and once-useful but used-by-nobody-today options of a command X." It happened to me often enough that even when I knew what I wanted to achieve and which command X could do that I would first try to read darned man page and fail to find the solution, but then just googling gave enough of material to a) have something to try b) have a discussion of the cases where that "something" doesn't fulfill the use most use cases of those who asked (the "natural need") including, of course, the use case I've had. I have a completely opposite attitude. Bash is horrible on many levels. Bash man page is only a part of horribleness. The main problem for all man pages is that they are mostly as if written for those who already know about every unnecessary detail of both the tool in question and all related tools or environmental issues, but who searches for some even more obscure detail among all obscure details that they already know. Not to mention the descriptions that aren't: e.g. the complete explanation of the option --frob-blonk FILE would be something like "this option uses the FILE as the frob blonk" oh, how helpful. I use bash every day, but I've at least managed to reduce its use to the minimum that keeps me still sane.
- mFixman 7y agoSkimming the bash manpage every once in a while is important to stay out of information bubbles. There are too many developers who rely only on Google/Stack Overflow to find and write answers to questions, and it's common to repeat bad, incomplete, or outdated information. I can think of a lot of times when the most accepted SO answer for many questions was "copy and paste this gigantic block of code" instead of using an existing command.
- molteanu 7y agoMany people also use the classic Emacs, particularly for larger editing tasks. (Of course, any modern software developer working on an extensive project is unlikely to use only a pure text-based editor and should also be familiar with modern graphical IDEs and tools.) Huh?! Unlikely?!
- joycian 7y agoMost people I know use IDE with code style enforcement, automatic variable renaming, unused variable warning, etc.
- Asooka 7y agoi.e. Emacs? Or Vim? Or VSCode? Especially with language servers there isn't much difference between the three, except that VSCode is a bit primitive in the editing department, but if it works for you, by all means.
- y4mi 7y agoyes, unlikely. most people use IDE's, very few limit themselves to simple editors. they're very rare but do exist.
- sureaboutthis 7y agoSo you think emacs is a simple editor, eh?
- y4mi 7y agoVanilla emacs without config and plugins, started as a terminal application is a simple editor, just the same as vim. Yes. But that is entirely besides the point. The parent was outraged how developers are unlikely to use only simple text editors. And the phrase he was taking an issues with didn't say that emacs is a simple editor either. So you're either willingly misinterpreting everything or just unable to read and understand simple sentences.
- 7y ago
- dvfjsdhgfv 7y ago> Obscure but useful I find the choice of the word "obscure" a bit amusing, given that this section lists many commands used ona daily basis by thousands of syadmins.
- mvindahl 7y agoSkimmed most of it but still learned some useful stuff. Will keep it in my bookmarks. Also, would suggest mentioning gitbash in the Windows section. You get it for free with git so it's easy to come by, even in corporate environments where obtaining permission to install software is hard. If combined with something like ConEmu, it's actually pretty nice.
- lprd 7y agoThis looks great! Is there an equivalent for zsh users?
- enriquto 7y ago> This looks great! Is there an equivalent for zsh users? Most of it works just the same.
- kensai 7y agoIs it worth it to master the (newly reloaded) Windows Terminal?
- rgoulter 7y agoWindows Terminal is like iTerm2 / xterm etc. CMD.exe, Posh is like bash, zsh, etc. It's less likely you'll "master" a terminal emulator. (Other than figuring out settings where the defaults get in your way of using it).
- Riverheart 7y agoIf you work with Windows at all it's worthwhile to have some Powershell scripting chops for system automation. And while it's kind of like Bash, it's syntax is more common and everything is an object which is nice. No more string parsing hoops to get basic info.
- follower 7y agoIf pictures or a hand-drawn look is more your thing, Julia Evan's work is very accessible. She sells zines like "Bite Size Command Line!" https://jvns.ca/blog/2018/08/05/new-zine--bite-size-command-line/ https://jvns.ca/blog/2018/08/05/new-zine--bite-size-command-... but also posts a lot of the content on Twitter too: e.g. https://twitter.com/i/moments/1026078161115729920 https://twitter.com/i/moments/1026078161115729920 (I actually made a proof-of-concept tool called 0rk which displays the images in the terminal https://github.com/follower/0rk https://github.com/follower/0rk so you don't even have to leave your terminal to look something up.) There's also the TLDR pages project which aims to create "Simplified and community-driven man pages" with practical examples which looks like a helpful approach: https://tldr.sh/ https://tldr.sh/ Not sure if any of the TLDR clients already do this but it just occurred to me it'd be cool to be able to view an example and then edit it directly...
- augustk 7y agoMy suggestion would be: Learn basic POSIX Shell (sh). It's smaller than Bash and more portable. https://pubs.opengroup.org/onlinepubs/007904875/utilities/xcu_chap02.html https://pubs.opengroup.org/onlinepubs/007904875/utilities/xc...
- klmr 7y agoIt’s also really limited. I do a lot of shell programming and I lean heavily on Bashisms to get any work done. Even in Bash I’m hitting the wall constantly. Sh-only is utterly impractical: Reading code from big projects that try to stay compatible (e.g. automake) really show-cases these limitations. For instance, performing proper argument quoting of variables without arrays is next to impossible.
- naniwaduni 7y agoEven POSIX sh gives you effectively gives you a stack of lists in $@, one for each function call. If you absolutely must, you can maintain proper quoting very far with those. Shell is not as limited as you think, though it can be rather inefficient about it and it's probably not a good choice for programs whose designs it isn't especially good at handling. For whatever reason, programmers tend to be rather dismissive of non-general-purpose programming languages, or more generally languages that do not work like conventional general-purpose languages, and refuse to learn them. I think the worst case we see of this is with CSS, where people come up with elaborate ways to place boxes procedurally in javascript (and JS once suffered from being considered a toy language, too), but I've seen similar attitudes get pointed at things like apache configuration, systemd unit files, jq, and Lua. (On the other end, sometimes people believe that they're just writing configuration, and that this is somehow more maintainable than writing code, when really they're writing code embedded in a data description language; see Chef, Ansible &c.) As for autotools, autoconf's "Portable Shell Programming" document covers seriously ancient shells. New programs following those guidelines aren't trying to stay compatible: their code isn't going to compile on the relics that run those shells without active effort that generally isn't happening. It's just a cargo cult.
- yjftsjthsd-h 7y ago
- aljarry 7y agoSome time ago I stumbled upon a really good introduction to text manipulation in command line: https://developer.ibm.com/articles/au-unixtext/ https://developer.ibm.com/articles/au-unixtext/ After years of using bits of bash I've found quite a few new things for me.
- JdeBP 7y agoHave you ever read Unix Text Processing?
- sjy 7y agoIf you're an experienced command line user, this is a great reminder of how far you've come, and check list to figure out where your weak spots lie. I wonder how long these skills will remain useful; skeptics often seem to (wrongly) think that the CLI is 'obsolete.' I learned some of the things on this list more than 10 years ago and I am sure for some people it has been much longer than that. If anything, the increased prevalence of embedded Linux devices has made these skills feel more useful over time.
- dhimes 7y agoHoly crap! I never knew curl cheat.sh/<command> was a thing. All these years....
- g_sch 7y agoWhile this has some helpful pointers, I found it amusing that some points were relatively little work, while others contain enough to keep you busy for weeks - for example, comparing output redirection to network management.
- casper345 7y ago> Know > overwrites the output file and >> appends. Learn about stdout and stderr. Yep, learned that the hard way
- mlang23 7y agoGosh! How is it possible I missed C-x C-e for over 20 years?
- flavious 7y agoI've written many thousand lines of code in bash (along with way more in 15 years of programming in other languages) and I must tell you: Never again! Use xonch at least.