【Shell编程】 测试文件为字符设备文件

用Shell编程,判断一文件是不是字符设备文件,如果是将其拷贝到 /dev 目录下。

#!/bin/bash 

if [ ! $# -eq 1 ]
then
	echo "please add right arg"

else
	#判断文件为字符文件
	if [ -c $1 ]
	then
		#拷贝到 /dev 下
		echo "$1 is a char-type file"
		cp $1 /dev
	else
		echo "$1 is not a char-type file"
	fi 
fi

猜你喜欢

转载自blog.csdn.net/feit2417/article/details/81603374