heredoc in cat & bash

https://en.wikipedia.org/wiki/Here_document

cat:

cat > outfile.txt <<EOF
>some text
>to save
>EOF

 

source: https://stackoverflow.com/questions/17115664/can-linux-cat-command-be-used-for-writing-text-to-file

 

bash:

<< COMMENT
multi
        line
                comment

COMMENT

for i in `seq 1 20`; do
        echo $i
done

 

来源:https://linuxize.com/post/bash-heredoc/

 

posted @ 2024-03-28 14:36  profesor  阅读(9)  评论(0)    收藏  举报