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 @   xgqfrms  阅读(366)  评论(9编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· .NET10 - 预览版1新功能体验(一)
历史上的今天:
2020-10-13 MDN 文档高级操作进阶教程
2020-10-13 Learning Web Performance with MDN
2020-10-13 prefetch vs preload vs prerender vs preconnect All In One
2020-10-13 OAuth 2.0 JWT All In One
2020-10-13 吐槽一下国内用户体验非常不好的一些网站 All In One
2020-10-13 git tag All In One
2020-10-13 React components render order All In One
点击右上角即可分享
微信分享提示