Rename files quickly

By admin

A cheap trick from the comand line, let's say you have a directory where the files end in MP3 instead of mp3 (lower):

kenglish@bowls:~/play/mp3$ ls
track1.MP3 track2.MP3 track3.MP3 track4.MP3 track5.MP3 track6.MP3

(first, test it)

kenglish@bowls:~/play/mp3$ for FILE in *.MP3; do NEW_FILE=`echo $FILE | sed -e s/MP3$/mp3/`; echo “mv $FILE $NEW_FILE”; done
mv track1.MP3 track1.mp3
mv track2.MP3 track2.mp3
mv track3.MP3 track3.mp3
mv track4.MP3 track4.mp3
mv track5.MP3 track5.mp3
mv track6.MP3 track6.mp3

(now, run it!)

kenglish@bowls:~/play/mp3$ for FILE in *.MP3; do NEW_FILE=`echo $FILE | sed -e s/MP3/mp3/`; echo “mv $FILE $NEW_FILE”; `mv $FILE $NEW_FILE`; done
mv track1.MP3 track1.mp3
mv track2.MP3 track2.mp3
mv track3.MP3 track3.mp3
mv track4.MP3 track4.mp3
mv track5.MP3 track5.mp3
mv track6.MP3 track6.mp3
kenglish@bowls:~/play/mp3$ ls
track1.mp3 track2.mp3 track3.mp3 track4.mp3 track5.mp3 track6.mp3

I know, for you senior admins this is a no-brainer but junior here always forgets how to do it…

note: if the file names have spaces in them, do this for the mv command, command would look like this:

kenglish@bowls:~/play/mp3$ for FILE in *.MP3; do NEW_FILE=`echo $FILE | sed -e s/MP3/mp3/`; echo “mv \”$FILE\” \”$NEW_FILE\”"; `mv “$FILE” “$NEW_FILE”`; done

categoriaLinux commentoNo Comments dataJune 12th, 2007
Read All

Kernel Version and Distribution

By admin

What linux distribution the box is using:
cat /etc/issue

What kernel version the box is running:
uname -a

Sample Output:

kenglish@bowls:~$ uname -a
Linux bowls 2.6.20-16-generic #2 SMP Thu Jun 7 20:19:32 UTC 2007 i686 GNU/Linux
kenglish@bowls:~$ cat /etc/issue
Ubuntu 7.04 \n \l

categoriaLinux commentoNo Comments dataJune 11th, 2007
Read All

Checking/changing hostname

By admin

Some command options:

uname -n
hostname -a
hostname -s
hostname -d
hostname -f
hostname

To change the hostname (in debian/ubuntu ):

1) user hostname command:
sudo hostname NEW_HOSTNAME

2) change in hosts file
sudo vi /etc/hosts

3) use sysctl to change the variable kernel.hostname:
sudo sysctl kernel.hostname=NEW_HOSTNAME

categoriaLinux commentoNo Comments dataJune 11th, 2007
Read All