Hacker News new | past | comments | ask | show | jobs | submit login

But how to reconcile this advice with the "unnecessary cat" zealots. Just let me live my life guys.



Just use pv, you don't need cat with it like shown in the article:

    pv some.iso >/dev/sdb
Or if you don't care about progress bar, you can use cp:

    cp some.iso /dev/sdb


I didn't check if it works for writing to a volume, but wouldn't this simple input work?

  < some.iso > /dev/sdb


Redirection isn't very useful here without a command. Put a 'cat' in front of it, for example.


Have you never tried it?

    % cat > foo
    fred
    barney
    wilma
    betty
    % < foo > bar
    % cat bar
    fred
    barney
    wilma
    betty
    % diff foo bar
    %


I wasn't able to do that with bash. Not at the computer now though so I can't try it again to see if I had screwed it up.

Update: Back at the computer now, and I cannot replicate it with bash:

    rascul@smarts:~/mm> cat > foo
    fred
    barney
    wilma
    betty
    rascul@smarts:~/mm> < foo > bar
    rascul@smarts:~/mm> cat bar
    rascul@smarts:~/mm>
I'm curious what shell you did that with.


That's in zsh. Yeah, I guess there are shells where it won't work.


I think it's a zshism. I can't seem to do it in dash either.


I've since tried in two versions of Bash (3.2 and 5.1) and in five different varieties of ksh (oksh, mksh, ksh93, pdksh, GNU ksh). It does seem to be a zshism. All the others do the redirect into the destination, but only zsh provides the content of the redirect from source without some other command to read it.

The zsh way seems more properly fitting with the philosophy of the Unix shell to me. It would be an uphill battle getting everyone else to change that behavior, though.


I've been using this for a long time now and I didn't know if what a zshism because it felt so simple to use and Unixy, TIL too, thanks!


interesting! TIL


If you look at https://news.ycombinator.com/item?id=33334043 it turns out rascul was right and it appears to be only zsh that handles the reading of the redirected input without some other command to hand it off to.


I saw all that. Still, was interesting.

I just happened to explore this on an M1, so I had a shell that would do things this way.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: