This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This Function will handal escaped character / also using sed | |
| CommentAppend() { | |
| # Comment line and append line below commented line | |
| local comment="$( echo "$1" | sed 's/\(\/\)/\\\//g' )" # search this line and comment it | |
| local append="$( echo "$2" | sed 's/\(\/\)/\\\//g' )" # Append this line below commented line | |
| local InputFile="$3" | |
| sed -i "s/^${comment}/#${comment}/g" $InputFile | |
| # if string does not exists in input file then add |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function AppendIfnotExists() { | |
| while read s | |
| do | |
| inputFile="$2" | |
| # if starting content matched then comment them | |
| local startStr=$( echo "${s}" | cut -d" " -f1 ) | |
| grep -q "^#${s}" $inputFile || sed -i "s/^$startStr/#$startStr/g" $inputFile | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function CheckSpace() { | |
| local Partition=$1 | |
| awk -v p=$Partition 'BEGIN{ | |
| threshold=80 | |
| cmd = "LC_ALL=C df -Ph "p | |
| while( cmd | getline ) { | |
| used=$5 # Usage in % of 5th colume | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function checkprocess() { | |
| local process=$1 | |
| [[ $# -ne 1 ]] && { echo "Usage: $0 process"; exit 1; } | |
| if ps cax | grep -q $process; then | |
| echo "Process is running." | |
| else | |
| echo "Process is not running." | |
| fi | |
| } |
NewerOlder