A few nice Unix commands.

Shell and simple command line applications

Erase all in a directory except one file (or so)

for i in `ls -1 | grep -v <filetokeep>`; do rm -rf $i; done

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.

hexdump -v -e '8/1 "0x%02x, "' -e '"\n"' <filetodump>

ls

Colour directories, binaries (etc) using ls –color=auto.

Screenshots

Take a screenshot of the entire desktop

$ xwd -root -out scrdump

Take a screenshot of a given window:

$ xwd -out scrdump

and point to the window to grab with the mouse.

View a screenshot

$ xwud -in scrdump 

Tar

Untar a single file in a big tar file

tar -xvf <thetar.tar> <thefile>

Untar in a given directory

tar -xvf <thetar.tar> -C <thedir>

Development

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
 
Back to top
unix/misc.txt · Last modified: 2009/02/28 15:21 (external edit)
 
 
Get OpenSolaris Recent changes RSS feed Valid XHTML 1.0 Driven by DokuWiki chimeric.de = chi`s home
(c) A. Apvrille - 2009