Computing.Net > Forums > Unix > If and Case

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Click here to start participating now! Also, check out the New User Guide.

If and Case

Reply to Message Icon

Name: smart2 (by patelh)
Date: April 10, 2007 at 12:09:32 Pacific
OS: Windows XP
CPU/Ram: 1024MB
Product: Sony Vaio
Comment:

Can someone briefly explain to me what is occurring in this script?


#!/bin/csh
if ($#argv < 2) then
echo Not enough arguments
echo usage: chx *.oldx nwx
exit 0
endif
mkdir /tmp/chx.$user
set nwx="$argv[$#argv]"
set oldx="$argv[1]:e"
echo "are you sure you want to run chx?"
switch ($<)
case y:
breaksw
case yes:
breaksw
default:
echo Nothing done
exit 0
endsw
set i=0
foreach file ( $argv )
@ i++
if ( $i == $#argv ) break
cp $file /tmp/chx.$user/$file:r
end
set array = `ls /tmp/chx.$user`
foreach file ( $array )
if ( -f $file.$nwx ) then
echo destination file $file.$nwx exists. No action taken
continue
endif
cp /tmp/chx.$user/$file $file.$nwx
rm $file.$oldx
end
rm -r /tmp/chx.$user

Hal



Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


sorting problem sorting f... script - loop



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: If and Case

Syntax for IF ....AND www.computing.net/answers/unix/syntax-for-if-and/4562.html

context free grammer www.computing.net/answers/unix/context-free-grammer/4767.html

ibm - sco AIX issue www.computing.net/answers/unix/ibm-sco-aix-issue/6057.html