Case the joint

I have no idea where I found this little script but note the use of the case function on line 7. It is no real eye opener but it is an intelligent and fast method of parsing the command line options of the script.

The final cut

So then, I had to rename this temp file that was in the format "filename.extension.TMP" to its original filename.

This was a solution for "cut":

newname=`echo $name| cut -f1,2 -d "."`
mv $name $newname

The parameter -f specifies that I want to use the first and second fields of the variable $name.

The parameter -d specified the delimiter to be "."; a period

And voila!

 

Just for your information, this script was intended for use as a batch renaming of files.

What's this about then?

My name is Mohammed Arafa.

I am an AIX/Linux System Administrator. This is where I post stuff about POSIX.
You are also welcome to post stories and comments. I also have a forum for you to use.

Enjoy!

Pages

Subscribe to Posix In Egypt RSS