Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/26.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
Linux 如何转义shell脚本中的命令关键字?_Linux_Bash_Shell_Heredoc - Fatal编程技术网

Linux 如何转义shell脚本中的命令关键字?

Linux 如何转义shell脚本中的命令关键字?,linux,bash,shell,heredoc,Linux,Bash,Shell,Heredoc,在我的shell脚本中,我有 #!/bin/bash var1=$1 var2=$2 cat<<new_script<<EOF ...some code... for i in `find / -perm 6000 -type f`; do chmod a-s $i; done mkdir $var1 ...some code... EOF #/bin/bash var1=1美元 var2=2美元 带单引号的catQuoteEOF: #!/bin/bash cat &g

在我的shell脚本中,我有

#!/bin/bash
var1=$1
var2=$2
cat<<new_script<<EOF
...some code...
for i in `find / -perm 6000 -type f`; do chmod a-s $i; done
mkdir $var1
...some code...
EOF
#/bin/bash
var1=1美元
var2=2美元

带单引号的catQuote
EOF

#!/bin/bash
cat >>new_script <<'EOF'
...some code...
for i in `find / -perm 6000 -type f`; do chmod a-s $i; done
...some code...
EOF
#/bin/bash

cat>>带有单引号的新脚本Quote
EOF

#!/bin/bash
cat >>new_script <<'EOF'
...some code...
for i in `find / -perm 6000 -type f`; do chmod a-s $i; done
...some code...
EOF
#/bin/bash

cat>>新脚本能否解释放置“EOF”会做哪些更改以使其正常工作?如果没有单引号,行为变量将被插入,反勾号中的命令将被计算,等等。这可以通过引用标签的任何部分来禁用,然后以未加引号的值结束。我也需要使用变量。我已经做了编辑。用
EOF
替换
'EOF'
,用
\$(find/-perm 6000-typef)
替换
'find/-perm 6000-typef'
。你能解释一下放“EOF”会有什么变化吗?没有单引号,行为就是变量被插入,反勾中的命令被计算,等。这可以通过引用标签的任何部分来禁用,然后以未引用的值结束。我也需要使用变量。我已经做了编辑。用
EOF
替换
'EOF'
'find/-perm 6000-type f`
替换
\$(find/-perm 6000-type f)