News for hackers. Stuff that matters.
Re:Linux command line techniques: IO redirection and piping by stevelosh on Wednesday November 03, 2010 @01:25PM (#1865581)
This 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"
Re:Linux command line techniques: IO redirection and piping by ax0n on Wednesday November 03, 2010 @02:28PM (#1865857)
sudo cat ~/something.txt | grep 'hello' | sudo tee ~someoneelse/result.txt

or use "| sudo tee -a" (append) in place of >>

Re:Linux command line techniques: IO redirection and piping by russell_h on Wednesday November 03, 2010 @01:25PM (#1865577)
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".
Re:Linux command line techniques: IO redirection and piping by silentbicycle on Wednesday November 03, 2010 @01:44PM (#1865666)
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.

Re:Linux command line techniques: IO redirection and piping by nodata on Wednesday November 03, 2010 @05:04PM (#1866512)
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.

Re:Linux command line techniques: IO redirection and piping by silentbicycle on Wednesday November 03, 2010 @05:29PM (#1866610)
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.

Re:Linux command line techniques: IO redirection and piping by noglorp on Wednesday November 03, 2010 @04:08PM (#1866280)
s/tricks/fundamentals
Re:Linux command line techniques: IO redirection and piping by astrange on Wednesday November 03, 2010 @01:23PM (#1865568)
Is there a *nix programmer who doesn't know this? This article is hardly worthwhile to anyone vaguely competent.
Re:Linux command line techniques: IO redirection and piping by nodata on Wednesday November 03, 2010 @01:41PM (#1865648)
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.
Re:Linux command line techniques: IO redirection and piping by th0ma5 on Wednesday November 03, 2010 @04:14PM (#1866301)
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?
Re:Linux command line techniques: IO redirection and piping by nodata on Wednesday November 03, 2010 @04:59PM (#1866499)
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).

Re:Linux command line techniques: IO redirection and piping by randall on Wednesday November 03, 2010 @02:27PM (#1865849)
Don't hate on us not-as-technical hackers! :)

But seriously, it's helpful as I dive more into the command line.

Re:Linux command line techniques: IO redirection and piping by nodata on Wednesday November 03, 2010 @05:01PM (#1866504)
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.
Re:Linux command line techniques: IO redirection and piping by jmhobbs on Wednesday November 03, 2010 @01:41PM (#1865643)
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:~$
Re:Linux command line techniques: IO redirection and piping by cellularmitosis on Wednesday November 03, 2010 @05:12PM (#1866540)
'cat christmas_list.txt | sort > christmas_list.txt'

the above is wrong. that will clobber the file.

Re:Linux command line techniques: IO redirection and piping by rexyo on Wednesday November 03, 2010 @12:42PM (#1865379)
Very nice, thanks for sharing
Re:Linux command line techniques: IO redirection and piping by thingie on Wednesday November 03, 2010 @01:25PM (#1865580)
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.
Re:Linux command line techniques: IO redirection and piping by rexyo on Thursday November 04, 2010 @07:46AM (#1868479)
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.