Computing.Net > Forums > Unix > Unix c shell script

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Unix c shell script

Reply to Message Icon

Name: wind0610
Date: January 15, 2006 at 09:15:58 Pacific
OS: WindowsXP
CPU/Ram: 1gb
Comment:

I need to write a script that can check if the file exists ignore the case. How can I do that? Please help me out!! Thank you all.



Sponsored Link
Ads by Google

Response Number 1
Name: aka
Date: January 15, 2006 at 12:04:47 Pacific
Reply:

Something like this ?

If not, please be more specific. :D

clear
echo -n "Search file if exist for : "
read chfile
ls -lG $chfile
ls -lG /home/$chfile


Don“t freak out until you know the facts...Relax...!


0

Response Number 2
Name: wind0610
Date: January 15, 2006 at 12:15:41 Pacific
Reply:

Here is what I need to do. First, I want to find all the .cpp and .h files then check if the file is not directory, not already in lower case, and no other files has the same name. If it passes those tests then rename the file into lower case. Here is my script
#!/bin/csh
foreach file (*.cpp *.h)
if (-d "$file") then
echo 'Error: This is a directory that cannot be renamed.'
else if(#don't know what to do) then
echo 'Error: The file name is already in lower case.'
else if(#don't know what to do) then
echo 'Error: The file already exists.'
else
echo "$file" | sed 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/' >> newname
mv $file $newname
echo "The file $file has been renamed to $newname"
endif
end


0

Response Number 3
Name: wind0610
Date: January 15, 2006 at 19:03:08 Pacific
Reply:

Never mind ~I get this fixed
Thank you for the help.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Unix c shell script

C-shell script help www.computing.net/answers/unix/cshell-script-help/6828.html

C Shell script.. www.computing.net/answers/unix/c-shell-script/1537.html

decimal numbers in c shell scripts www.computing.net/answers/unix/decimal-numbers-in-c-shell-scripts/1945.html