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.

Friday, June 29, 2012

How to Record and Play macro in Visual Studio

Macro comes in very handy if you have to repeat certain operation a lot of times.

Ctrl + Shift + R => Start
Ctrl + Shift + R => Stop
Ctrl + Shift + P => Play

I recently learned about them when i needed to put breakpoint on all the calls to function(SendEvent) and inspect the event id. At first i was manually putting the breakpoint but then i realised that the file was like 3K lines of code. So, instead what i did was search for "SendEvent" once and then after that pressing F3 will move to next occurrence of the searched string. Then move to the start of the file. Press Ctrl+Shift+R to start recording macro, press F3 to get to first matched string and then press F9 to put the breakpoint.  Press Ctrl+Shift+R to stop recording. Then keep pressing Ctrl+Shift+P till the end of the file.

Thursday, February 9, 2012

Yum cannot resolve $releasever - Fedora

Yesterday I was installing some packages with yum, but then later decided to cancel the install pressing Ctrl+C, after that i started noticing this issue. Whenever i tried to install anything yum spilled the following error.

Could not parse metalink http://mirrors.fedoraproject.org/metalink?repo=fedora-$releasever&arch=x86_64 error was
No repomd file

Yum was not able to resolve the value of $releasever variable. It turns out that it gets to know that value from the version of "fedora-release" package installed on the system.
After i figured that out, the solution was simple, just reinstall "fedora-release" for your current system. Since currently i am using fedora 15, I issued the following command

yum install fedora-release --releasever=15

Notice, you need to tell yum to use release version of the current fedora release using --releasever