Get all the lines which are not common to the two files.
diff file1 file2 | sed '/^[0-9][0-9]*/d; s/^. //; /^---$/d' > file3
Rename multiple files:
(this removes the extension of all .conf files in current dir)
mmv '*.conf' '#1'Search and Replace in Multiple Files in perl(easy as PIE)
perl -p -i -e 's/<oldword>/<newword>/g' *Remove comments and blank lines from file
egrep -v '^$|^\s*#' configfileFind out which process is using up your memory using ps, awk, sort
ps aux | awk '{if ($5 != 0 ) print $2,$5,$6,$11}' | sort -k2n
ps eo user,pid,pcpu,cmd,args sort pcpu | head n20Find out Top 10 Largest File or Directory Using du, sort and head
du -sk /var/log/* | sort -r -n | head -10Find out Top 10 Most Used Commands.
cat ~/.bash_history | tr "\|\;" "\n" | sed -e "s/^ //g" | cut -d " " -f 1 | sort | uniq -c | sort -n | tail -n 15Search mail logs for log in attempts
for i in `ls /var/spool/mail`; do echo $i; cat /var/log/maillog* | grep -i LOGIN| grep $i | wc -l; done
for i in `ls /var/spool/mail`; do echo $i; cat /var/log/maillog* | grep -i LOGIN| grep "authid="$i | wc -l; doneCheck Top Connections
PORT=110;netstat antp | awk '$4 ~ /:'$PORT'$/ {c++;print $5|"cut f1 d:|sort |uniq c| sort n"} END {print c}
No comments:
Post a Comment