0

How to write the following to a file

printf "*\n!.gitignore\n" > $datadir/.gitignore

-bash: !.gitignore\n: event not found

Kusalananda
  • 333,661
clarkk
  • 1,837

1 Answers1

1

single quotes to avoid the ! being treated specially:

printf '*\n!.gitignore\n' > $datadir/.gitignore