gnu-coreutils

Binary "tail" a file

I would guess most people on this site are familiar with tail, if not - it provides a "follow" mode that as text is appended to the file tail will dump those characters out to the terminal. What I am looking for (and possibly to write myself if necessary) is a version of tail that works on binary files. Basically I have a wireless link ...

top command's CPU usage calculation

I am trying to use GNU coreutil top's formula for calculating CPU usages in percentage. But top is using some half_total, to calculate the percentage, which is adding 0.5 to the percentage. In utils.c of top's source, the following line (at 3.8 beta1, it is in line number: 459): - out++ = (int)((diffs++ * 1000 + half_total) / total_ch...

Forcing the order of output fields from cut command

I want to do something like this: cat abcd.txt | cut -f 2,1 and I want the order to be 2 and then 1 in the output. On the machine I am testing (FreeBSD 6), this is not happening (its printing in 1,2 order). Can you tell me how to do this? I know I can always write a shell script to do this reversing, but I am looking for something us...

Less gets keyboard input from stderr?

Hello! I'm taking a look at the code to the 'less' utility, specifically how it gets keyboard input. Interestingly, on line 80 of ttyin.c, it sets the file descriptor to read from: /* * Try /dev/tty. * If that doesn't work, use file descriptor 2, * which in Unix is usually attached to the screen, * but also...

Using ed to manipulate files matched by find

Following the bash-hackers wiki's recommendation, I want to edit files using ed. In particular I want to do the following with ed instead of sed: find . -type f -exec sed -i -e 's/a/b/g' {} \; I see that ed doesn't have opt like sed's -e, so as far as I know, pipes and io redirections are the only way to work with it non-interactivel...

Structured output between linux commands

I am looking for any papers, implementations, or just general ideas about common linux/unix utilities writing/reading structured output/input. The structured output could be anything, xml, jsopn, yaml, etc. This question: http://stackoverflow.com/questions/703163/formatting-shell-output-into-structured-data asks pretty much what I am...

Calculate the total space consumption of specific files in unix terminal

I have a folder containing .tcb and .tch files. I need to know what the size of all .tcb files together, respectively of all .tch files is. I did like this: 1) I created a temp folder and then: mv *tch temp 2) and then: du -sk temp I found the command in the Internet and wikipedia says this: "du (abbreviated from disk usage) is a ...

What's the most efficient way to get a sorted, human-readable du output on Mac OS 10.6?

I used to have this sweet alias for du I called dusort that would print out a human-readable list of sizes for the top-level subdirectories+files sorted by size. It was like a mini-filelight for mac that runs in terminal. But now my alias is broken after I copied it to my new mac running Mac OS 10.6. Apparently the sort I used either ca...