Created
April 19, 2013 00:16
-
-
Save flacodirt/5417203 to your computer and use it in GitHub Desktop.
Clear bash history of any lines matching keyword
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
echo '# @author brockhensley' | |
echo '# @version 1.0.0' | |
echo '# @date Last updated April 18th 2013' | |
echo '# @link brockhensley.com' | |
if [ -z "$@" ] | |
then | |
echo '#' | |
echo '# Enter search string to clear from history as parameter' | |
echo '#' | |
echo '# Example: ./clearhistory.sh anythingwiththisword' | |
echo '#' | |
exit 0 | |
fi | |
for var in "$@" | |
do | |
grep -v $var "$HISTFILE" > /tmp/history | |
mv /tmp/history "$HISTFILE" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment