小编p4x*_*p4x的帖子

bash脚本:echo >>返回错误"没有这样的文件或目录"

为什么不使用这段代码?

#!/bin/bash

test="~/.test"

function fn_append () {

    echo "check vars: $1  ···  ${1} ··· $2"
    echo "check comm: echo \"$2\" >> $1"
        #this returns "No such file or directory"
    echo $2 >> $1
    echo $2 >> ${1}
    echo $2 >> "$1"
        #this creates file named $1
    echo $2 >> '$1'
        #this works (but it isn't enough)
    echo $2 >> ~/.test
        #this is the command Im trying to create.
    #echo "alias ll='ls -lstra'" >> ~/.test
}

fn_append ${test} "alias ll='ls -lstra'" …
Run Code Online (Sandbox Code Playgroud)

bash shell append echo

2
推荐指数
1
解决办法
8166
查看次数

标签 统计

append ×1

bash ×1

echo ×1

shell ×1