All commands (12,987)


  • 0
    find . -iname ".svn" | xargs rm -r $1
    rwunsch · 2012-05-07 08:18:12 0
  • Decrypt with: gpg -o- foo.tgz.gpg | tar zxvf -


    0
    tar zcf - foo | gpg -c --cipher-algo aes256 -o foo.tgz.gpg
    skkzsh · 2013-03-13 09:44:39 0
  • This one has a better performance, as it is a one pass count with awk. For this script it might not matter, but for others it is a good optiomization.


    0
    svn ls -R | egrep -v -e "\/$" | xargs svn blame | awk '{count[$2]++}END{for(j in count) print count[j] "\t" j}' | sort -rn
    kurzum · 2013-05-03 01:45:12 0

  • 0
    find /logs -ls -xdev | sort -nrk 7 | head -10
    vidya99343 · 2013-07-22 08:34:28 0
  • "find ./ ..." could be replaced with "find $PWD ..." to display absolute path instead of relative path. Show Sample Output


    0
    find ./ -type f -size +500k -exec ls -1Ash {} \; | sort -hr | cat -n
    rgregor · 2013-10-01 10:32:28 0
  • Pass the files path to finfo(), can be unix path, dos path, relative or absolute. The file is converted into an absolute nix path, then checked to see if it is in-fact a regular/existing file. Then converted into an absolute windows path and sent to "wmic". Then magic, you have windows file details right in the terminal. Uses: cygwin, cygpath, sed, and awk. Needs Windows WMI "wmic.exe" to be operational. The output is corrected for easy... finfo notepad.exe finfo "C:\windows\system32\notepad.exe" finfo /cygdrive/c/Windows/System32/notepad.exe finfo "/cygdrive/c/Program Files/notepad.exe" finfo ../notepad.exe Show Sample Output


    0
    finfo() { [[ -f "$(cygpath "$@")" ]] || { echo "bad-file";return 1;}; echo "$(wmic datafile where name=\""$(echo "$(cygpath -wa "$@")"|sed 's/\\/\\\\/g')"\" get /value)"|sed 's/\r//g;s/^M$//;/^$/d'|awk -F"=" '{print $1"=""\033[1m"$2"\033[0m"}';}
    lowjax · 2013-12-30 07:47:41 0
  • Use this command to execute the contents of http://www.example.com/automation/remotescript.sh in the local environment. The parameters are optional. Alterrnatives to wget: CURL: curl -s http://www.example.com/automation/remotescript.sh | bash /dev/stdin param1 param2 W3M: w3m -dump http://www.example.com/automation/remotescript.sh | bash /dev/stdin [param1] [param2] LYNX: lynx -source http://www.example.com/automation/remotescript.sh | bash /dev/stdin [param1] [param2]


    0
    wget -q -O - http://www.example.com/automation/remotescript.sh | bash /dev/stdin parameter1 parameter2
    paulera · 2015-02-16 16:55:09 5
  • This might one day deliver the melody to the next super hit on the radio if played long enough


    0
    python -c "import os; print [i * bytearray(os.urandom(10)) for i in bytearray(os.urandom(10000))]" | padsp tee /dev/audio > /dev/null
    BigZ · 2016-08-03 20:15:43 0

  • 0
    ifconfig eth0 | sed -n 's/.*inet addr:\([0-9\.]*\).*/\1/p'
    cycne · 2017-02-18 15:53:37 0
  • netstat doesn't always function similarly across the board. Also the use of three commands in the original (netstat followed by grep followed by grep) is a waste of pipes


    0
    lsof -i :80 | tee /dev/stderr | wc -l
    AdvancedThreat · 2017-11-26 16:04:59 0
  • The $[...] block in bash and zsh will let you do math. echo $[6*7] This is the same as using $((...)), which also works in ksh. Of course, this is a simple, dumb wrapper and doesn't allow floating-point. Show Sample Output


    0
    while true; do read i; echo $[$i]; done
    mulad · 2009-02-18 23:13:09 2
  • If used without arguments, returns own IP info. If used with argument, returns info about the parsed argument. Show Sample Output


    0
    geoip () { curl -s "http://www.geoiptool.com/?IP=$1" | html2text | egrep --color 'City:|IP Address:|Country:' }
    wizel · 2009-11-15 17:59:23 0
  • Displays battery power status Show Sample Output


    0
    webattery
    SkyKnight · 2010-04-13 15:15:09 0
  • It's actually really helpful if you've done a lot of replaces in say a header file, and now you want to replace the same text in the source code file.


    0
    In vim: q: && v[cursor movement]y && [paste/edit/save to /tmp/tmp.vim] && move to window to modify && :so /tmp/tmp.vim
    tmsh · 2010-05-12 03:03:40 2
  • Useful for creating MAC addresses for virtual machines on a subnet. 00:16:3e is a standard Xen OID, change as needed. Show Sample Output


    0
    echo 00:16:3e$(gethostip 10.1.2.11 | awk '{ print tolower(substr($3,3)) }' |sed 's/.\{2\}/:&/g' )
    chwilk · 2010-09-23 16:46:21 0
  • Usage: VBoxBlockBoot [Virtual_Machine] [Block_device] Eg: VBoxBlockBoot WinXP /dev/sdc In another words vm=usb; usb=sdc;sudo umount /dev/$usb* ; sudo chmod 777 /dev/$usb ; VBoxManage storageattach $vm --medium ~/raw-HD-4-VB/$usb.vmdk --type hdd --storagectl "IDE Controller" --device 0 --port 0 ; VBoxManage startvm $vm Where vm --> Name of the virtual machine to start usb --> Block device to use. (/dev/sdc) This can used after setup up a boot loader on to my USB pen drive or HDD (After creating Live USB). Here root privilege is needed but not granted to Virtual Box. Thus we can access all our VM.( If we run VBox as root we can't access our VMs). Root privilege is used to - Unmount the storage device - Chmod to full access (777) Requirements:- 1. Device information file (rawvmdk file) created by the following command. Need to run only once. Not bad to run many. VBoxCreateRawDisk() { VBoxManage internalcommands createrawvmdk -filename ~/.rawHD4VB_`basename "$1"`.vmdk -rawdisk "$1"; } 2. Root privilege to umount & chmod 3. Real storage medium (ie /dev/*) (Non-virtual such as USB HD, pen drive, a partition) 4. A virtual m/c already available (here "usb") vm=usb; usb=sdc;sudo umount /dev/$usb* ; sudo chmod 777 /dev/$usb ; VBoxManage storageattach $vm --medium ~/raw-HD-4-VB/$usb.vmdk --type hdd --storagectl "IDE Controller" --device 0 --port 0 ; VBoxManage startvm $vm VBoxBlockBoot() { sudo umount "$2"*; sudo chmod 777 "$2"; VBoxManage storageattach "$1" --medium ~/.rawHD4VB_`basename "$2"`.vmdk --type hdd --storagectl "IDE Controller" --device 0 --port 0 ; VBoxManage startvm "$1"; } Show Sample Output


    0
    VBoxBlockBoot() { sudo umount "$2"*; sudo chmod 777 "$2"; VBoxManage storageattach "$1" --medium ~/.rawHD4VB_`basename "$2"`.vmdk --type hdd --storagectl "IDE Controller" --device 0 --port 0 ; VBoxManage startvm "$1";}
    totti · 2011-07-29 13:04:19 0

  • 0
    tshark -r data.pcap -R "ip.addr==192.168.1.2 && ip.addr==64.12.24.50 && aim" -d tcp.port==443,aim -T fields -e "aim.buddyname" |sort |uniq -c
    anhpht · 2011-10-11 15:38:26 0
  • bash-3.2$ find /logs -ls -xdev | sort -nrk 7 | head -10 1761905 205380 -rwxrwxr-x 1 wsadmin logadmin 210095353 Jul 22 01:33 /logs/intlpymt/Trace.log 652689 187360 -rwxrwxr-x 1 wsadmin logadmin 191663182 Jul 21 23:00 /logs/websphere/wsfpp1lppwa1213omsecureServer/SystemOut_13.07.21_23.00.12.log 2380449 186536 -rwxrwxr-x 1 wsadmin logadmin 190819939 Jul 16 14:03 /logs/omset/traceIntl.log.201307161403.lppwa1213.gz 2119524 183888 -rwxrwxr-x 1 wsadmin logadmin 188110111 Jul 22 01:33 /logs/intlpymt/intlpymtria/Trace.log 652816 160332 -rwxrwxr-x 1 wsadmin logadmin 164011871 Aug 14 2012 /logs/websphere/wsfpp1lppwa1213omsecureServer/SystemOut.log_08142012.gzip 653312 128916 -rwxrwxr-x 1 wsadmin logadmin 131873943 Jul 18 10:49 /logs/websphere/heapdump.20130718.104150.27592.0006.phd.201307181406.lppwa1213.gz 653320 128916 -rwxrwxr-x 1 wsadmin logadmin 131873735 Jul 18 10:40 /logs/websphere/heapdump.20130718.104012.27592.0002.phd.201307181406.lppwa1213.gz 653309 128912 -rwxrwxr-x 1 wsadmin logadmin 131867602 Jul 18 10:46 /logs/websphere/heapdump.20130718.104008.27592.0001.phd.201307181405.lppwa1213.gz 653323 128872 -rwxrwxr-x 1 wsadmin logadmin 131828157 Jul 18 10:41 /logs/websphere/heapdump.20130718.104109.27592.0004.phd.201307181407.lppwa1213.gz 652783 120288 -rwxrwxr-x 1 wsadmin logadmin 123047750 Aug 13 2012 /logs/websphere/wsfpp1lppwa1213omsecureServer/SystemOut.log_0813.2012.gzip bash-3.2$ Show Sample Output


    0
    find /logs -ls -xdev | sort -nrk 7 | head -10
    vidya99343 · 2013-07-22 08:36:03 0
  • Display a list of local shell scripts soft-linked to /usr/local/bin Put local shell scripts to local ~/bin/ directory and soft-link them to /usr/local/bin/ which is in the $PATH variable to run them from anywhere. Show Sample Output


    0
    for AAA in $(find /usr/local/bin -type l); do ls -gG "${AAA}"; done
    rgregor · 2013-10-01 10:49:12 0
  • When bootstrapping or repairing a node this is a simple way to keep tabs on what a node is actively doing. Show Sample Output


    0
    watch -d 'echo -e "Remaining: `(nodetool netstats | grep " 0%" | wc -l)` \nCurrent: `(nodetool netstats | grep "%" | grep -v " 0%")`"'
    mrwulf · 2014-01-01 16:59:01 0

  • 0
    find . |xargs grep '<html\|<body\|<table' |sed '/~/d;s/:.*//' |sed 's/.*/mv & &.html/' |uniq >run.sh; sh run.sh
    mobluse · 2014-07-09 19:20:40 0
  • to set the current time manually Show Sample Output


    0
    timedatectl set-time 'YYYY-MM-DD HH:MM:SS' && hwclock --systohc
    aysadk · 2017-02-19 01:15:38 0
  • There are two different ways that I would have done this. With the command posted or if you prefer xargs: pip freeze --local | awk -F "=" '{$1}' | xargs pip install -U # But this is a moot point considering the above replaces xargs


    0
    pip freeze --local | awk -F "=" '{print "pip install -U "$1}' | sh
    AdvancedThreat · 2017-11-26 16:11:18 0
  • This will drop you into vim to edit all files that contain your grep string.


    0
    grep -ir 'foo' * | awk '{print $1}' | sed -e 's/://' | xargs vim
    elubow · 2009-09-03 15:12:27 0
  • this is funny ;) alias sl="ls" ... is the useful solution, but that's boring ;P and You won't learn to think before You type !


    0
    apt-get install sl; sl
    alvinx · 2009-09-21 13:55:24 0
  • ‹ First  < 402 403 404 405 406 >  Last ›

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.

Share Your 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.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

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: