为什么不使用这段代码?
#!/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)