Live data from Hacker News

Unix Commands I Abuse Every Day

everythingsysadmin.com

21–30 of 108 posts

Re: Unix Commands I Abuse Every Day

#21
post #18
post #11

Earlier quoted context omitted.

I have long thought that some sort of zsh completion that detects that abuse of cat and converts it into the more appropriate `< file` might be a good idea. If it did it silently it probably wouldn't be worth it but if it actually preformed the substitution in front of you then it might help users get more comfortable with the carrot syntax.

The ` < file` has to appear at/near the end of the line, right? Using cat has the advantage of being able to read the line from left to right along with the data flow. I often add more piped commands to the end of a line as I refine it, while the source data remains the same. (To be fair, sometimes the opposite is true.)

Nope,

    
and even

    ./command 
works fine in Bash and Zsh.

Re: Unix Commands I Abuse Every Day

#22
post #11
post #6

Random note. The most commonly "abused" Unix command is cat. The name is short for "concatenate", and its intended purpose was originally to combine 2 or more files at once. Therefore every time you use it to spool one file into a pipeline, that is technically an abuse!

I have long thought that some sort of zsh completion that detects that abuse of cat and converts it into the more appropriate `< file` might be a good idea. If it did it silently it probably wouldn't be worth it but if it actually preformed the substitution in front of you then it might help users get more comfortable with the carrot syntax.

> carrot syntax

Heh. Be careful with this, though: ^ is the caret (note spelling) according to most sources of information about these things.

Random Fun Geekery Time: Back in the Before-Before, the grapheme in ASCII at the codepoint ^ is now was an up-arrow character, which is why BASIC uses ^ for exponentiation even though FORTRAN, which came first and which early BASIC dialects greatly copied, uses .

These days, ↑ is U+2191, or &uarr; in HTML.

http://www.alanwood.net/unicode/arrows.html

http://www.fileformat.info/info/unicode/char/2191/index.htm

http://en.wikipedia.org/wiki/Caret

Re: Unix Commands I Abuse Every Day

#23
post #3

cat foo | less Normally I'd typed something like "grep -i 'something' foo | less", and wanted to just up arrow the previous line and change the grep stuff to cat. I don't know why, it doesn't really save me anything. Maybe it's the hackerish "because I can, that's why" instinct at work.

It'll save you a few more keystrokes if you do cat !$ | less !$ is "the last argument to the previous command".

If you do

    less .
it will save you even more keystrokes.

Re: Unix Commands I Abuse Every Day

#24
post #5
post #4

Earlier quoted context omitted.

If you like xargs, but want jobs to execute in parallel, you may enjoy GNU parallel. Your trivial example: find images -name "*.jpg" | parallel convert -geometry 200x {} {.}_thumb.jpg

xargs --max-procs=#

The nice thing about parallel is that it can actually run some of the instances on remote machines using SSH, transparently (as long as they have the commands). You just need a couple of parameters and it takes care of uploading the files the command needs and then downloading the results. It's quite awesome.

Re: Unix Commands I Abuse Every Day

#26
I like this but i can't decide if it's technically abuse or not. The paste command will happily parse - (meaning read from stdin) multiple times, so for transposing a list into a table:

  file.txt:
  line1
  line2
  line3
  line4
  line5
  line6

  $ paste - - - 
Combine with the column command for pretty printing. I seem to find a use for this pretty frequently.

I like the simplicity of this one but it's not very useful day to day:

  $ echo *
As a replacement for "ls".

Re: Unix Commands I Abuse Every Day

#27
post #19
post #11

Earlier quoted context omitted.

I have long thought that some sort of zsh completion that detects that abuse of cat and converts it into the more appropriate `< file` might be a good idea. If it did it silently it probably wouldn't be worth it but if it actually preformed the substitution in front of you then it might help users get more comfortable with the carrot syntax.

Does it really matter that you're starting an extra process?

it doesnt matter for a file of size 1kb. For a file of size 10Gb, every process matters.

For the downvoters: please time how long it takes to do something like `cat $file | awk '{print $1}' ` and `awk <$file '{print $1}'`

Re: Unix Commands I Abuse Every Day

#28
post #6

Random note. The most commonly "abused" Unix command is cat. The name is short for "concatenate", and its intended purpose was originally to combine 2 or more files at once. Therefore every time you use it to spool one file into a pipeline, that is technically an abuse!

shell input redirection doesn't work inside eshell, the only way I know to pipe into stdin from eshell is to use cat
Post reply on HN