for i in $(find ./ -name dubbee*.mp3) do mv $i $i-1.mp3 ffmpeg -i $i-1.mp3 -acodec mp3 -ab 64k $i rm $i-1.mp3 done
Tag Archive for Bash
recode all mp3 files
Get php.ini location
php -i | grep php.ini
Bash script to find and delete files older than x days
find /path/to/files -type f -mtime +7 -exec rm {} ;
Git whitespace fixes for windows newlines
.git/hooks/pre-commit 2>&1 | sed '/^*/d' | sed 's/:.*//' | uniq for FILE in `.git/hooks/pre-commit 2>&1 | sed '/^*/d' | sed 's/:.*//' | uniq` ; do sed -ie 's/[[:space:]]*$//' $FILE ; done
DocBack
# Docback 0.2
# -----------------
# A front-end to rsync:
#
# Back up documents to the
# Simmons server space
# -----------------
# Aaron Rubinstein
# 7/17/08
usage()
{
cat <<EOF
Docback
Back up documents to your Simmons server space
A front-end for rsync
Usage: -u value [-r value] [-d] [-t] filename1 [filename2...]
-u Simmons username (required)
-r remote directory
-d copy entire directory
-t copy file only if edited in last 24 hrs
-g update local file from Simmons server (use with -r)
EOF
exit 2;
}
if [ $# -lt 1 ] ; then
usage;
fi
# Define options
rflag=
uflag=
dflag=
tflag=
gflag=
while getopts 'r:u:dgt' OPTION
do
case $OPTION in
r) rflag=1
rval="$OPTARG"
;;
u) uflag=1
uval="$OPTARG"
;;
d) dflag=1
;;
t) tflag=1
;;
g) gflag=1
;;
?) printf "Usage: %s: -u value [-r value] [-t] [-d] [-g] filename1 [filename2...]
" $(basename $0) >&2
exit 2
;;
esac
done
shift $(($OPTIND - 1))
# If "-d" specified, recursively copy directory with rsync
if [ "$dflag" ] ; then
rsync -vtr $* $uval@cleo.simmons.edu:/users/gslis/$uval/$rval
fi
# If "-t" specified find file if edited within last 24 hrs
if [ "$tflag" ] ; then
FILE=$(find ${HOME}/ -mtime -1 -name $*)
# If nothing found, print message and exit
if [ ! $FILE ] ; then
echo "File has not been edited within last 24 hours"
exit 1;
fi
fi
if [ "$gflag" ] ; then
# Update local folder with contents of remote folder
rsync -vtr $uval@cleo.simmons.edu:/users/gslis/$uval/$rval $*
fi
# Send found file(s) via rsync
rsync -v -t --progress $* $uval@cleo.simmons.edu:/users/gslis/$uval/$rval
My Debian Aliases
# Alias definitions. # You may want to put all your additions into a separate file like # ~/.bash_aliases, instead of adding them here directly. # See /usr/share/doc/bash-doc/examples in the bash-doc package. #if [ -f ~/.bash_aliases ]; then # . ~/.bash_aliases #fi # enable color support of ls and also add handy aliases if [ "$TERM" != "dumb" ]; then eval "`dircolors -b`" alias ls='ls --color=auto' #alias dir='ls --color=auto --format=vertical' #alias vdir='ls --color=auto --format=long' fi # some more ls aliases alias ll='ls -l' alias la='ls -A' alias l='ls -CF' alias sud='sudo apt-get update' alias sug='sudo apt-get upgrade' alias last='last | less' alias rq='sudo repquota -s /home' # enable programmable completion features (you don't need to enable # this, if it's already enabled in /etc/bash.bashrc and /etc/profile # sources /etc/bash.bashrc). if [ -f /etc/bash_completion ]; then . /etc/bash_completion fi
How to redirect something using sudo
echo "# whatever" | sudo tee -a /etc/apt/sources.list
Find out how many instances of Tomcat are running on your computer
ps -eaf | grep tomcat
domain name to IP address
#!/bin/sh
# Usage: domain2ip domain.name1 ... domain.nameN
if test $# -eq 0
then
echo "------------------"
echo "please add domain name to look up ex) domain2ip google.com foo.bar ..."
echo "------------------"
exit 1
fi
echo "------------------"
for names in $@
do
command=`nslookup $1 > d2ip.temp`
command=`grep NXDOMAIN d2ip.temp`
if test $? -eq 0
then
echo "$1 is not a valid IP address"
echo "------------------"
command=`rm -f d2ip.temp`
shift
elif test $? -eq 1
then
ipname=`cat d2ip.temp | grep -i name`
ipadd=`cut -f5 d2ip.temp | grep -i address`
echo "$ipname"
echo "$ipadd"
echo "------------------"
command=`rm -f d2ip.temp`
shift
else
echo "script exited for another reason! <img src='http://www.snippetsmania.com/wp-includes/images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' /> "
fi
done
exit 0