Live data from Hacker News

Linux Commands for Developers

blog.jayfields.com

31–40 of 67 posts

Re: Linux Commands for Developers

#31

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

less +F filename does the same thing, but loses the following when the logfile gets rotated. Does the same thing happen to tail -f? (edit: alexfoo answered that tail -F tracks the file properly)

one benefit to less +F is that you can cancel the following and read normally in less.

Re: Linux Commands for Developers

#32
I was surprised and a little disappointed that `join(1)` didn't join the list!

With the files in the example (order.out.log, order.in.log), to join every record on it's id, you would do something like:

  $ join -j 2 order.out.log order.in.log

  111, 8:22:19 1, Patterns of Enterprise Architecture, Kindle edition, 39.99 8:22:20 Order Complete
  112, 8:23:45 1, Joy of Clojure, Hardcover, 29.99 8:23:50 Order sent to fulfillment
  113, 8:24:19 -1, Patterns of Enterprise Architecture, Kindle edition, 39.99 8:24:20 Refund sent to processing

Re: Linux Commands for Developers

#34
post #9

Earlier quoted context omitted.

[ 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 cas…

How about: grep Hardcover | grep Kindle

Yup, but I had meant in one command though, i.e.

  sed -n '/Kindle/{/Hardcover/p}'

Re: Linux Commands for Developers

#35
post #33

I think it's obligatory that someone writes 'strace' in threads about articles like this, so here goes. strace is fantastic for debugging certain categories of problem.

Absolutely, especially for those who do network programming under Unix/Linux. Combined with lsof, it can help a lot in troubleshooting issues such as deadlocks.

Re: Linux Commands for Developers

#36
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…

Moreover if you use cat, it can be easily replaced with e.g. zcat to do whatever you want with gzipped files.

Re: Linux Commands for Developers

#38
post #18

how do I execute the out put of something like this: grep -i 'pattern' file | awk '{print $5}' | sed 's/^/cmd/g' I end up sending to a file, chmod, then run it at the shell.

In bash... $(grep -i 'pattern' file | awk '{print $5}' | sed 's/^/cmd/g') ? Or surround in backticks `command which outputs text you want to run as a command` I prefer $() as they nest better. Or have I misunderstood your question?

That's it $() works. thanks.

Re: Linux Commands for Developers

#40
post #30
post #23

Earlier quoted context omitted.

Perhaps because sending GiBs through read(2) and write(2) unnecessarily isn't a NOP?

Who said NOPs are free? NOPs still take at least one clock cycle.

It's not that simple anymore... In modern CPUs, NOPs are discarded by the decoding units so they never occupy the exeuction units. If decoding BW is not saturated (and most often, it's not), NOPs are indeed "free".
Post reply on HN