Linux

A-Z index of the linux Bash

alias Create an alias awk Find and Replace text within file(s) break Exit from a loop builtin Run a shell builtin cal Display a calendar case Conditionally perform a command cat Display the contents of a file cd Change Directory chgrp Change group ownership chmod Change access permissions chown Change file owner and group chroot […]

Read More
Scripting

List processes in a hierarchy

ps -e -o pid,args –forest List processes by % cpu usage ps -e -o pcpu,cpu,nice,state,cputime,args –sort pcpu | sed ‘/^ 0.0 /d’ List processes by mem usage ps -e -orss=,args= | sort -b -k1,1n | pr -TW$COLUMNS List info for particular process IDs ps -p 1,2

Read More
Scripting

Text manipulation using sed

Replace string1 with string2 sed ‘s/string1/string2/g’ Modify anystring1 to anystring2 sed ‘s/\(.*\)1/\12/g’ Remove comments and blank lines sed ‘/ *#/d; /^ *$/d’ Concatenate lines with trailing \ sed ‘:a; /\\$/N; s/\\\n//; ta’ Remove trailing spaces from lines sed ‘s/[ \t]*$//’ Escape shell metacharacters active within double quotes sed ‘s/\([\\`\\”$\\\\]\)/\\\1/g’ Print 1000th line sed -n ‘1000p;1000q’ […]

Read More