How to delete history of last 10 commands in shell?

前端 未结 19 1817
孤城傲影
孤城傲影 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

    A simple function can kill all by number (though it barfs on errors)

    kill_hist() {
        for i in $(echo $@ | sed -e 's/ /\n/g;' | sort -rn | sed -e 's/\n/ /;')
        do
                history -d $i;
        done
    }
    kill_hist `seq 511 520`
    # or kill a few ranges
    kill_hist `seq 1001 1010` `seq 1200 1201`
    
    0 讨论(0)
提交回复
热议问题