Skip to content

Instantly share code, notes, and snippets.

@todd-dsm
Created May 6, 2021 17:51
Show Gist options
  • Save todd-dsm/53f769165b8e3cb14a625667a85f44c4 to your computer and use it in GitHub Desktop.
Save todd-dsm/53f769165b8e3cb14a625667a85f44c4 to your computer and use it in GitHub Desktop.
conditionally find something in a file
#!/usr/bin/env bash
myFile='/tmp/file.yaml'
if ! grep thing $myFile; then
echo "adding thing!"
# code to add thing
else
echo "thing already exists" # no-op, report only
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment