Linux command line techniques: IO redirection and piping(blog.interstellr.com)
blog.interstellr.com
Linux command line techniques: IO redirection and piping
http://blog.interstellr.com/linux-command-line-tricks-you-need-to-know-io
7 comments
Not 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".
Indeed. 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.
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.
I 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.
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.
On 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.
Unfortunately, Linux newbies searching for help may run across bad advice from people with barely more experience, creating a feedback loop.
s/tricks/fundamentals
Is there a *nix programmer who doesn't know this? This article is hardly worthwhile to anyone vaguely competent.
[deleted]
These 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.
I 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?
I'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).
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).
Don't hate on us not-as-technical hackers! :)
But seriously, it's helpful as I dive more into the command line.
But seriously, it's helpful as I dive more into the command line.
I 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.
As 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:~$'cat christmas_list.txt | sort > christmas_list.txt'
the above is wrong. that will clobber the file.
the above is wrong. that will clobber the file.
Very nice, thanks for sharing
Not 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.
Of 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.
You can get around this by using sudo to run a new shell that does the redirection: