How to delete history of last 10 commands in shell?

前端 未结 19 2163
孤城傲影
孤城傲影 2021-01-29 18:47

Commands follows

  511  clear
  512  history
  513  history -d 505
  514  history
  515  history -d 507 510 513
  516  history
  517  history -d 509
  518  hist         


        
19条回答
  •  你的背包
    2021-01-29 19:54

    for h in $(seq $(history | tail -1 | awk '{print $1-N}')  $(history | tail -1 | awk '{print $1}') | tac); do history -d $h; done; history -d $(history | tail -1 | awk '{print $1}')
    

    If you want to delete 10 lines then just change the value of N to 10.

提交回复
热议问题