Live data from Hacker News

Util-linux cheat sheet

catonmat.net

11–17 of 17 posts

Re: Util-linux cheat sheet

#11
post #9
post #8

Earlier quoted context omitted.

Interesting- the control characters get re-interpreted into screen commands. Thanks for that.

You can achieve the some of the same results with less -R and you also get searching and scrolling. (It colorizes ls's output, but it doesn't do the scrolling or screen-clearing stuff.) To get a handle on why this happens, think of it this way: Back in 1983 using Unix (and I mean a full-size Serious Unix, not Xenix for the 8088 or anything) meant hooking a text terminal (like the brand-new VT-220!) to a minicomputer…

Awesome stuff, derleth. I do remember the days of ctrl-h backspace and ctrl-g ringing a bell. I also remember playing with the escape codes more-- goofy high school ('70s) and college ('80s) tricks. Back in the days of "Creative Computing" (later -> Byte)

Re: Util-linux cheat sheet

#12
post #10
post #2

OK this is more than I need right now, but I did get curious about the "script" command that captures your term session to a text file- to start and stop use: script ctrl-d But when looking at my output file (if you just do what I did above it will be called 'typescript') it has control characters around the file names. How can I suppress these?

Haven't looked at the cheat sheets but... If you just want something readable, a couple of quick and dirty ways are: col -bx You can further clean things up by deleting unwanted lines or characters using sed. strings typescript|sed '1d;/deleteme/d;s/deleteme//g'|less There's also an old utility called ttyrec/ttyplay you might like.

Thanks. It was more curiosity necessity (although now my mind is thinking, "what can I use this for?").

- interesting with ttyrec/ttyplay. I'll check on this if my mind comes up with something important.

Re: Util-linux cheat sheet

#13
post #11
post #9

Earlier quoted context omitted.

You can achieve the some of the same results with less -R and you also get searching and scrolling. (It colorizes ls's output, but it doesn't do the scrolling or screen-clearing stuff.) To get a handle on why this happens, think of it this way: Back in 1983 using Unix (and I mean a full-size Serious Unix, not Xenix for the 8088 or anything) meant hooking a text terminal (like the brand-new VT-220!) to a minicomputer…

Awesome stuff, derleth. I do remember the days of ctrl-h backspace and ctrl-g ringing a bell. I also remember playing with the escape codes more-- goofy high school ('70s) and college ('80s) tricks. Back in the days of "Creative Computing" (later -> Byte)

Almost forgot: Under xterm, at least, ^V is the escape character and ^[ is ESC, so you can type things like:

$ echo '^[[0m^[[01;32mfoo^[[0m'

with a ^V before every ^[ (the ^V doesn't get echoed back to you unless you type ^V^V to enter a single ^V). That makes 'foo' bold and lime green.

Once you learn how to read a terminfo file, you can do everything your terminal is capable of (and xterm can do quite a bit) entirely by typing control codes by hand. Which is pointless, given that tput, from the ncurses package, does the same thing in a much more user-friendly way that's also completely terminal-independent.

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

http://www.gnu.org/software/ncurses/ncurses.html

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

http://tldp.org/HOWTO/Bash-Prompt-HOWTO/x405.html -- Explicitly about using tput, which really is a neat way to make your shell script's output look nice.

Re: Util-linux cheat sheet

#14
post #13
post #11

Earlier quoted context omitted.

Awesome stuff, derleth. I do remember the days of ctrl-h backspace and ctrl-g ringing a bell. I also remember playing with the escape codes more-- goofy high school ('70s) and college ('80s) tricks. Back in the days of "Creative Computing" (later -> Byte)

Almost forgot: Under xterm, at least, ^V is the escape character and ^[ is ESC, so you can type things like: $ echo '^[[0m^[[01;32mfoo^[[0m' with a ^V before every ^[ (the ^V doesn't get echoed back to you unless you type ^V^V to enter a single ^V). That makes 'foo' bold and lime green. Once you learn how to read a terminfo file, you can do everything your terminal is capable of (and xterm can do quite a bit) entirel…

Well, I guess that about makes thoughts of doing anything useful the rest of today pointless....This is way too fun.

Re: Util-linux cheat sheet

#15
I'm guessing this was generated by running `man -f` on the list of executables provided by util-linux.

    descriptions() { xargs -I '{}' man -f '{}' ; }
    executables() { pkgfile -bl $1 | cut -f 2; } # Arch Linux specific
    executables util-linux | descriptions 2> missed | sort | less

Re: Util-linux cheat sheet

#16
post #2

OK this is more than I need right now, but I did get curious about the "script" command that captures your term session to a text file- to start and stop use: script ctrl-d But when looking at my output file (if you just do what I did above it will be called 'typescript') it has control characters around the file names. How can I suppress these?

For more joy:

     script --timing=typescript.time
     
     exit
     scriptreplay -t typescript.time typescript
Try that, say, with a few commands such as 'top', 'mtr www.google.com', and 'vmstat 4 10'.

Re: Util-linux cheat sheet

#17
post #7
post #4

Earlier quoted context omitted.

Which control characters? And you say around file names... did you run "ls" while in your script session? if you generated colorized output, script will record that. If you don't want colorized output, run "\ls" (bypass any alias you might have for ls, and just run ls directly) or use "ls --color=never". You'll still see ^M at the end of each line. You can run "dos2unix typescript" to strip those out. It's script's j…

You are exactly right. Thank you.

You are most welcome.
Post reply on HN