Saturday, July 14, 2012

Batch rename files from lower case file name to upper case filename or vice versa!

Suppose you have a lot of image files in lower case name and you want to change rename them to upper case filename or vice-versa


for file in *.jpg; do mv $file $(echo $file | tr a-z A-Z); done

or from upper case to lower case

for file in *.JPG; do mv $file $(echo $file | tr A-Z a-z); done

If filenames contains spaces in them then just wrap the variable names in "", like

for file in *.jpg; do mv "$file" "$(echo $file | tr a-z A-Z)" ; done

Monday, July 2, 2012

Sudo in Fedora - How can I use sudo even when username is not found in /etc/sudoers file!

So, I was reading some stuff about sudo and /etc/sudoers file, that only users who are in the /etc/sudoers file are able to run sudo command; but when I looked into /etc/sudoers file on my system(Fedora 16) I could not find my username in there, but still I was able to use the sudo command. There was also a folder named /etc/sudoers.d but that was empty. So, how was I able to run the sudo command? After searching for somtime on the internet I came to know that the trick was the following line in /etc/sudoers file

%wheel ALL=(ALL)       ALL

This means give sudo access to all users in the wheel group, and when i looked up my group(using groups command) I indeed was part of the wheel group.