### Commands tagged binary (13) the last day the last week the last month all time sorted by date votes

• Create a binary clock. Show Sample Output

36
watch -n 1 'echo "obase=2;`date +%s`" | bc'
· 2009-11-04 02:04:00
• If you should happen to find yourself needing some binary numbers, this is a quickie way of doing it. If you need more digits, just add more "{0..1}" sequences for each digit you need. You can assign them to an array, too, and access them by their decimal equivalent for a quickie binary to decimal conversion (for larger values it's probably better to use another method). Note: this works in bash, ksh and zsh. For zsh, though, you'll need to issue a setopt KSH_ARRAYS to make the array zero-based. `binary=({0..1}{0..1}{0..1}{0..1})` `echo \${binary[9]}` Show Sample Output

18
echo {0..1}{0..1}{0..1}{0..1}
· 2009-06-23 17:30:20
• Upload/download newer version of any file with less size and high speed. To remake the new file use `bspatch <oldfile> <newfile> <patchfile>`

7
bsdiff <oldfile> <newfile> <patchfile>
· 2011-09-13 18:22:40
• Binary clock with separate H:M:S. Show Sample Output

6
watch -n 1 'date "+obase=2; print %H,\":\",%M,\":\",%S" |bc'
· 2011-02-02 00:01:48
• Convert some decimal numbers to binary numbers. You could also build a general base-converter: `function convBase { echo "ibase=\$1; obase=\$2; \$3" | bc; }` then you could write `function decToBun { convBase 10 2 \$1; }` Show Sample Output

4
function decToBin { echo "ibase=10; obase=2; \$1" | bc; }
· 2009-11-24 22:57:58
• Replace (as opposed to insert) hex opcodes, data, breakpoints, etc. without opening a hex editor. HEXBYTES contains the hex you want to inject in ascii form (e.g. 31c0) OFFSET is the hex offset (e.g. 49cf) into the binary FILE

2
echo -n \$HEXBYTES | xxd -r -p | dd of=\$FILE seek=\$((0x\$OFFSET)) bs=1 conv=notrunc
· 2009-03-11 17:02:24
• Print out your age in days in binary. Today's my binary birthday, I'm 2^14 days old :-) . This command does bash arithmatic \$(( )) on two dates: Today: \$(date +%s) Date of birth: \$(date +%s -d YYYY-MM-DD) The dates are expressed as the number of seconds since the Unix epoch (Jan 1970), so we devide the difference by 86400 (seconds per day). . Finally we pipe "obase=2; DAYS-OLD" into bc to convert to binary. (obase == output base) Show Sample Output

2
echo "obase=2;\$(((\$(date +%s)-\$(date +%s -d YYYY-MM-DD))/86400))" | bc
· 2015-10-19 15:40:32
• 'od -c' works like 'hexdump -c' but is available on other operating systems that don't ship with hexdump (e.g. solaris).

1
od -c <file>
· 2011-09-09 18:55:28
• This will show you any links that a command follows (unlike 'file -L'), as well as the ultimate binary or script. Put the name of the command at the very end; this will be passed to perl as the first argument. For obvious reasons, this doesn't work with aliases or functions. Show Sample Output

0
perl -le 'chomp(\$w=`which \$ARGV[0]`);\$_=`file \$w`;while(/link\b/){chomp(\$_=(split/`/,\$_)[1]);chop\$_;\$w.=" -> \$_";\$_=`file \$_`;}print "\n\$w";' COMMAND_NAME
· 2010-07-30 19:26:35
• - View non printable characters. - view binary files Show Sample Output

0
hexdump -c <file>
· 2011-09-09 09:54:16
• xxd can convert a hexdump back to binary using the -r option which can be useful for patching or editing binary files.

0
xxd <file>
· 2011-09-09 21:52:30
• Use this function with bash version 4+ to convert arbitrary hexadecimal sequences to binary. If you don't have bash 4+ then modify the lowercase to uppercase demangling statement `s=\${@^^}` to set s equal to the uppercase hex input or the bc command throws an input parser error. Show Sample Output

0
hex2bin () { s=\${@^^}; for i in \$(seq 0 1 \$((\${#s}-1))); do printf "%04s" `printf "ibase=16; obase=2; \${s:\$i:1};\n" | bc` ; done; printf "\n"; }
· 2018-10-02 22:02:33
• Use this like the cat command with the additional feature to strip out unprintable characters from the input, newlines will stay. Show Sample Output

-1
strings -1 <file>
· 2012-11-23 11:33:25

### What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

### Check These Out

list block devices
Shows all block devices in a tree with descruptions of what they are.

Create a bunch of dummy text files

Dumping Audio stream from flv (using mplayer)

Convert CSV to JSON

Find usb device
I often use it to find recently added ou removed device, or using find in /dev, or anything similar. Just run the command, plug the device, and wait to see him and only him

[re]verify a disc with very friendly output
[re]verify those burned CD's early and often - better safe than sorry - at a bare minimum you need the good old `dd` and `md5sum` commands, but why not throw in a super "user-friendly" progress gauge with the `pv` command - adjust the ``-s'' "size" argument to your needs - 700 MB in this case, and capture that checksum in a "test.md5" file with `tee` - just in-case for near-future reference. *uber-bonus* ability - positively identify those unlabeled mystery discs - for extra credit, what disc was used for this sample output?

show each new entry in system messages as a popup
It willl popup a message for each new entry in /var/log/messages found on the notify-send howto page on ubuntuforums.org. Posted here only because it is one of the favourites of mine.

delete PBS jobs based on strings from qstat output

Create a mirror of a local folder, on a remote server
Create a exact mirror of the local folder "/root/files", on remote server 'remote_server' using SSH command (listening on port 22) (all files & folders on destination server/folder will be deleted)

Remove git branches that do not have a remote tracking branch anymore