Find / Replace
Remove all lines that contain a specific string
To remove any lines that contain a string you will want to use the global search :g and the d flag for delete.
:g/<string>/dExample
I often see where people use the -p flag with the password passed directly into the command when doing mysql queries on servers. This is something that you shouldn't do. I don't want the passwords in the bash history so I remove them.
ls -la
cat ~/.zshrc
mysql -u root -p TeHpASSword
tar -zcf dump.tar.gz dump.sql
mysql -u root -p TeHpASSwordAfter opening in VIM I would do the following:
:g/mysql/dWhich would result in the file contents being:
ls -la
cat ~/.zshrc
tar -zcf dump.tar.gz dump.sqlNow you can just save and close with :wq and now the mysql references are no longer in the history.
Last updated
Was this helpful?