Cat+EOF
Sometimes the we need to use the shell
commands to do something, in order to do the job more convenience.
If we want to create the file under the file system, we can input the command like below to create the file we want to create and add the some contents to the file.
Command
➜ rust git:(master) ✗ cat > src/sorting/cocktail_shaker_sort.rs <<EOF
heredoc> /// cocktail shaker sort
heredoc> EOF
If we need to add the new content but do not want to replace the exist content, we need to use >>
which mean append
.
Command
➜ rust git:(master) ✗ cat >> src/sorting/cocktail_shaker_sort.rs <<EOF
heredoc> /// It's an extension of bubble sort.
heredoc> EOF