UNIXオペレーションII 課題1 (99ad0526)

提出されたスクリプト(kadai1.sh)

if($#argv == 2) then
	set i = 1 
	while($i <= $argv[1])	
	mv $argv[2].$i.iff $argv[3].$n.iff
	@ i ++
end	
else if($#argv == 3) then
	set i = 1
	while($i <= $argv[1])
	mv $argv[2].$i.iff $argv[3].$n.iff
	@ i ++
end	
endif

実行結果

引数が2つの場合

# ls
test.1.iff
test.2.iff
test.3.iff
test.4.iff
test.5.iff
# csh kadai1.sh test tmp
while: Expression Syntax.
# ls
test.1.iff
test.2.iff
test.3.iff
test.4.iff
test.5.iff

引数が3つの場合

# ls
xyz.1.iff
xyz.2.iff
xyz.3.iff
xyz.4.iff
xyz.5.iff
# csh kadai1.sh 3 test tmp
n: Undefined variable.
# ls
xyz.1.iff
xyz.2.iff
xyz.3.iff
xyz.4.iff
xyz.5.iff