bash

syntax error near unexpected token `do' when run with sudo

雨燕双飞 提交于 2021-02-07 03:27:42
问题 From here: http://www.sat.dundee.ac.uk/psc/watchdog/watchdog-testing.html for n in $(seq 1 60); do echo $n; sleep 1; sync; done I get: :~$ sudo for n in $(seq 1 60); do echo $n; sleep 1; sync; done bash: syntax error near unexpected token `do' 回答1: The shell parses the command line and because for looks like an argument to sudo , you basically get a do without a for . To fix it, run the loop in a subshell, either as a separate script, or like this; sudo sh -c 'for n in $(seq 1 60); do echo "

syntax error near unexpected token `do' when run with sudo

痴心易碎 提交于 2021-02-07 03:21:40
问题 From here: http://www.sat.dundee.ac.uk/psc/watchdog/watchdog-testing.html for n in $(seq 1 60); do echo $n; sleep 1; sync; done I get: :~$ sudo for n in $(seq 1 60); do echo $n; sleep 1; sync; done bash: syntax error near unexpected token `do' 回答1: The shell parses the command line and because for looks like an argument to sudo , you basically get a do without a for . To fix it, run the loop in a subshell, either as a separate script, or like this; sudo sh -c 'for n in $(seq 1 60); do echo "

Bash script throws syntax errors when the 'extglob' option is set inside a subshell or function

家住魔仙堡 提交于 2021-02-07 02:52:30
问题 Problem The execution of a Bash script fails with the following error message when the 'extglob' option is set inside a subshell: /tmp/foo.sh: line 7: syntax error near unexpected token `(' #!/usr/bin/env bash set -euo pipefail ( shopt -s extglob for f in ?(.)!(|+(.)|vendor); do echo "$f" done ) It fails in the same manner inside a function: #!/usr/bin/env bash set -euo pipefail list_no_vendor () { shopt -s extglob for f in ?(.)!(|+(.)|vendor); do echo "$f" done } list_no_vendor Investigation

趁webpack5还没出,先升级成webpack4吧

假如想象 提交于 2021-02-06 21:29:23
上一次将webpack1升级到3,也仅是 半年前 ,前端工具发展变化太快了,如今webpack4已经灰常稳定,传说性能提升非常高,值得升级。 一直用着的webpack3越来越慢,一分多钟的编译时间简直不能忍,升级之后在几个系统和几台电脑上评测,平均提高了7-9倍,生产模式的最突出 升级之后完整的 webpack4项目配置DEMO 已经放到Github中,欢迎围观 star ~ 关于如何升级到V4已经有很多优秀的文章,结合官方文档你也可以升级起来 本文仅说说本次升级主要做的改动优化点,或者坑 webpack4升级完全指南 webpack4 changelog React 16 加载优化性能 1. 移除了commonchunk插件,改用了optimization属性进行更加灵活的配置 ,不过稍微不注意,就会有问题,如 Uncaught Error: only one instance of babel-polyfill is allowed 如果一个页面存在多个entry入口文件,即页面引用了多个模块时,默认会产生多个独立的common区 所以记得将common设为公有,如 optimization: { runtimeChunk: { name: 'common' }, 2. 默认的生产模式noEmitOnError为true,导致代码检查工具报错之后无法将检查结果写入文件中

ANSI questions: “\x1B[?25h” and “\x1BE”

独自空忆成欢 提交于 2021-02-06 19:56:56
问题 What does "\x1B[?25h" do? How is "\x1BE" different from "\n" ? According to http://ascii-table.com/ansi-escape-sequences-vt-100.php it " moves to next line "? Seems like that's what "\n" does? I tried echo "xxx\nxxx\n" and echo "xxx\x1BExxx\n" in PHP and they both output the same thing. Any ideas? Thanks! 回答1: These are ANSI escape sequences (also known as VT100 codes) are an early standardisation of control codes pre-dating ASCII. The escape sequence \x1BE , or Esc + E , is NEL or "Next line

Is wget or similar programs always available on POSIX systems?

心不动则不痛 提交于 2021-02-06 14:58:27
问题 Is there an HTTP client like wget/lynx/GET that is distributed by default in POSIX or *nix operating systems that could be used for maximum portability? I know most systems have wget or lynx installed, but I seem to remember installing some Ubuntu server systems using default settings and they had neither wget or lynx installed in the base package. I am writing a shell script for Linux (and probably Mac) to install a piece of software onto the computer. To prevent having to distribute a

Bash variables: case sensitive or not?

点点圈 提交于 2021-02-06 14:21:38
问题 Is bash shell scripting case sensitive? Is variable date the same as DATE ? 回答1: Yes, it is case sensitive, just like the rest of UNIX. $date and $DATE are two different variables. makefile and Makefile are two different files. -h and -H are two distinct flags (usually). 来源: https://stackoverflow.com/questions/15571706/bash-variables-case-sensitive-or-not

Bash variables: case sensitive or not?

霸气de小男生 提交于 2021-02-06 14:21:37
问题 Is bash shell scripting case sensitive? Is variable date the same as DATE ? 回答1: Yes, it is case sensitive, just like the rest of UNIX. $date and $DATE are two different variables. makefile and Makefile are two different files. -h and -H are two distinct flags (usually). 来源: https://stackoverflow.com/questions/15571706/bash-variables-case-sensitive-or-not

Get AWS EMR Cluster ID from Name

半城伤御伤魂 提交于 2021-02-06 13:59:38
问题 AWS CLI command aws emr list-clusters returns the following json. Is there a way through bash or groovy that I can use the Name to get the Id? I can't just use the Id becauseI am deleting clusters and rebuilding them with only the same name. So I know the name of the cluster is "my-cluster" and I would like to use it somehow to get the Id of the cluster. End case is I actually want the Master public DNS of the cluster. { "Clusters": [ { "Status": { "Timeline": { "ReadyDateTime": 1433200405

Get AWS EMR Cluster ID from Name

我的未来我决定 提交于 2021-02-06 13:57:09
问题 AWS CLI command aws emr list-clusters returns the following json. Is there a way through bash or groovy that I can use the Name to get the Id? I can't just use the Id becauseI am deleting clusters and rebuilding them with only the same name. So I know the name of the cluster is "my-cluster" and I would like to use it somehow to get the Id of the cluster. End case is I actually want the Master public DNS of the cluster. { "Clusters": [ { "Status": { "Timeline": { "ReadyDateTime": 1433200405