0

How to write the following to a file

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

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

Kusalananda
  • 320,670
  • 36
  • 633
  • 936
clarkk
  • 1,727
  • 6
  • 31
  • 43

1 Answers1

1

single quotes to avoid the ! being treated specially:

printf '*\n!.gitignore\n' > $datadir/.gitignore
SuperStormer
  • 173
  • 1
  • 13