Commands by ichbins (8)

  • Scope should have the Rigol Ultravision Technology otherwise it won't accept the command. ImageMagic is required. Scope sends a 1.1M BMP file and converted to PNG it's only 18-20K

    echo "display:data?" | nc "$scope_ip_address" 5555 | dd bs=1 skip=11 2>/dev/null | convert bmp:- out_file.png
    ichbins · 2015-06-27 06:43:43 0
  • This version is precise and requires one second to collect statistics. Check sample output for a more generic version and also a remote computer invocation variant. It doesn't work with the busybox version of the 'top' command but can be adjusted Show Sample Output

    top -bn2|awk -F, '/Cpu/{if (NR>4){print 100-gensub(/.([^ ]+).*/,"\\1","g",$4)}}'
    ichbins · 2014-04-18 17:48:05 0
  • this command will add the following two lines into the ~/.bash_aliases: alias exit='pwd > ~/.lastdir;exit' [ -n "$(cat .lastdir 2>/dev/null)" ] && cd "$(cat .lastdir)" or redirect it to the ~/.bashrc if you like Donno, I find it usefull. You may also define an alias for 'cd ~' like - alias cdh='cd ~'

    echo -e 'alias exit='\''pwd > ~/.lastdir;exit'\''\n[ -n "$(cat .lastdir 2>/dev/null)" ] && cd "$(cat .lastdir)"' >> ~/.bash_aliases
    ichbins · 2014-01-28 18:02:04 0
  • Starts and shows a timer. banner command is a part of the sysvbanner package. Instead of the banner an echo or figlet commands could be used. Stop the timer with Ctrl-C and elapsed time will be shown as the result. Show Sample Output

    alias timer='export ts=$(date +%s);p='\''$(date -u -d @"$(($(date +%s)-$ts))" +"%H.%M.%S")'\'';watch -n 1 -t banner $p;eval "echo $p"'
    ichbins · 2013-08-24 16:18:45 1
  • bash output is inserted into the clipboard, then mousepad is started and the clipboard content is pasted. xsel and xdotool needs to be installed. Instead of the mousepad any other editor can be used. I've successfully tested the Sublime Text Editor and it opens a new tab for each new paste. Check Sample output for a usage example. This command is originated from here - Show Sample Output

    alias 2edit='xsel -b;n=pipe$RANDOM;xdotool exec --terminator -- mousepad $n -- search --sync --onlyvisible --name $n key --window %1 ctrl+v'
    ichbins · 2013-08-11 06:18:31 0
  • pdfunite is a part of the poppler-utils. poppler-utils package is only 150KB. The alternative - pdftk package is 14MB! Install poppler-utils if you need simple pdf operation commands like unite, separate, info, text/html conversions

    pdfunite 1.pdf 2.pdf united.pdf
    ichbins · 2013-07-09 11:44:58 1
  • it also works with the chrome browser. The alternative with tail and nc doesn't

    socat -u FILE:/var/log/syslog,ignoreeof TCP4-LISTEN:12345,fork,reuseaddr
    ichbins · 2013-02-18 13:36:01 0
  • Actually this is a shorter version that fits the 255 chars limit of this resource. The full version shows status in the right top corner: alias mpdd='while sleep 1; do _r=$(awk '\''BEGIN{FS=": "}/^Artist:/{r=r""$2};/^Title:/{r=r" - "$2};/^time:/{r=$2" "r};/^state: play/{f=1}END{if(f==1){print r}}'\'' <(mpc status;mpc currentsong));_l=${#_r};[ $_l -eq 0 ] && continue;[ -z "$_p" ] && _p=$_l;echo -ne "\e[s\e[0;${_p}H\e[K\e[u";_p=$((COLUMNS - _l));echo -ne "\e[s\e[0;${_p}H\e[K\e[0;44m\e[1;33m${_r}\e[0m\e[u";done &' mpc is defined like this: function mpc() { echo "$*" | nc 6600 } Show Sample Output

    while sleep 1; do (mpc status;mpc currentsong)|awk 'BEGIN{FS=": "}/^Artist:/{r=r""$2};/^Title:/{r=r" - "$2};/^time:/{r=$2" "r};/^state: play/{f=1}END{if(f==1){print r}}'|echo -ne "\e[s\e[0;0H\e[K\e[0;44m\e[1;33m$(cat -)\e[0m\e[u";done &
    ichbins · 2012-12-24 18:03:29 0

What's this? 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.

Share Your Commands

Check These Out

make directory with current date

phpdoc shortcut
A shortcut to generate documentation with phpdoc. Defaults to HTML; optionally to PDF if third argument is given. Stores documentation in cwd under ./docs/. I forget the syntax to the output, -o, option, so this is easier.

Install pip with Proxy
Installs pip packages defining a proxy

Search google and show only urls
Get the first 10 google results form a querry, but showing only the urls from the results. Use + to search diferent terms, ex: commandlinefu+google .

Take screenshot through SSH
When connected to a box via ssh you can do a quick screenshot of that box using this command. After that you can rscp it over to your box and look at it.

Emulating netcat -e (netcat-traditional or netcat-openbsd) with the gnu-netcat
Then just nc servername 2600 and ./ kill the client with ctrl+c. You can reconnect several times. kill the server with exit

nice disk usage, sorted by size, see description for full command
full command below, would not let me put full command in text box du -sk ./* | sort -nr | awk 'BEGIN{ pref[1]="K"; pref[2]="M"; pref[3]="G";} { total = total + $1; x = $1; y = 1; while( x > 1024 ) { x = (x + 1023)/1024; y++; } printf("%g%s\t%s\n",int(x*10)/10,pref[y],$2); } END { y = 1; while( total > 1024 ) { total = (total + 1023)/1024; y++; } printf("Total: %g%s\n",int(total*10)/10,pref[y]); }'

disable caps lock
a quick one-line way to disable caps lock while running X.

Steve Reich - Piano Phase; interpreter: Bourne-Again Shell.
The Piano Phase piece, by Steve Reich is a minimalist composition which is played on two pianos played at slightly different tempos, a task that's very difficult to accomplish by human players. The auditive effects produced by the cell displacement produce beautiful patterns. See . My rendered version: Requires sox to be installed on the system. There are multiple videos on youtube showing different approaches and experiences to this interpretation. There is also a synthesized version. Even if Bash can behave as a powerful pianist, a simple threaded version leaves full room to several time glitches and even negative displacements, the same issues that human pianists experience when playing the piece. The older the computer, the better the chaos added to the result due to the CPU load. Apparently that's the reason Steve Reich composes pieces such as this. Without further ado, please give a warm welcome to the Bash minimalist player on synthesized two-threaded pianos. Please turn off your cellphones.

How to establish a remote Gnu screen session that you can re-connect to
Long before tabbed terminals existed, people have been using Gnu screen to open many shells in a single text terminal. Combined with ssh, it gives you the ability to have many open shells with a single remote connection using the above options. If you detach with "Ctrl-a d" or if the ssh session is accidentally terminated, all processes running in your remote shells remain undisturbed, ready for you to reconnect. Other useful screen commands are "Ctrl-a c" (open new shell) and "Ctrl-a a" (alternate between shells). Read this quick reference for more screen commands:

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.


Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: