Skip to content

Instantly share code, notes, and snippets.

@jnovack
Created July 24, 2017 23:44
Show Gist options
  • Save jnovack/40222c542999a1e3b98956527ba43108 to your computer and use it in GitHub Desktop.
Save jnovack/40222c542999a1e3b98956527ba43108 to your computer and use it in GitHub Desktop.
append_once()
#!/bin/bash
function append_once() {
while read data; do
grep -q "$data" $1 || echo "$data" >> $1
done
}
append_once ~/.bashrc <<EOF
echo 'This line is only written once.'
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment