I often find myself testing out a command (e.g.
cat file | awk 'stuff') in the shell and when I'm satisfied with the way it works, I append the command to a script file.
Let's say this is the command I created
cat file.txt | awk -F '|' '$3 == "\"0\""'
How can I quickly echo that to a file without having to escape stuff first and without having to use the mouse?
Is there a way to do something like
echo --verbatim the_command_with_lots_of_quotes_and_everything >> file.sh
cat <<'EOF'\n the_command \n EOF >> file.sh ?