Skip to content

Instantly share code, notes, and snippets.

@evandrix
Created July 15, 2011 12:16
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save evandrix/1084584 to your computer and use it in GitHub Desktop.
Save evandrix/1084584 to your computer and use it in GitHub Desktop.
Commandlinefu.com
# http://www.commandlinefu.com/commands/favourites/plaintext
# commandlinefu.com by David Winterbottom
# Repoint an existing symlink to a new location
ln -nsf <TARGET> <LINK>
# RDP through SSH tunnel
ssh -f -L3389:<RDP_HOST>:3389 <SSH_PROXY> "sleep 10" && rdesktop -T'<WINDOW_TITLE>' -uAdministrator -g800x600 -a8 -rsound:off -rclipboard:PRIMARYCLIPBOARD -5 localhost
# Control ssh connection
[enter]~?
# simple port check command
parallel 'nc -z -v {1} {2}' ::: 192.168.1.10 192.168.1.11 ::: 80 25 110
# List your MACs address
sort -u < /sys/class/net/*/address
# phpinfo from the command line
php -i
# bash alias for sdiff: differ
alias differ='sdiff --suppress-common-lines $1 $2'
# Get your commandlinefu points (upvotes - downvotes)
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
# print all except first collumn
cut -f 2- -d " "
# Make a statistic about the lines of code
find . -type f -name "*.c" -exec cat {} \; | wc -l
# Throttling Bandwidth On A Mac
sudo ipfw pipe 1 config bw 50KByte/s;sudo ipfw add 1 pipe 1 src-port 80
# Get lines count of a list of files
find . -name "*.sql" -print0 | wc -l --files0-from=-
# Save an HTML page, and covert it to a .pdf file
wget $URL | htmldoc --webpage -f "$URL".pdf - ; xpdf "$URL".pdf &
# find files containing text
grep -lir "some text" *
# Validate and pretty-print JSON expressions.
echo '{"json":"obj"}' | python -m simplejson.tool
# Move all files with common extension to current directory
mv `find .zip ./` .
# Download an entire website
wget --random-wait -r -p -e robots=off -U mozilla http://www.example.com
# Extract tarball from internet without local saving
wget -qO - "http://www.tarball.com/tarball.gz" | tar zxvf -
# Update twitter via curl
curl -u user:pass -d status="Tweeting from the shell" http://twitter.com/statuses/update.xml
# http://www.commandlinefu.com/commands/by/evandrix/plaintext
# commandlinefu.com by David Winterbottom
# Lookaround in grep
echo "John's" | grep -Po '\b\w+(?<!s)\b'
# Look for jQuery version script include in files *asp*$, *htm*$ ie. not *.aspx.cs
find . \( -name "*.as[pc]x" -o -name "*.htm*" \) -exec grep -Hi "jquery-1" {} +
# Regex or
egrep '(expr1|expr2)' file
# HTTP Caching (gateway/reverse proxy cache for webapps)
response.headers['Cache-Control'] = 'public, max-age=60';
# Find common lines between two files
comm -12 FILE1.sorted FILE2.sorted > common
# print info about compiled Scala class
scalac quicksort.scala && javap QuickSort
# grep: find in files
egrep -in "this|that" *.dat
# Install mysql-2.8.1 rubygem on Mac OS X 10.6 (Snow Leopard)
sudo env ARCHFLAGS="-arch x86_64" gem install mysql
# Recursively remove all .svn directories
rm -rf `find . -type d -name .svn`
# Enumerate rubygems environment
gem environment
# Clone all remote branches of a specific GitHub repository
git branch -a | grep "remotes/origin" | grep -v master | awk -F / '{print $3}' | xargs -I % git clone -b % git://github.com/jamesotron/DevWorld-2010-Cocoa-Workshop %
# Check if SSL session caching is enabled on Google
gnutls-cli -V -r www.google.com |grep 'Session ID'
# Get pid of running Apache Tomcat process
ps -eo pid,args | grep -v grep | grep catalina | awk '{print $1}'
# ignore .DS_Store forever in GIT
echo .DS_Store >> ~/.gitignore
# Find Out My Linux Distribution Name and Version
cat /etc/*-release
# Delete specific remote 'origin' branch 'gh-pages'
git push origin :gh-pages
# Move files matching a certain pattern to another folder
find . | grep ".*\[[Church|CPYAF].*" | while read f; do mv "$f" ../emails;done
# Python: Quickly locate site-packages
python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"
# Extract specific lines from a text file using Stream Editor (sed)
sed -n -e 1186,1210p A-small-practice.in
# delete a particular line by line number in file
sed -i 3d ~/.ssh/known_hosts
# Delete all empty/blank lines from text file & output to file
sed '/^$/d' /tmp/data.txt > /tmp/output.txt
# 3 Simple Steps to X11 Forward on Mac OS X
ssh -X johndoe@123.456.789
# Recursively remove all '.java.orig' files (scalable)
find . -type f -iname '*.java.orig' -delete
# find the path of the java called from the command line
ls -l $(type -path -all java)
# Remove two dashes ('--') before signature in Evolution Mail (>2.30.x)
gconf-editor /apps/evolution/mail/composer/no_signature_delim false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment