linux | get system idle via script
# XX=5;top -n $XX | grep CPU | grep id | awk ‘{print $8}’ | awk ‘{s+=$1} END {print s}’ | xargs -I % echo “scale=0;%/$XX” | bc -l
# XX=5;top -n $XX | grep CPU | grep id | awk ‘{print $8}’ | awk ‘{s+=$1} END {print s}’ | xargs -I % echo “scale=0;%/$XX” | bc -l
For each character in string do # IN=”\\”;printf -v OUT ‘%%%02x’ “‘$IN”; echo $OUT or # echo “this & that” | perl -MURI::Escape -ne ‘chomp;print uri_escape($_),”\n”‘
function createPassword () { CNTSYLL=$1 CNTNUM=$2 test “x$1” == “x” && return 1 test “x$2” == “x” && return 1 PASS=”” YYY=( a e i o u ei au ai eu iu ui oi) ZZZ=( b c d f g h j k l m n p q r s t v w x y […]
Create some functions: function prepare_dialog () { # DIALOG STDOUT exec 3>&1 } function d_selectOneGender () { C_GEND_LIST=”$(getexistinggenders)” D_STRG=”” for C_GEND in $C_GEND_LIST; do D_STRG=”${D_STRG} $C_GEND Gender OFF $C_GEND” done dialog \ –backtitle “$VERSION” \ –clear \ –title “$1” \ –item-help \ –radiolist ‘Select one:’ \ $H $W $MH \ $D_STRG return $? } … […]
LDAP TIME is calculated in nanoseconds (factor 10000000) from 01/01/1601 echo $((($LDAPTIME/10000000)-11644473600)) 01/01/1601 .. 01/01/1970 in seconds: 11644473600
… here: group by first column, select the row with maximum value in second column # cat $FILE | awk ‘{print $2″ “$1}’ | sort -k 2 -k 1rn | uniq -f 1 | awk ‘{print $2” “$1}’
For the second column… # cat $FILE | awk ‘{$2=$2==int($2)?int($2):int($2)+1}1’
MOD_INTRO_FILE_CHARSET=”$(file -bi “$MOD_INTRO_FILE” | grep charset | sed “s|.*\=||” | awk ‘{print $1}’)” if [ “x$MOD_INTRO_FILE_CHARSET” != “x” ]; then $(which iconv) -l | grep -wi $MOD_INTRO_FILE_CHARSET > /dev/null if [ $? -eq 0 ]; then MOD_INTRO=”$(cat “$MOD_INTRO_FILE” | $(which iconv) -cs -f $MOD_INTRO_FILE_CHARSET -t $CHARSET_TEXTFILE)” else MOD_INTRO=”$(cat “$MOD_INTRO_FILE”)” fi else MOD_INTRO=”$(cat “$MOD_INTRO_FILE”)” fi
function drop_bad_chars { echo “$@” | sed “s|[\’]||g” | sed ‘s|[\”]||g’ }
function do_sql { DB=”$1″ shift test -r “$DBDIR/$DB” if [ $? -ne 0 ]; then write2log “Creating DB $DB” create_db “$DB” fi if [ “x$@” == “x” ]; then return 1; fi LOOP=1;MAXLOOP=10 while true;do $SQLITE “$DBDIR/$DB” “$@” 2>/dev/null && return 0 LOOP=$(( $LOOP + 1 )) RD=”0.$(( ( RANDOM % 9 ) + 1 […]
You must be logged in to post a comment.