Commands by leftyfb (2)

  • Requires: curl xsel access to the internet( This is an alias utilizing the service to make sharing files easier from the command line. I have modified the alias provided by to use xsel to copy the resulting URL to the clipboard. The full modified alias is as follows since commandlinefu only allows 255 characters: transfer() { if [ $# -eq 0 ]; then echo "No arguments specified. Usage:\necho transfer /tmp/\ncat /tmp/ | transfer"; return 1; fi if tty -s; then basefile=$(basename "$1" | sed -e 's/[^a-zA-Z0-9._-]/-/g'); curl --progress-bar --upload-file "$1" "$basefile" |xsel --clipboard; else curl --progress-bar --upload-file "-" "$1" |xsel --clipboard ; fi; xsel --clipboard; } Show Sample Output

    transfer() { basefile=$(basename "$1" | sed -e 's/[^a-zA-Z0-9._-]/-/g');curl --progress-bar --upload-file "$1" "$basefile"|xsel --clipboard;xsel --clipboard ; }
    leftyfb · 2016-03-20 19:38:48 0
  • I save this to bin/iptrace and run "iptrace ipaddress" to get the Country, City and State of an ip address using the service. I add the following to my script to get a tinyurl of the map as well: URL=`lynx -dump$1|grep details|awk '{print $2}'` lynx -dump$URL|grep tinyurl|grep "19. http"|awk '{print $2}'

    lynx -dump$1|grep address|egrep 'city|state|country'|awk '{print $3,$4,$5,$6,$7,$8}'|sed 's\ip address flag \\'|sed 's\My\\'
    leftyfb · 2009-02-25 17:16:56 5

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

pushd rotates the stack so that the second directory comes at the top.
'pushd +1' is equivalent to 'pushd'. Can be 'pushd +3' or more generaly 'pushd +N'. Can also be 'pushd -N'. More description in 'man bash'.

Debug how files are being accessed by a process
Instead of looking through `lsof` results, use inotifywait!

Do one ping to a URL, I use this in a MRTG gauge graph to monitor connectivity

VIM: Go back to the last place you were in a document
You're perhaps editing a line, or reading a certain line of code, you use page up and down or move through the file and now you wish to return to the last position the cursor was at. '' will get you there.

xargs for builtin bash commands

Matrix Style
Unlike other alternatives, this command only relies on bash builtins and should also work on windows platforms with the bash executable. Sparseness corresponds to the number 128 and can be adjusted. To print all possible digits instead of only 0 and 1 replace RANDOM%2 by RANDOM%10 or RANDOM%16 to add letters [A-F].

Destroy all disks on system simultaneously
This command will use the fdisk utility to find all block devices on your system, and overwrite them with data from the /dev/urandom non-blocking random number generator. CAUTION: This will irrevocably erase EVERY SINGLE physical block storage device visible to the fdisk utility, including plugged USB devices, RAID sets, LVM, etc.

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)

Check if network cable is plugged in and working correctly
with 'mii-tool -w eth0' you can watch the interface for changes of the link status

List the URLs of tabs of the frontmost Chrome window in OS X
This also works with Safari if you just change the application name. Replace $ window 1 with $ windows to list the URLs of tabs in all windows instead of only the frontmost window. This also includes titles: $ osascript -e{'set o to""','tell app"google chrome"','repeat with t in tabs of window 1','set o to o&url of t&"\n"&" "&title of t&"\n"',end,end}|sed \$d .

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: