0. Internet 1. Text 2. Graphics 3. System 4. File 5. Misc 6. Palm 7. OS X |
Linux: wiping free disk space # Besides removing cruft, BleachBit can wipe free disk space (similar to SDelete or cipher /W:C under Windows). In addition to source code, a number of Linux and Windows binaries are available for download. (via Super User) /nix | Feb 26, 2012 Verify disk wipe #After zero-filling a disk, verify with hexdump or md5sum and All-Zero Hash Calculator. On a 2.5" 500GB SATA drive, both hexdump and md5sum took 144m16s to run. hexdump: $ hexdump /dev/sda 0000000 0000 0000 0000 0000 0000 0000 0000 0000 * 7470c060007470c06000 hex = 500107862016 decimal, which is the number of bytes on disk. md5sum and All-Zero Hash Calculator: $ md5sum /dev/sda 91564846bfd6055945b31bbd831378a7You'll need the number of bytes or sectors (the latter may be listed on the drive sticker as LBA) to verify the hash: $ fdisk -l /dev/sda Disk /dev/sda: 500.1 GB, 500107862016 bytes
$ testdisk /dev/sda
Proceed > None > Advanced > Size in sectors
976773168
/nix | Jan 29, 2012 Using wget on Amazon to download search results #Neither Google nor Amazon index used book descriptions from sellers, making it difficult to find unique or mislisted volumes. In order to download these comments for searching with ack, wget was tried: $ wget "http://www.amazon.com/gp/offer-listing/0131103628/?condition=used" ... HTTP request sent, awaiting response... 204 NoContent ...Hrm. How about omitting the User-Agent header? $ wget --user-agent="" "http://www.amazon.com/gp/offer-listing/0131103628/?condition=used" ... HTTP request sent, awaiting response... 200 OK ...Bingo. If there is more than one page of listings (i.e., more than 15 used books available), all pages can be downloaded via something like wget -i urls.txt --user-agent="", where urls.txt contains one URL per line: http://www.amazon.com/gp/offer-listing/0131103628/ref=olp_page_1?startIndex=0&condition=used http://www.amazon.com/gp/offer-listing/0131103628/ref=olp_page_2?startIndex=15&condition=used http://www.amazon.com/gp/offer-listing/0131103628/ref=olp_page_3?startIndex=30&condition=used /nix | Dec 01, 2011 HTML2Markdown and much more #Pandoc can convert from:
/nix | Nov 03, 2011 Find ALL CAPS 8.3 filenames which may contain digits #Given a directory of files like this: AD2IWFB6.txt An_Important_File.txt BB0IA29Q.txt C2MMT30I.txt CANTDELETETHISONE.txt Y9S29CC0.txt z.doc ZZQ0LII7.txtlist the ALL CAPS files which are eight characters long, with or without numbers included, and ending in ".txt" like so: $ ls -1 | ack ^[A-Z0-9]{8}\.txt$ AD2IWFB6.txt BB0IA29Q.txt C2MMT30I.txt Y9S29CC0.txt ZZQ0LII7.txt(find -regex had a problem with the regular expression, so just went with ack instead. ack -g REGEX didn't match the regex either, perhaps because it matches based on both the relative path and filename?) Delete the matching files by simply piping to xargs: $ ls -1 | ack ^[A-Z0-9]{8}\.txt$ | xargs rm
/nix | Oct 07, 2011 Execute a command every x seconds indefinitely #As cron's smallest increment is one minute, here are two methods for executing a command every five seconds: $ watch -n 5 echo "foo" $ while true; do echo "foo"; sleep 5; done /nix | Sep 29, 2011 Learn programming concepts using Bash shell #Mendel Cooper's Advanced Bash-Scripting Guide is "an in-depth exploration of the art of shell scripting... suitable for classroom use as a general introduction to programming concepts". Revision 6.4 was released just a few weeks ago in several formats. /nix | Sep 18, 2011 Sequence expressions in wget and curl #Given a range of JPGs to batch download: http://example.com/manga/manga_06p01.jpgone approach using wget would be: $ wget http://example.com/manga/manga_06p{00..99}.jpgBash 4 is required for brace expansion using a range. Unfortunately, the expression fails to expand at all when read from a file (e.g., $ wget -i urls.txt). curl, on the other hand, does not depend on Bash for sequencing: $ curl -O http://example.com/manga/manga_06_p[00-99].jpgso it will correctly parse sequences in a properly-formatted text file (e.g., urls.txt): url = "http://example.com/manga/manga_06_p[00-99].jpg"like so: $ curl --remote-name-all -K urls.txt /nix | Sep 12, 2011 Save all terminal text with script #Script makes a typescript of everything printed in the terminal (saved to a file named typescript in the current directory by default): $ script Script started, output file is typescript $ echo 'this is being recorded!' this is being recorded! $ exit exit Script done, output file is typescript $ head typescript Script started on Sun Jul 17 07:25:25 2011 bash-3.2$ echo 'this is being recorded!' this is being recorded! bash-3.2$ exit exit Script done on Sun Jul 17 07:25:51 2011 /nix | Jul 17, 2011 When you need a quick & simple calculator in Bash... #$ bc -lq 1+1 2 quitor $ echo $((1+1)) 2or $ echo $[1+1] 2 /nix | Jul 17, 2011 |
Categories
Blosxom Archive
2012: 5 4 3 2 1
2011: 12 11 10 9 8 7 6 5 4 3 2 1 2010: 12 11 10 9 8 7 6 5 4 3 2 1 2009: 12 11 10 9 8 7 6 5 4 3 2 1 2008: 12 11 10 9 8 7 6 5 4 3 2 1 2007: 12 11 10 9 8 7 6 5 4 3 2 1 2006: 12 11 10 9 8 7 6 5 4 3 2 1 2005: 12 11 10 Blogger Archive
Ezine Archive
|