Solved Linux shell scripting Problem !

December 16, 2011 at 07:59:55
Specs: Windows XP
I need a shell script which can search a file and tell if it is in /root directory or not ..
if it was there , change the file name characters from LOWER to UPPER or UPPER to LOWER cases and creat a new file which contain last folder subfiles with a new name ..
it have to be compiled with gcc ..


See More: Linux shell scripting Problem !

Report •

December 16, 2011 at 09:44:44
✔ Best Answer
Are you asking to change files in the /root directory only at the first level? The Linux find command will list only the files in the parent directory:

cd /root
find . -maxdepth 1 -type f -print

First, to change any files would require root user permission. Are you sure you want to do this?

Second, within a file name, changing upper case letters to lowercase and lowercase to uppercase is tricky. I need to think about it, but I see no way of doing it other than looking at each letter individually.

Third, I don't know exactly what this means:

"and creat a new file which contain last folder subfiles with a new name ..
it have to be compiled with gcc .."

Remove the maxdepth check will allow searching sub folders/directories.

Report •

December 17, 2011 at 03:54:51
Be aware that changing the filenames (bearing in mind that Linux filenames are case sensitive) may well lead to a system that cannot boot.

Also be aware that you cannot compile a batch script with gcc. Why this strange requirement? (Hint: when a poster specifies that a particular tool be used it probably means that this is a homework question where that requirement was stated. If that is not the case here then I would be fascinated to know the reason for the requirement.)

Report •

December 17, 2011 at 08:39:49
Dear Friends :
you're right , this is my homework & i have to do it until tomorrow ! :(
1- find a file which name's "ExAmple.txt"
2- it have to tell if this file exists in /root directory or not !
3- if it was found , change the lower cases to upper or upper to lower (i didn't know that it should have permission to do that !)
4- when the name have been changed , it should create a new folder with this name ( the changed name in step 3 )
5- create file "eXaMPLE.txt"

Report •

Related Solutions

December 17, 2011 at 14:07:07
Don't you think that it is cheating to ask someone else to do your homework for you? Do you think you deserve any credits that you get in that case?

Report •

December 17, 2011 at 22:47:21
it seems that you don't like to solve my problem .. so isn't it better to let the other friends lead me up ?!
i just need the codes for These Commands : Find , Rename and Create New File

Report •

December 19, 2011 at 03:57:53
help or man will answer most of your questions.

Report •

December 19, 2011 at 04:51:05
Are you sure that the requirement is for a shell script? "it have to be compiled with gcc" would seem to imply a C program.

Report •

December 19, 2011 at 20:55:50
yes , that's right ..
it was my mistake.. it should be a C program

Report •

Ask Question