Skip to main content

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}')

This works I have checked .

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.

I think this is the correct and shortest one line code answer to the above query .

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}')

This works I have checked .

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

I think this is the correct and shortest one line code answer to the above query .

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.

Source Link

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}')

This works I have checked .

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

I think this is the correct and shortest one line code answer to the above query .