This website requires Javascript to function properly. Please go to the setting of your web browser and enable Javascript for this website.
×
Loading...
@Ontario
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
请问web developer和software developer技术上有什么区别?
Elon Musk 带着川普总统奔向火星了。
扔硬币的实验研究
哪位Excel大神帮忙解答一下,一个spreadsheet一表格connection到另外一个spreadsheet,原来的data是数字格式,但是connection以后变成text格式,这是为什么呢?这两天才出现的问题,之前好多年没有过这样的问题。谢谢先
中国政府官方的行为,证明了,苹果手机是世界上最安全的手机。感谢乔布斯先生。感谢库克先生硬是顶住了美国政府的最强大的压力。
枫下论坛主坛
/
工作学习
/
IT技术讨论