
Terminal - Commands tagged commandlinefu - 13 results
curl "http://www.commandlinefu.com/commands/matching/$(echo "$@" | sed 's/ /-/g')/$(echo -n $@ | base64)/plaintext"
This is sample output - yours may be different.
for me the above command didn't work for more than one argument but this one does
goclf() { type "$1" | sed '1d' | tr -d "\n" | tr -s '[:space:]'; echo }
This is sample output - yours may be different.
root@ballgag ~ % tail -n4 .bashrc # newlines to spaces break code
goclf()
{
type "$1" | sed '1d' | tr -d "\n" | tr -s '[:space:]'; echo
}
root@ballgag ~ % type goclf # command will work, but unneeded space
goclf is a function
goclf ()
{
type "$1" | sed '1d' | tr -d "\n" | tr -s '[:space:]';
echo
}
root@ballgag ~ % goclf goclf # elegant
goclf () { type "$1" | sed '1d' | tr -d "\n" | tr -s '[:space:]'; echo}
This command will format your alias or function to a single line, trimming duplicate white space and newlines and inserting delimiter semi-colons, so it continues to work on a single line.
curl -s http://www.commandlinefu.com/commands/by/$1/xml | awk -F'</?div[^>]*>' '/class=\"command\"/{gsub(/"/,"\"",$2); gsub(/</,"<",$2); gsub(/>/,">",$2); gsub(/&/,"\\&",$2); cmd=$2} /class=\"num-votes\"/{printf("%3i %s\n", $2, cmd)}'
This is sample output - yours may be different.
0 sed 's/.*/ /'
0 date -s "`curl -sI www.example.com | sed -n 's/^Date: //p'`"
0 jot -s '' -b '-' 50
7 command | sed -n '1,/regex/p'
4 curl -s search.twitter.com | awk -F'</?[^>]+>' '/\/intra\/trend\//{print $2}'
5 dig +short -x {ip}
This version prints current votes and commands for a user. Pass the user as an argument. While this technically "fits" as a one liner, it really is easier to look at as a shell script with extra whitespace. :)
username=bartonski;curl -s http://www.commandlinefu.com/commands/by/$username/json|perl -e 'BEGIN{$s=0;$n=0};END{print "Score: $s\nEntries: $n\nMean: ";printf "%3.2f\n",$s/$n}' -0173 -nae 'foreach $f (@F){if($f =~ /"votes":"(-*\d+)"/){$s += $1; $n++;}}'
This is sample output - yours may be different.
Like command #4845, prints score, number of entries, and average score.
username=matthewbauer; curl -s http://www.commandlinefu.com/commands/by/$username/json | tr '{' '\n' | grep -Eo ',"votes":"[0-9\-]+","' | grep -Eo '[0-9\-]+' | tr '\n' '+' | sed 's/+$/\n/' | bc
This is sample output - yours may be different.
This will calculate the your commandlinefu votes (upvotes - downvotes).
Hopefully this will boost my commandlinefu points.
clfavs(){ URL="http://www.commandlinefu.com";wget -O - --save-cookies c --post-data "username=$1&password=$2&submit=Let+me+in" $URL/users/signin;for i in `seq 0 25 $3`;do wget -O - --load-cookies c $URL/commands/favourites/plaintext/$i >>$4;done;rm -f c;}
This is sample output - yours may be different.
Usage: clfavs username password num_favourite_commands file_in_which_to_backup
while true; do curl -s http://www.commandlinefu.com/commands/view/3643/log-a-commands-votes | grep 'id="num-votes-' | sed 's;.*id="num-votes-[0-9]*">\([0-9\-]*\)</div>;\1;' >> votes; sleep 10; done
This is sample output - yours may be different.
Log a command's votes,
then run:
gnuplot -persist <(echo "plot 'votes' with lines")
This is sample output - yours may be different.
sudo /usr/sbin/ethtool eth0
Settings for eth0:
Supported ports: [ TP ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Half 1000baseT/Full
Supports auto-negotiation: Yes
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Half 1000baseT/Full
Advertised auto-negotiation: Yes
Speed: Unknown! (65535)
Duplex: Unknown! (255)
Port: Twisted Pair
PHYAD: 1
Transceiver: internal
Auto-negotiation: on
Supports Wake-on: g
Wake-on: g
Current message level: 0x000000ff (255)
Link detected: no
This is an commandline utility to get fair piece of information about the attached network card.
This is sample output - yours may be different.
Use it like this below:
vnstat -u -i interface forces a database update for interface or creates the database if it doesn't exist. This is
usually the first command used after a fresh install.
vnstat -u -i interface --nick nick gives interface the nickname nick and that information will be later included
with queries.
vnstat -u -r --disable -i interface resets the internal counters of interface and disables it from being updated
before enabled again with the --enable parameter. This feature is especially useful for interfaces like ppp0 that
aren't always active.
And one of out put will be below,
sudo /usr/bin/vnstat -l
Monitoring ppp0... (press CTRL-C to stop)
rx: 0.00 kB/s 0 p/s tx: 0.00 kB/s 0 p/s^C
ppp0 / traffic statistics
rx | tx
--------------------------------------+----------------------------------------
bytes 0 kB | 0 kB
--------------------------------------+----------------------------------------
max 0.05 kB/s | 0.03 kB/s
average 0.01 kB/s | 0.00 kB/s
min 0.00 kB/s | 0.00 kB/s
--------------------------------------+----------------------------------------
packets 1 | 1
--------------------------------------+----------------------------------------
max 0 p/s | 0 p/s
average 0 p/s | 0 p/s
min 0 p/s | 0 p/s
--------------------------------------+----------------------------------------
time 17 seconds
It has got so many wonderful switch to get the exact data you need.
A wonderful command line utility to check the internet usage. It has got so many useful switch to display the data you want.Please visit the man page to get all the information.Get it from this website http://humdi.net/vnstat
cmdfu(){ curl "http://www.commandlinefu.com/commands/matching/$@/$(echo -n $@ | openssl base64)/plaintext"; }
This is sample output - yours may be different.
# commandlinefu.com by David Winterbottom
# bash or tcsh redirect both to stdout and to a file
echo "Hello World." | tee -a hello.txt
wget -qO - http://www.commandlinefu.com/feed/tenup | xmlstarlet sel -T -t -o '<x>' -n -t -m rss/channel/item -o '<y>' -n -v description -o '</y>' -n -t -o '</x>' | xmlstarlet sel -T -t -m x/y -v code -n
This is sample output - yours may be different.
$ ps aux | grep [p]rocess-name
$ getconf LONG_BIT
$ for I in $(mysql -e 'show databases' -s --skip-column-names); do mysqldump $I | gzip > $I.sql.gz"; done
$ free && sync && echo 3 > /proc/sys/vm/drop_caches && free
$ find . -empty -type d -exec rmdir {} +
$ exiftool '-Directory<DateTimeOriginal' -d %Y/%m/%d dir
$ tmpfile=$(mktemp) && echo -e 'startup_message off\nscreen -t top htop\nsplit\nfocus\nscreen -t nethogs nethogs wlan0\nsplit\nfocus\nscreen -t iotop iotop' > $tmpfile && sudo screen -c $tmpfile
$ /sbin/kexec -l /boot/$KERNEL --append="$KERNELPARAMTERS" --initrd=/boot/$INITRD; sync; /sbin/kexec -e
$ dig +short txt <keyword>.wp.dg.cx
$ autossh -M50000 -t server.example.com 'screen -raAd mysession'
$ knock <host> 3000 4000 5000 && ssh -p <port> user@host && knock <host> 5000 4000 3000
$ cat /var/log/secure.log | awk '{print substr($0,0,12)}' | uniq -c | sort -nr | awk '{printf("\n%s ",$0) ; for (i = 0; i<$1 ; i++) {printf("*")};}'
$ for x in `jot - 0 2400 25`; do curl "http://www.commandlinefu.com/commands/browse/sort-by-votes/plaintext/$x" ; done > commandlinefu.txt
$ ssh -t remote_host screen -r
$ diff <(echo "$a") <(echo "$b")
This lengthy cryptic line will print the latest top 10 commandlinefu.com posts without their summaries. To print also their respective summaries use the following (even bigger) command line:
wget -qO - http://www.commandlinefu.com/feed/tenup | xmlstarlet sel -T -t -o '<doc>' -n -t -m rss/channel/item -o '<item>' -n -o '<title>' -v title -o '</title>' -n -o '<description>' -v description -o '</description>' -n -o '</item>' -n -t -o '</doc>' | xmlstarlet sel -T -t -m doc/item -v description/code -n -v title -n -n
It is recommended to include this line into a shell script to be easily run, as I do myself. You could also use the following URLs to browse the top 3 commands:
wget -qO - http://www.commandlinefu.com/feed/threeup | xmlstarlet ...
.. or all others:
wget -qO - http://feeds2.feedburner.com/Command-line-fu | xmlstarlet ...
PS: You need to install "xmlstarlet" to run it. It is found in Debian APT repositories (apt-get install xmlstarlet) or under the http://xmlstar.sourceforge.net/ URL.
curl http://www.commandlinefu.com/commands/by/<your username>/rss|gzip ->commandlinefu-contribs-backup-$(date +%Y-%m-%d-%H.%M.%S).rss.gz
This is sample output - yours may be different.
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 20487 0 20487 0 0 18344 0 --:--:-- 0:00:01 --:--:-- 97557
Use `zless` to read the content of your *rss.gz file:
zless commandlinefu-contribs-backup-2009-08-10-07.40.39.rss.gz
(curl -d q=grep http://www.commandlinefu.com/search/autocomplete) | egrep 'autocomplete|votes|destination' | perl -pi -e 's/a style="display:none" class="destination" href="//g;s/<[^>]*>//g;s/">$/\n\n/g;s/^ +//g;s/^\//http:\/\/commandlinefu.com\//g'
This is sample output - yours may be different.
grep --color=auto -iRnH "$search_word" $directory
Grep for word in directory (recursive)
http://commandlinefu.com/commands/view/1144/grep-for-word-in-directory-recursive
grep -i --color=auto
Grep colorized
http://commandlinefu.com/commands/view/2004/grep-colorized
There's probably a more efficient way to do this rather than the relatively long perl program, but perl is my hammer, so text processing looks like a nail.
This is of course a lot to type all at once. You can make it better by putting this somewhere:
clf () { (curl -d "q=$@" http://www.commandlinefu.com/search/autocomplete 2>/dev/null) | egrep 'autocomplete|votes|destination' | perl -pi -e 's/<a style="display:none" class="destination" href="//g;s/<[^>]*>//g;s/">$/\n\n/g;s/^ +|\([0-9]+ votes,//g;s/^\//http:\/\/commandlinefu.com\//g'; }
Then, to look up any command, you can do this:
clf diff
This is similar to http://www.colivre.coop.br/Aurium/CLFUSearch except that it's just one line, so more in the spirit of CLF, in my opinion.