23,121
社区成员
发帖
与我相关
我的任务
分享
#!/bin/sh
echo "请输入你要查找的内容:"
read findstring
echo "请输入你要超找的路径或者文件"
read targetpath
while test -z $findstring
do
echo "输入为空请重新输入:"
read findstring
done
while test -z $targetpath
do
echo "路径或者文件为空请重新输入:"
read targetpath
done
append="/*"
if test -d $targetpath || test -f $targetpath
then
grep -l "$findstring" $targetpath$append
echo $targetpath$append
echo "grep -l '$findstring' $targetpath$append"
else
echo "不是一个文件或者路径"
fi
单引号不会变量扩展,要双引号。