I have a bash script in Linux and i want to clear history of shell that my script executed from it.
I know that history -c
clears current session history, but i want to clear parent session history.
My script is look like this:
#!/bin/bash
# my code
history -c
cat /dev/null > ~/.bash_history
but it doesn't work!
How can i do this?
I try this and it works, but after re switch to root user:
su - root -c "history -c"
su - root -c "cat /dev/null > ~/.bash_history"
history -c
cat /dev/null > ~/.bash_history
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.