Skip to content

Instantly share code, notes, and snippets.

@snorfsneflin
Last active November 11, 2015 07:15
Show Gist options
  • Save snorfsneflin/15e10d37c8aab2410618 to your computer and use it in GitHub Desktop.
Save snorfsneflin/15e10d37c8aab2410618 to your computer and use it in GitHub Desktop.
shell trix
#/usr/env bash
#
#create 7 constants using output of date command
readonly year month day hour minutes seconds epoch _ < <(date '+%Y %m %d %H %M %S %s')
#create 7 variables using output of date command
#read year month day hour minutes seconds epoch _ < <(date '+%Y %m %d %H %M %S %s')
echo $year $month $day $hour $minutes $seconds $epoch
#
echo
echo 'optimal cpu load based on number of processors and cores: '
echo "$(( $(grep 'physical id' '/proc/cpuinfo' | uniq | wc -l) * $(grep 'core id' '/proc/cpuinfo' | wc -l) ))"
echo
echo 'cpu load meeting or exceeding below would indicate a problem: '
echo "$(( $(( $(grep 'physical id' '/proc/cpuinfo' | uniq | wc -l) * $(grep 'core id' '/proc/cpuinfo' | wc -l) )) * 2 + 1 ))"
echo
echo "current $(uptime | cut -d, -f4 | sed 's/^ *//')"
#look for pattern 'hello world' contained in files located within working directory and below
#suppress errors, match whole words, print file name:line number:*
grep -srnw "$PWD" -e 'hello world'
# filter empty lines and lines that start with a #
egrep -v '^#|^$' '/path/to/file'
echo 'total number of 50 mb+ files in working directory and below'
find . -type f -size +50M | wc -l
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment