OS=`uname`
Linux () {
echo Linux!
}
SunOS () {
echo Solaris!
}
Darwin () {
echo OSX!
}
${OS};
date -d @$EPOCH
find . -type d -exec chmod 755 {} \;
find . -type f -exec chmod 644 {} \;
x=3 y=4 area=`bc -l << _EOF $x*$y _EOF `
# convert a column to a space delimited list
foo=`grep $string $file | awk '{ORS=" "; print $1}'`
for arg in $foo;
do
echo $arg;
done;
while ps -p $! > /dev/null; do printf . ; sleep 1; done ; echoBut not if there's no terminal to write to:
## if connected to a terminal show a status tick. printf is posix. tty -s && while ps -p $! > /dev/null; do printf . ; sleep 1; done ; echo ## if not, just idle until find returns. tty -s || wait
# /usr/ucb/mail for SunOS echo $message | /bin/mail -s $subject $recipient
IFS=
# ls -l total 5 -rw-r--r-- 1 dkozak uucp 6 Sep 8 14:31 bar -rw-r--r-- 1 dkozak uucp 6 Sep 8 14:31 baz -rw-r--r-- 1 dkozak uucp 12 Sep 8 14:32 baz bar -rw-r--r-- 1 dkozak uucp 6 Sep 8 14:31 foo -rw-r--r-- 1 dkozak uucp 12 Sep 8 14:31 foo bar # more * :::::::::::::: bar :::::::::::::: word2 :::::::::::::: baz :::::::::::::: word3 :::::::::::::: baz bar :::::::::::::: word3 word2 :::::::::::::: foo :::::::::::::: word1 :::::::::::::: foo bar :::::::::::::: word1 word2 # find . -print0 | xargs -0 grep word3 ./baz:word3 ./baz bar:word3
/usr/bin/ssh -x -n -obatchmode=yes -oconnecttimeout=5 -oGSSAPIAuthentication=no
rand=`mcookie`
fqdn=`host -W 1 \`/bin/hostname\` | awk '{print $1}'`
name=`uname -n` fqdn=`nslookup $name |grep -Po \\S+.edu`
tty -s && echo 'Running in a terminal!' tty -s || echo 'Running via cron, for example.' >output.txt
#!/bin/sh
##
## A few lines of automatic interpreter choosing magic:
##
# \
[ -x /usr/bin/tclsh ] && THE_RIGHT_TCL=/usr/bin/tclsh
# \
[ -x /usr/sfw/bin/tclsh8.3 ] && THE_RIGHT_TCL=/usr/sfw/bin/tclsh8.3
# \
[ -x /usr/sfw/bin/tclsh8.4 ] && THE_RIGHT_TCL=/usr/sfw/bin/tclsh8.4
# \
exec $THE_RIGHT_TCL "$0" ${1+"$@"}
# password encode a string with blowfish, and ascii armor it echo $plaintext | openssl enc -bf -base64 # decode it! echo $blowfish_b64_text | openssl enc -d -bf -base64
rpm -qa --qf "%{NAME}\n" | sort -u
dpkg --get-selections | grep install | sort -u | awk '{print $1}'
if grep -V |grep -q GNU then echo "GNU grep is the default. Yay!" else echo "Crap! Wrong grep!" exit fi
openssl s_client -connect $https-server:443 -showcerts
And sanity:
#!/bin/ksh # # This script verifies proper ssl cert installation, # including CA cert bundle completeness. # # Phil Ehrens <pehrens@ligo.caltech.edu> # openssl s_client -connect $1:443 -verify 10 2>&1 |grep Verify & sleep 1 kill -s SIGTERM $! >/dev/null 2>&1 # echo "" # openssl s_client -connect $1:443 -showcerts 2>&1 |egrep ' [0-9] s:' & sleep 1 kill -s SIGTERM $! >/dev/null 2>&1
tar -cf - $local-dir | ssh $target-host tar -xf - -C $target-dir
Or:
rsync -r --partial --progress --rsh=ssh $local_file $remote_scp_style_target
#!/bin/ksh for ((j=114 ; j<=115 ; j++)) do for ((i=1 ; i<=256 ; i++)) do addr=NNN.NNN.$j.$i name=`dig -x $addr +short` [ -z "$name" ] && name=$addr echo "$addr : '$name'" done done
#!/bin/ksh # # This script walks all over NNN.NNN.11[45] # and reports certs and their expiration dates. # # Phil Ehrens <pehrens@ligo.caltech.edu> # for ((j=114 ; j<=115 ; j++)) do for ((i=1 ; i<=256 ; i++)) do addr=NNN.NNN.$j.$i name=`dig -x $addr +short` [ -z "$name" ] && name=$addr echo "$addr : '$name'" openssl s_client -connect "$addr":443 >"$addr".tmp 2>/dev/null & sleep 2 kill -s SIGTERM $! >/dev/null 2>&1 openssl x509 -in "$addr".tmp -noout -subject -enddate 2>/dev/null rm -f "$addr".tmp done done
echo ${file##*.}
# operates on output of 'rpm -qa |sort' # shows files that are in $1 that are not in $2 # you need to run it in both directions to compare # rpms on two servers. for rpm in $(cat $1) do grep $rpm $2 >/dev/null || echo $rpm done
echo 'select * from $db_table;' | sqlite3 $db_name
$a = 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûýýþÿŔŕ'; $b = 'aaaaaaaceeeeiiiidnoooooouuuuybsaaaaaaaceeeeiiiidnoooooouuuyybyRr';Or:
iconv --from-code=utf-8 --to-code=us-ascii//translit
http://www.google.com/search?q="Linux Rocks"
printf \\033]0\;\%s\\007 "$title"
curl --insecure -c /tmp/mycookies -b /tmp/mycookies --user albert.einstein --location-trusted https://wiki.ligo.org
#!/bin/ksh
#
# Returns total memory used by process $1 in kb.
#
IFS=$'\n'
for line in $(</proc/$1/smaps)
do
if [[ $line =~ ^Size: ]]
then
IFS=' '
set -A tmp $line
((kb += ${tmp[1]}))
fi
done
print $kb
Terse version (no faster)
#!/bin/ksh
#
# Returns total memory used by process $1 in kb.
#
IFS=$'\n'
for line in $(</proc/$1/smaps)
do
[[ $line =~ ^Size:\s+(\S+) ]] && ((kb += ${.sh.match[1]}))
done
print $kb
var='orl,bdl,lap'
pattern='^[^,]*,(.*)$'
[[ $var =~ $pattern ]]
newvar=${.sh.match[1]}