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

• 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
• I've corrected the function. My octal conversion formula was completely wrong. Thanks to pgas at http://mywiki.wooledge.org/BashFAQ/071 for setting me straight. The new function is from pgas and is very fast. Show Sample Output

5
chr () { printf \\\$((\$1/64*100+\$1%64/8*10+\$1%8)); }
· 2009-10-15 07:01:54
• 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

• 2
chr() { printf \\\$(printf %o \$1); }
· 2009-10-16 19:10:44

1
awk {'print rshift(and(\$1, 0xFF000000), 24) "." rshift(and(\$1, 0x00FF0000), 16) "." rshift(and(\$1, 0x0000FF00), 8) "." and(\$1, 0x000000FF)'}
· 2018-08-16 11:46:26
• Doesn't fail for percent sign now.

0
chr () { echo -en "\0\$(printf %x \$1)"}
· 2009-10-16 21:54:58

### 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

Replace Caps-lock with Control-key

List bash functions defined in .bash_profile or .bashrc
If you issue the "set" command, you'll see a list of variables and functions. This command displays just those functions' names.

Search some text from all files inside a directory

Sorted list of established destination connections
no need grep. its redundant when awk is present.

Find out my Linux distribution name and version

Go up multiple levels of directories quickly and easily.
This is a kind of wrapper around the shell builtin cd that allows a person to quickly go up several directories. Instead of typing: cd ../.. A user can type: cd ... Instead of: cd ../../.. Type: cd .... Add another period and it goes up four levels. Adding more periods will take you up more levels.

Which processes are listening on a specific port (e.g. port 80)
swap out "80" for your port of interest. Can use port number or named ports e.g. "http"

Send command to all terminals in a screen session

Get length of current playlist in xmms2