kpn$ cat scriptit.txt
Some shellscripts of mine. Done for personal use only, but shared here
so anyone can take them and use them if they like. All scripts are
provided as-is and without support. But you can do anything you like
with them. All done in freebsd and (bash|zsh) enviroment, but might
work on linux and other shells too.
admin FreeBSD admin, open into it's own page...
salasana Create random passwords
free info about memory usage (something like "free" in linux)
num number guessing game
lento for flight checking in/out from hki-vantaa airport
thumb.sh script for thumbnail creating
bind.sh function (or includes) for choosing IP to bind
di.shList files in directory and info about file types
du.shDisk usage of homedir and mailbox
ip.sh List assigned IPs and check hostnames for them
And here we have some oneliners for commandline usage
Change extensios of filenames (without rename, example all .htm to .html):
for i in *.htm; do mv "$i" "${i/.htm}".html; done
Remove whitespaces from filenames (ie. convert whitespaces to underscores):
for i in *; do mv "$i" "`echo $i | tr " " "_"`"; done
Change some text inside many files (ie. change "Foobar" to "foo" inside all .html)
find ./ -name "*.html" -exec perl -pi -e "s/Foobar/foo/g;" {} \;
Change all file names recursive w/o touching directory names
Example changes fooBAR to FOObar in all file names under /home/testi recursive, but it doesnt touch directory names
find /home/testi -type f | while read I ; do mv "$I" "${I%/*}/`echo "${I##*/}" | sed s/fooBAR/FOObar/g`" 2>/dev/null ; done
Same as earlier but using tr to convert whitespaces from file name to underscores
Again this will leave all underscores to directory names
find ./ -type f | while read I ; do mv "$I" "${I%/*}/`echo "${I##*/}" | tr " " "_"`" 2>/dev/null ; done
Make all numbers inside file bigger (ie. add 3 too all numbers inside file i.txt)
perl -i.tiny -pe 's/(\d+)/3+$1/ge' i.txt
Same with stdin example (ie. output would be 4 is 3)
echo '2 is 1' | perl -i.tiny -pe 's/(\d+)/2+$1/ge'
kpn$