我是一个 bash 脚本,我有以下内容
CMD="{ head -n1 $DATE.$FROMSTRAT.new && egrep -i \"$SYMS\" $DATE.$FROMSTRAT.new; } > $DATE.$TOSTRAT.new"
echo "Running $CMD"
`$CMD`
Run Code Online (Sandbox Code Playgroud)
当我调用脚本时
Running { head -n1 inputFile.new && egrep -i "X|Y" inputFile.new; } > outputFile.new
script.sh: line 17: {: command not found
Run Code Online (Sandbox Code Playgroud)
但是当我{ head -n1 inputFile.new && egrep -i "X|Y" inputFile.new; } > outputFile.new
在命令行上运行时,它工作正常。
我试图逃避{
没有成功,我该怎么做?
我倾向于从源代码构建二进制文件。我通常的设置如下
$HOME/build -> this gets the sources
$HOME/programs -> this is where the build happen, so where the binaries are
Run Code Online (Sandbox Code Playgroud)
完成后,我将以下内容放入我的 bashrc
export MYNEWBINDIR = $HOME/programs/...
export PATH=$MYNEWBINDIR:$PATH
Run Code Online (Sandbox Code Playgroud)
我的问题是:这是推荐的方式吗?例如,我可以创建一个 local $HOME/bin
,符号链接那里的所有二进制文件,然后将其添加到路径中...