xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

Linux bash shell script block comment All In One

Linux bash shell script block comment All In One

Linux bash shell 脚本 多行注释 / 块级注释

https://stackoverflow.com/questions/43158140/way-to-create-multiline-comments-in-bash/76127090#76127090

# :后面有空格 ✅
: <<EOF
# codes ...
...
# whatever ...
EOF

# :后面无空格 ✅
:<<EOF
# codes ...
...
# whatever ...
EOF
# :<<'block_comment'
:<<'END'

END
#  block_comment
:<<UFO
# codes ...
...
# whatever ...
UFO

# 双引号 ✅
:<<"BC"
# codes ...
...
# whatever ...
BC

# 单引号 ✅
:<<'BC'
# codes ...
...
# whatever ...
BC

# 无引号 ✅
:<<BC
# codes ...
...
# whatever ...
BC

# emoji ✅
:<<🇨🇳
# codes ...
...
# whatever ...
🇨🇳

demos

#!/usr/bin/env bash

echo "Line 1"

# linux bash block comment

# :<<'block_comment'
:<<'END'
n=0
b=10
a=1
while read line
do
  n=`expr $n + $a`
  if [ $n == $b ]
  then
      echo $line
  fi
done < file.txt
END
# block_comment

echo "Line end ✅"

sed / head / tail


sed -n 10p ./text.txt

sed -n '10p' ./text.txt
# cat ./text.txt | head -n +10p ❌

cat ./text.txt | head -n +10

cat ./text.txt | head -n 10

cat ./text.txt | head -n +10 | tail -n 1

# cat ./text.txt | head -n 10 | tail -n 1 ❌

# cat ./text.txt | tail -n 10p ❌

cat ./text.txt | tail -n +10

cat ./text.txt | tail -n 10

cat ./text.txt | tail -n +10 | head -n 1

cat ./text.txt | tail -n 10 | head -n 1

# cat ./text.txt | tail -n '10p' | head -n 1 ❌

Linux bash REPL

https://www.lintcode.com/problem/2656/description

(🐞 反爬虫测试!打击盗版⚠️)如果你看到这个信息, 说明这是一篇剽窃的文章,请访问 https://www.cnblogs.com/xgqfrms/ 查看原创文章!

refs

https://stackoverflow.com/questions/947897/block-comments-in-a-shell-script

https://www.runoob.com/linux/linux-shell-variable.html#:~:text=%24{%23array_name[n]}-,Shell 注释,-以 %23 开头



©xgqfrms 2012-2021

www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!

原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!


posted @ 2022-06-14 17:34  xgqfrms  阅读(34)  评论(0编辑  收藏  举报