Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Bash $f在shell脚本中的含义是什么?_Bash - Fatal编程技术网

Bash $f在shell脚本中的含义是什么?

Bash $f在shell脚本中的含义是什么?,bash,Bash,我很难理解这句话的意思 #!/bin/bash Files=`(find . -type f)` for f in $Files do if [ "$(dirname $f)" != "." ] then # these are files in a subdirectory x=$(dirname $f) #get the name of the file with the directory y=${x:2} #remove ./ from t

我很难理解这句话的意思

#!/bin/bash
Files=`(find .  -type f)`
 for f in $Files
 do
  if [ "$(dirname $f)" != "." ]
  then
  # these are files in a subdirectory
   x=$(dirname $f)  #get the name of the file with the directory
   y=${x:2}         #remove ./ from the name
   echo $(basename $f) \($y\)
  else
   # these are files in the current directory
   echo $(basename $f)
 fi
done
意味着什么?查找目录中的每个文件吗?“类型f”是否意味着查找每个“文件”类型? 还有,$f的功能是什么


我开始在壳牌,所以任何帮助都会非常有用

有关$Files中的f,请参见
。。。
$f
指的是
循环变量的
。也可以写出来

Files=1(find . -type f)` 

是的,
-type f
表示“文件”

请参见
了解$files中的f
。。。
$f
指的是
循环变量的
。也可以写出来

Files=1(find . -type f)` 

是的,
-type f
表示“文件”。

对不起,我还没有足够的声誉来添加评论。Elliott对您的“f”变量名有正确的答案。不过,为了回答您的后续问题,时间段的意义与文件类型无关

在linux中,“.”表示您的pwd或当前工作目录。pwd的父目录由“..”表示。find命令要求提供路径,无论是相对路径还是绝对路径。“.”通过有效地说“在当前目录(.)和所有子目录中搜索”来实现这一点。Find自然是递归的IIRC


快乐的黑客

对不起,我还没有足够的声誉来添加评论。Elliott对您的“f”变量名有正确的答案。不过,为了回答您的后续问题,时间段的意义与文件类型无关

在linux中,“.”表示您的pwd或当前工作目录。pwd的父目录由“..”表示。find命令要求提供路径,无论是相对路径还是绝对路径。“.”通过有效地说“在当前目录(.)和所有子目录中搜索”来实现这一点。Find自然是递归的IIRC


快乐的黑客

man-find
祝你好运。@Sheller
man-find
无助于回答OPs问题“在shell脚本中$f是什么意思?”
man-find
祝你好运。@Sheller
man-find
无助于回答OPs问题“在shell脚本中$f是什么意思?”现在对$f感到如此愚蠢。至于f型,它的意义是什么。在Files=(find.-type f)中,@Laura
find
将启动搜索的目录作为参数。它查找给定目录和所有子目录中的内容。
文件=(find.-type f)
中的点
意味着find应该启动“在此目录中”的搜索。它与
/
相同。例如,在您的命令行
cd.
上尝试一下,您将停留在目录中,您现在对$f感到非常愚蠢。至于f型,它的意义是什么。在Files=(find.-type f)中,@Laura
find
将启动搜索的目录作为参数。它查找给定目录和所有子目录中的内容。
文件=(find.-type f)
中的点
意味着find应该启动“在此目录中”的搜索。它与
/
相同。例如,在您的命令行
cd.
上尝试,您将停留在您所在的目录中