3 ms·
Curious, in case I'm missing something. Is what you've written equivalent to the following, or is there a reason for the pipe? sort in.txt > out.txt
by femto 13y ago
Curious, in case I'm missing something. Is what you've written equivalent to the following, or is there a reason for the pipe?
sort in.txt > out.txt
- MereInterest 13y agoFrom the other comment, it is completely equivalent, and I will admit that the pipe is due purely to my ignorance. I usually use `sort` for sorting the output of other commands, and so I forget that it can open a file on its own.
- reycharles 13y agoThat usage of cat is "wrong" in general: cat file | command > out is the same as command < file > out
- rat87 13y agoDon't worry about the cat it does have a purpose: portability. cat in.txt | sort > out.txt works in powershell(cat is an alias for Get-Content and sort is an alias for sort-object)(without the sort it wouln't work).
- Someone 13y agoFor those that don't know: there is/was an ancient meme called the "Useless Use of Cat Award" about that subject. See for instance http://en.wikipedia.org/wiki/Cat_(Unix)#Useless_use_of_cat http://en.wikipedia.org/wiki/Cat_(Unix)#Useless_use_of_cat, http://partmaps.org/era/unix/award.html http://partmaps.org/era/unix/award.html, or http://unix.stackexchange.com/questions/16279/should-i-care-about-unnecessary-cats http://unix.stackexchange.com/questions/16279/should-i-care-...