This shows you the differences between two versions of the page.
os:unix [2009/01/17 15:47] 192.168.0.2 |
— (current) | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | //A few nice Unix commands.// | ||
- | ===== Erase all in a directory except one file (or so) ===== | ||
- | |||
- | <code> | ||
- | for i in `ls -1 | grep -v <filetokeep>`; do rm -rf $i; done | ||
- | </code> | ||
- | |||
- | |||
- | ===== Compilation ===== | ||
- | |||
- | * to generate a .s: gcc -S -c foo.c | ||
- | * to output combined C and assembly: gcc -c -g -Wa,-a,-ad foo.c > foo.lst | ||
- | * to assemble a .s: as -o foo.o foo.s. Use -gstabs for debug and -a to print memory listing. | ||
- | * to assemble a .o: gcc foo.o -o foo | ||
- | |||
- | ===== Emacs ===== | ||
- | |||
- | ^ Solaris 10 ^ OpenSolaris 2008.11 ^ Ubuntu ^ | ||
- | | CSWemacs | SUNWgnu-emacs and SUNWgnu-emacs-x | =) | | ||
- | |||
- | The configuration file is ~/.emacs | ||
- | To reload .emacs: M-x load-file ~/.emacs | ||
- | |||
- | <code> | ||
- | ;; turn on font-lock mode | ||
- | (global-font-lock-mode t) | ||
- | |||
- | ;; enable visual feedback on selections | ||
- | (setq-default transient-mark-mode t) | ||
- | |||
- | ;; always end a file with a newline | ||
- | (setq require-final-newline t) | ||
- | |||
- | ;; stop at the end of the file, not just add lines | ||
- | (setq next-line-add-newlines nil) | ||
- | |||
- | ;;to display time | ||
- | (display-time) | ||
- | |||
- | ;;to set the cursor color | ||
- | (set-cursor-color "red") | ||
- | |||
- | ;;to set the font | ||
- | (set-default-font "7x14") | ||
- | |||
- | ;; foreground | ||
- | (set-foreground-color "white") | ||
- | |||
- | ;;to set background color to black | ||
- | (set-background-color "black") | ||
- | |||
- | ;;to manage the geometric size of initial window. | ||
- | (setq initial-frame-alist '((width . 87) (height . 42))) | ||
- | </code> | ||
- | |||
- | ===== Tar ===== | ||
- | |||
- | ==== Untar a single file in a big tar file ==== | ||
- | |||
- | <code> | ||
- | tar -xvf <thetar.tar> <thefile> | ||
- | </code> | ||
- | |||
- | ==== Untar in a given directory ==== | ||
- | |||
- | <code> | ||
- | tar -xvf <thetar.tar> -C <thedir> | ||
- | </code> | ||
- | |||
- | ===== Hexadecimal ===== | ||
- | |||
- | ==== Convert hexdump's output to C hex array ==== | ||
- | |||
- | More exactly, it'll convert from "AA BB CC" to "0xAA, 0xBB, 0xCC" with each line having 8 bytes. | ||
- | |||
- | <code> | ||
- | hexdump -v -e '8/1 "0x%02x, "' -e '"\n"' <filetodump> | ||
- | </code> | ||
- | |||
- | |||
- | ===== Screenshots ===== | ||
- | |||
- | Take a screenshot | ||
- | <code> | ||
- | $ xwd -root -out scrdump | ||
- | </code> | ||
- | |||
- | View a screenshot | ||
- | <code> | ||
- | $ xwud -in scrdump | ||
- | </code> |