for file in $(ls *.*); do base=$(basename $file); echo ${base##*\.};done | sort | uniq -c | sort -n -r 37 tsv 18 pdf 17 txt 7 err 5 log 5 png
Here I see that there are some log files that can be removed (if no longer needed).
This is mainly somewhere for me to dump interesting tidbits of tech info. Stuff that I may forget but will need again in the future. For a proper blog, visit my electronics blog (http://www.fangletronics.com) or my wife's pre-school crafty blog (http://www.filthwizardry.com).
for file in $(ls *.*); do base=$(basename $file); echo ${base##*\.};done | sort | uniq -c | sort -n -r 37 tsv 18 pdf 17 txt 7 err 5 log 5 png
> perl -le 'printf "%.4f\t%.4f\n", rand(), rand() for 1 .. 20' \ | R --vanilla --slave -e\ "data=read.delim(pipe('cat /dev/stdin'), header=F);\ cor.test(data\$V1, data\$V2)"
$
in this case).
function write_density_plot(data, name) { filename = paste(name, '_density_distribution.png', sep="") png(filename) print(densityplot(data, main=paste(name, 'score distribution')) dev.off() } filedata = read.delim('myfile', header=T) write_density_plot(filedata$blorg, 'blorg') write_density_plot(filedata$blarg, 'blarg') write_density_plot(filedata$wib, 'wib')
columnHeaders.sh
.columnHeaders.sh
script and then use diff
, kompare
or comm
to compare them.> diff <(columnHeaders.sh file1) <(columnHeaders.sh file2) 2,3c2,3 > 0 blarg > 1 blorg -- < 0 blorg < 1 blargIn this case we see two columns have been swapped between file1 and file2.
columnHeaders.sh
script basically does this (but allows user specified delimiters):
> head -1 <input file> | perl -F'\t' -lane 'print $n++,"\t$_" for @F'
if [[ ! -n "$2" ]];
then
echo "I received the second parameter:$2"
fi
getopts
is your friend.
while getopts f:l:p flag
do
case $flag in
f)
FIRSTNAME=$OPTARG;;
l)
LASTNAME=$OPTARG;;
p)
PRIVATE=1;;
?)
echo "$0 -f <first name> -l <last name> -p"
echo -e "\t-p [flag] keep my data private"
exit
done
man getopts
for more details). If an option requires an argument then a colon is placed after it's letter designation ('f' and 'l' in the above example).
if [[-z "$FIRSTNAME" || -z "$LASTNAME" ]];
then
echo "missing required parameter"
fi
function usage_and_exit()
{
echo "$0 -f <first name> -l <last name> -p"
echo -e "\t-p [flag] keep my data private"
exit
}
while getopts f:l:p flag
do
case $flag in
f)
FIRSTNAME=$OPTARG;;
l)
LASTNAME=$OPTARG;;
p)
PRIVATE=1;;
?)
usage_and_exit;;
done
if [[ -z "$FIRSTNAME" || -z "$LASTNAME" ]];
then
echo "missing a required parameter (firstname and lastname are required)"
usage_and_exit
fi
if [[ $PRIVATE -ne 0 ]];
then
echo "protecting private data"
fi
mysql> SHOW VARIABLES LIKE 'wait_timeout';
+--------------------------+-------+
| Variable_name | Value |
+--------------------------+-------+
| wait_timeout | 28800 |
+--------------------------+-------+
1 row in set (0.00 sec)
mysql> SET GLOBAL wait_timeout=86400;
mysql> SHOW VARIABLES LIKE 'wait_timeout';
+--------------------------+-------+
| Variable_name | Value |
+--------------------------+-------+
| wait_timeout | 28800 |
+--------------------------+-------+
1 row in set (0.00 sec)
mysql> SHOW GLOBAL VARIABLES LIKE 'wait_timeout';
+--------------------------+-------+
| Variable_name | Value |
+--------------------------+-------+
| wait_timeout | 86400 |
+--------------------------+-------+
1 row in set (0.00 sec)