Wednesday, May 22, 2013

Collection of very interesting unix commands

How to get your top 100 unix commands

history | sed "s/^[0-9 ]*//" | sed "s/ *| */\n/g" | awk '{print $1}' | sort | uniq -c | sort -rn | head -n 100 > commands.txt

How to copy a file to all subfolders of a directory using unix command

find . -type d -exec cp pathtofile {}/ \;

How to delete all .svn folders from current directory using unix command

find . -type d -name '.svn' -print -exec rm -rf {} \;

How to list all network connections (including which app they belong to)

lsof -i -nP

How to run the last command as root

sudo !!

How to execute the previous command until it is successful

until !!; do :; done

How to display summary of git commit ids and messages for a given branch

git log --pretty='format:%Cgreen%H %Cred%ai %Creset- %s'

How to list all file extensions present in the current directory

ls | perl -lne '++$x{lc $1} if /[.](.+)$/ }{ print for keys %x'

How to get your top 10 commands with number of times you have used it

cat .bash_history | cut -f 1 -d\ | sort | uniq -c | sort -r | head

To generate list of usernames from an svn logs (Run from top level of the svn project)

svn log | grep -E "r[0-9]+ \| .+ \|" | awk -F"|" '{print $2}' | sort | uniq > ~/authors.txt

How to get process details from its pid

ps -p $pid

How to open firefox profile manager

/Applications/ -p

Mr. Robg
My previous post

No comments:

Post a Comment