![](/img/trans.png)
[英]How to change the desktop wallpaper on linux from within a shell/bash script
[英]how to clear history of shell that a bash script executed from it in linux?
我在 Linux 中有一個 bash 腳本,我想清除我的腳本從它執行的 shell 的歷史記錄。
我知道history -c
清除當前 session 歷史記錄,但我想清除父 session 歷史記錄。
我的腳本是這樣的:
#!/bin/bash
# my code
history -c
cat /dev/null > ~/.bash_history
但它不起作用!
我怎樣才能做到這一點?
我嘗試了這個並且它有效,但是在重新切換到root用戶之后:
su - root -c "history -c"
su - root -c "cat /dev/null > ~/.bash_history"
history -c
cat /dev/null > ~/.bash_history
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.