Live data from Hacker News

Linux Commands for Developers

blog.jayfields.com

1–10 of 67 posts

Re: Linux Commands for Developers

#6
I was expecting to see the first comment in here complaining about his use of 'cat', as in all of the examples his second argument could've easily taken a filename argument..

  sort order.*
is surely more elegant than

  cat order.* | sort
which is fair enough, however, as it happens, i generally do end up using 'cat' in the way he's used it.. for such small jobs nobody can be genuinely worried about the overhead, and it comes down to a matter of taste..

personally, i find that using 'cat output | $command' helps to separate out the 'logic' of what i'm doing, if that makes sense..

also, again, purely as a matter of taste

i'd prefer

  egrep 'Hardcover|Kindle'
over

  grep "\(Kindle\|Hardcover\)"
EDIT: (as alexfoo has pointed out, this isn't a proper AND as it worries about the order.. my bad, still useful though :D )

and as a sidenote, something i only found recently, but which is quite useful, a logical AND with egrep looks like

  egrep 'Hardcover.*Kindle'

Re: Linux Commands for Developers

#7

tail -f filename should definitely make the list, essential for watching what's appended to log files in real time.

I prefer:-

tail -F filename

as most of the logfiles I need to watch tend to wrap at some point and 'tail -f' doesn't check for inode changes.

(-F is a non-standard option, it's there on GNU's [EDIT] tail binary and OS-X but not Solaris for example).

Re: Linux Commands for Developers

#8
post #6

I was expecting to see the first comment in here complaining about his use of 'cat', as in all of the examples his second argument could've easily taken a filename argument.. sort order.* is surely more elegant than cat order.* | sort which is fair enough, however, as it happens, i generally do end up using 'cat' in the way he's used it.. for such small jobs nobody can be genuinely worried about the overhead, and it…

Indeed, I don't see why people get so upset (or pedantic) about what are, effectively, NOPs in command-lines.

However, things change if you start adding certain options to sort:-

  sort -m order.*
and

  cat order.* | sort -m
are definitely not the same thing (for most input files at least).

Re: Linux Commands for Developers

#9
post #6

I was expecting to see the first comment in here complaining about his use of 'cat', as in all of the examples his second argument could've easily taken a filename argument.. sort order.* is surely more elegant than cat order.* | sort which is fair enough, however, as it happens, i generally do end up using 'cat' in the way he's used it.. for such small jobs nobody can be genuinely worried about the overhead, and it…

[ EDIT - Two replies as original post had been edited by the time I posted the first. ]

> and as a sidenote, something i only found recently, but which is quite useful, a logical AND with egrep looks like > > egrep 'Hardcover.Kindle'

That's not a true logical AND since it won't pick up an entry with the text "Kindle Hardcover". Only entries with the word "Hardcover" eventually followed by "Kindle". To cover both cases you'd need:-

  egrep 'Hardcover.*Kindle|Kindle.*Hardcover'
(Of course, someone will now show how this can be done in even fewer characters).

Re: Linux Commands for Developers

#10
I thought to learn something useful for programing (debugging, program runtime analysis, etc.). But instead the article is just about the generic commands cat, sort, grep, cut, sed, uniq, find and less. It is not really development related.
Post reply on HN