我需要将一个文件作为参数发送到我的C Shell脚本。现在我需要检查它是带有.xml扩展名的文件还是包含扩展名为.xml的文件列表的文件。
答案 0 :(得分:3)
我没有办法测试这个,但我过去使用csh的经历告诉我像
#!/bin/csh
file="$1"
switch ("$file")
case *.xml:
echo "file matches .xml"
breaksw
default:
if ( grep '\.xml$' "$file" ) then
echo "xml file extensions found in $file"
endif
breaksw
endswitch
应该有用。
IHTH