0

How to write the following to a file

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

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

0
1

single quotes to avoid the ! being treated specially:

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.