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

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

if($#argv == 2)then
	set a = (`ls $argv[1].*.iff`) 
	set n  = 1
 	while($#a >= $n)
		mv $argv[1].$n.iff $argv[2].$n.iff
		@ n ++
	end
else if($#argv == 3)then
	set n = (``)
	set   = (``)
	set   = (``)
	endif
	mv $argv.*.iff $argv.*.iff
else
end






 





















実行結果

引数が2つの場合

# ls
test.1.iff
test.2.iff
test.3.iff
test.4.iff
test.5.iff
# csh kadai1.sh test tmp
mv: when moving multiple files, last argument must be a directory
else: endif not found.
# ls
tmp.1.iff
tmp.2.iff
tmp.3.iff
tmp.4.iff
tmp.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
set: Variable name must begin with a letter.
# ls
xyz.1.iff
xyz.2.iff
xyz.3.iff
xyz.4.iff
xyz.5.iff