This website requires Javascript to function properly. Please go to the setting of your web browser and enable Javascript for this website.
×
Loading...
@Sacramento
Mall
Forum (EN)
Groups
Blogs
Topic
Panel View
Tree View
Close
Home
Refresh
Share
Sign In/Sign Up
Mall
Forum (English)
Blogs
Groups
Polls
Rolia Radio
This topic has been archived. It cannot be replied.
工作学习
/
IT技术讨论
/
问一个Shell 问题
下面的这个脚本根据提供的参数, 搜索当前目录下的文件是否含有规定内容,
如有, 拷到一个目录下.
find-and-copy
--------------------
#!/bin/sh
mkdir $1
for File in *
do
result=`grep -l $1 $File`
if test $File = $result
then
cp $File $1/$File
fi
done
----------------------------------
问题是系统把$File(文件名)的内容当成变量. 碰到每一个文件总是提示 xxx not found. 怎样让系统把$File当成是字符?
谢了先.
-
sndialogue
(globeandmail);
2005-4-20
{470}
(#2251675@0)
好像没问题呀。当字符还是当文件名depends on the parameter definition of the cmd. add -x at the end of the fist line to identify which statement has problem. below is my practise:
-
647i
(倒行逆施);
2005-4-21
{1060}
(#2252547@0)
double quote need to be added in the "test" line, in case there is no matach.
-
647i
(倒行逆施);
2005-4-21
(#2252548@0)
Thanks
-
sndialogue
(globeandmail);
2005-4-21
(#2252844@0)
>>. 怎样让系统把$File当成是字符? A: \$File
-
bugfree
(BugFree);
2005-4-30
(#2269687@0)
Share
More Topics
中国政府官方的行为,证明了,苹果手机是世界上最安全的手机。感谢乔布斯先生。感谢库克先生硬是顶住了美国政府的最强大的压力。
老程序员第一次用copilot的一点点体会
现在社区游泳池招救生员巡逻,过一会还要不停的点人头,这工作是否很快就被AI代替了,装一个摄像头后面是AI处理系统,这样只招一个等着救人就行了,人头沉下水一定时间立马强光照射,还可以分析水下人的状况来判断是否溺水等
新冠疫苗引发心肌炎? 最新研究这样看
这道几何题有解吗?
枫下论坛主坛
/
工作学习
/
IT技术讨论