Generate script in bash and save it to location requiring sudo

后端 未结 3 1819
孤街浪徒
孤街浪徒 2021-02-02 08:23

In bash I can create a script with a here-doc like so as per this site: http://tldp.org/LDP/abs/html/abs-guide.html#GENERATESCRIPT

(
cat <<\'EOF\'
#!/bin         


        
3条回答
  •  情话喂你
    2021-02-02 09:10

    This is how I would do it:

    sudo tee "$OUTFILE" > /dev/null <<'EOF'
    foo
    bar
    EOF
    

提交回复
热议问题