4 ms·
Linux command line techniques: IO redirection and piping
- rexyo 16y agoVery nice, thanks for sharing
- thingie 16y agoNot really, it's a fraction of the basic functionality of bash, which is not to be learned from a mosaic of random blogposts, but from something more complete. If you want something "more special", try, for example, Unix Power Tools book.
- rexyo 16y agoOf course its just basics, its a good start for beginners. It reminds me of the stuff I used to teach to junior programmers wanting to explore Linux.. Im already an advanced Linux user, but there's always something you haven't come accross yet... Thats one of the things I like best about Linux in general and bash.
- astrange 16y agoIs there a *nix programmer who doesn't know this? This article is hardly worthwhile to anyone vaguely competent.
- deleted 16y ago[deleted]
- russell_h 16y agoNot to diminish the value of the article (which seems well written and probably useful to some), but do these really count as "tricks"? That seems analogous to calling variable assignment a C programming "trick".
- silentbicycle 16y agoIndeed. If you don't know these "tricks", you don't know Unix. That's probably why it says "tricks you need to know". This probably comes from learning Unix via graphical interfaces, such as GNOME on Ubuntu, OS X, etc., and blog posts by other people with the same background. Kernighan and Pike's _The Unix Programming Environment_ is probably still the best place to learn this stuff.
- noglorp 16y agos/tricks/fundamentals
- nodata 16y agoI think most people don't know Linux now. I'm basing this on the nose-diving quality of replies to technical Linux questions and problems over the past couple of years. Normally it goes something like this: A: I have problem X with Y. B: Oh I don't know anything at all about Y, but if you migrate to Z I bet you won't have the problem any more. A: Okay I'll do that. Thanks! or: A: I have a problem X with Y. B: Oh did you try (completely unrelated irrelevant thing) A: No, but I will. Thanks! Seriously.
- silentbicycle 16y agoOn average, the BSD community is quite a bit more clueful. Not because the Linux community is dumb, but because Linux is quite a bit more visible - Complete newbies are dramatically more likely to use a newbie-friendly Linux distro such as Ubuntu than FreeBSD, OpenBSD, etc. (The BSDs seems to get more users who already have experience with Linux or commercial Unices.) Unfortunately, Linux newbies searching for help may run across bad advice from people with barely more experience, creating a feedback loop.
- stevelosh 16y agoThis is all pretty basic stuff. One thing that always bites me is trying to use sudo to redirect to a protected file. This doesn't work, because the shell is doing the redirection, not sudo: sudo cat ~/something.txt | grep 'hello' > ~someoneelse/result.txt You can get around this by using sudo to run a new shell that does the redirection: sudo sh -c "cat ~/something.txt | grep 'hello' > ~someoneelse/result.txt"
- ax0n 16y agosudo cat ~/something.txt | grep 'hello' | sudo tee ~someoneelse/result.txt or use "| sudo tee -a" (append) in place of >>
- jmhobbs 16y agoAs far as redirection goes, this skipped the least known bit (IMHO), closing descriptors. jmhobbs@katya:~$ cat file-that-doesnt-exist cat: file-that-doesnt-exist: No such file or directory jmhobbs@katya:~$ cat file-that-doesnt-exist 2>&- jmhobbs@katya:~$
- nodata 16y agoThese aren't tricks. These are the things you learn on the very first day of using a *nix system. How this is being voted up I will never know.
- randall 16y agoDon't hate on us not-as-technical hackers! :) But seriously, it's helpful as I dive more into the command line.
- nodata 16y agoI don't hate you, I'm just surprised that beginner level stuff is getting this number of votes. I think it's important to say when something isn't working. Even better would be for me to suggest a solution.
- th0ma5 16y agoI wonder if HN will wind up being sort of like Slashdot in the sense that the experienced people on the site will continue to make the site rich of such experience, but will be accommodating to those not experienced in whatever area, and slowly, over time, the inexperienced will continue to exert influence. Mind you, not as a collective whole, but as an ongoing wave of new people (those inexperienced people will become experiences either though reading the site, or just going along as usual). So could this cause a slight dumbing down of the site? Or will the two groups (veterans vs. inexperienced) just read different articles?
- nodata 16y agoI'd like HN to stay experienced only. I'm not sure how that can happen. Maybe new members votes count less, like wise or experienced peoples' advice counts for more. The alternative is to do what reddit does: subreddits. Or do what reddit doesn't do: automatic filtering (essentially per-user subreddits based on past voting).
- cellularmitosis 16y ago'cat christmas_list.txt | sort > christmas_list.txt' the above is wrong. that will clobber the file.