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

Linux echo 换行 All In One

Linux echo 换行 All In One

auto-install-npm.sh

#!/bin/sh

# sh/zsh/bash 选择默认

# echo "🚀 linux shell 定时器" && npm i -g app-node-env
# echo "🚀 linux shell 定时器" && yarn global add app-node-env

# 写入 logs
echo "🚀 linux shell 定时器" >> ./auto-install-npm.log 2>&1

# echo 换行
# echo -e "\n\n\n"
# echo "\n"

# 安装 log
# yarn global add app-node-env >> ./auto-install-npm.log 2>&1

# 安装不需要 log
yarn global add app-node-env

# Linux Bash shell 脚本定时器 All In One
# https://www.cnblogs.com/xgqfrms/p/15384401.html


zsh bug ???

# ❌
➜  ~ sudo ./auto-install-npm.sh >> /var/log/auto-install-npm.log 2>&1
zsh: permission denied: /var/log/auto-install-npm.log
➜  ~ ./auto-install-npm.sh >> /var/log/auto-install-npm.log 2>&1 
zsh: permission denied: /var/log/auto-install-npm.log

# ✅ OK
$ ./auto-install-npm.sh >> ./auto-install-npm.log 2>&1

linux 2>&1

cron logs

https://stackoverflow.com/questions/4811738/how-to-log-cron-jobs

# 2>&1, 标准输出和错误输出二合一

* * * * * ./auto-install-npm.sh >> /var/log/auto-install-npm.log 2>&1

https://stackoverflow.com/questions/818255/in-the-shell-what-does-21-mean

crontab / corn


# 定时器任务test
# 每隔 30 分钟运行一次,使用 sh 自动安装 app-node-env
# 30 * * * * sh ./auto-install-npm.sh
30 * * * * /bin/sh ./auto-install-npm.sh


https://www.cnblogs.com/xgqfrms/p/15384401.html

echo \n 换行 & EOF 多行注释 All In One


#!/bin/bash

# echo \n ❌
# echo "sed test\n"

# echo -e \n ✅
echo -e "sed test\n"

# echo $"双引号 ❌"
# echo $"sed test\n"

# echo $'单引号 ✅'
echo $'sed test\n'

printf "sed test\nabc xyz\n\n"

printf "sed test\nabc xyz"
# sed test
# abc xyz%
# printf % bug ❓zsh bug

# multi lines comments `<<EOF` & `EOF`

# multi_lines_comments = <<EOF

<<EOF

The \`%\` is not printed by \`printf\`, it's printed by \`zsh\` as part of its command prompt.

Bash uses \`$\` or something more complicated instead, that's why it looks different with bash.

\`printf\` prints the same thing both times, and following that the shell prints it's command prompt.

This command prompt looks different in \`zsh\` than in \`bash/sh\`.

https://stackoverflow.com/questions/8467424/echo-newline-in-bash-prints-literal-n

EOF

# echo "$multi_lines_comments"

refs

Linux echo command All In One

https://www.cnblogs.com/xgqfrms/p/15408568.html



©xgqfrms 2012-2020

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

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


posted @ 2021-10-13 15:35  xgqfrms  阅读(362)  评论(9编辑  收藏  举报