Just like I last posted the below script can be used to remove blank spaces from file names.
#!/bin/sh
find . -name "* *"|while read file
do
target=`echo "$file"|tr -s ' ' '_'`
mv "$file" "$target"
done
Category Archives: script
Shell script: Rename extensions of multiple files.
Shell provides easy way of renaming multiple files.
Eg: your directory has ’01 – Song1.mp3′, ’02 – Song2.mp3′, ’03 – Song3.mp3′ and you want to rename them to .txt. use the following commane.
$rename mp3 txt *.mp3
The above command renames .mp3 files to .txt.
An alternate script solution from here
#!/bin/sh
ls *.mp3|while read file
do
target=`echo $file|cut -d . -f 1`
#mv "$file" "$target.txt"
echo "$target.txt"
done
First test the above script by seeing the echo "$target.txt"
output then uncomment the line above it and comment this line.
Assorted Linux/Ubuntu Gotchas!!
To customise Vi Editor
copy /usr/share/vim/vimrc to ~/.vimrc
:syntax on for color highlighting
:set incsearch for incremental search in vi editor
to clear and redraw the screen ^L
To get network info
netstat -lneap | grep tcp
5900 for vnc
21 for ftp
To mount Windows partitions (NTFS) on boot-up, and allow users read and write access
sudo apt-get install ntfs-3g
sudo vi /etc/fstab
and add the following
/dev/hda5 /media/windows ntfs-3g defaults,locale=en_US.utf8 0 0
To mount network folder
//192.168.151.97/freeware /media/freesoft smbfs credentials=/root/.smbcredentials 0 0
To list all ips in a network
nmap -v -sP 192.168.185.1/24 | grep "appears to be up" | cut -d ' ' -f 2
Install FLash editor for linux
wget http://www.sonsuzdongu.com/paketler/f4lm_0.1-1_i386.deb
sudo dpkg -i f4lm_0.1-1_i386.deb
Postgresql
If you want to allow other(s) network system to access your
database, you need to make changes in two files : postgresql.conf and
pg_hba.conf.
in postgresql.conf file you need to specify IP address(es) to listen on,
with comma seperated. OR ‘*’ for ALL.
listen_addresses = ‘*’
And in pg_hba.conf you need to add the following line at end :
host all all 192.168.185.1/8 trust
Java 5 doc
wget http://javadocs.planetmirror.com/dist/jdk150-hh.zip
#To convert a wav to a mp3 file
sudo apt-get install lame
lame -h -v -b 128 music.wav music.mp3
#To convert all .wav files in a directory
#converts music.wav to music.wav.mp3
ls *.wav | xargs -i lame -h '{}' '{}'.mp3
or to find all files from current dir and subdirs
find . -iname "*.wav" | xargs -i lame -h '{}' '{}'.mp3
#to move files to a new directory
ls |xargs mv --target-directory=../somedir