history | tail -1 | awk '{print $1}'
for h in $(seq 1006 1008 | tac); do history -d $h; done; history -d $(history | tail -1 | awk '{print $1}')
histdel(){
for h in $(seq $1 $2 | tac); do
history -d $h
done
history -d $(history | tail -1 | awk '{print $1}')
}
[18:21:02 jonathag@gb-slo-svb-0221 ~]$ history | tail -n 11
1046 25-04-2016 18:20:47 echo "Command 1"
1047 25-04-2016 18:20:48 echo "Command 2"
1048 25-04-2016 18:20:50 echo "Command 3"
1049 25-04-2016 18:20:51 echo "Command 4"
1050 25-04-2016 18:20:53 echo "Command 5"
1051 25-04-2016 18:20:54 echo "Command 6"
1052 25-04-2016 18:20:56 echo "Command 7"
1053 25-04-2016 18:20:57 echo "Command 8"
1054 25-04-2016 18:21:00 echo "Command 9"
1055 25-04-2016 18:21:02 echo "Command 10"
1056 25-04-2016 18:21:07 history | tail -n 11
[18:21:07 jonathag@gb-slo-svb-0221 ~]$ histdel 1049 1051
[18:21:23 jonathag@gb-slo-svb-0221 ~]$ history | tail -n 8
1046 25-04-2016 18:20:47 echo "Command 1"
1047 25-04-2016 18:20:48 echo "Command 2"
1048 25-04-2016 18:20:50 echo "Command 3"
1049 25-04-2016 18:20:56 echo "Command 7"
1050 25-04-2016 18:20:57 echo "Command 8"
1051 25-04-2016 18:21:00 echo "Command 9"
1052 25-04-2016 18:21:02 echo "Command 10"
1053 25-04-2016 18:21:07 history | tail -n 11
histdeln(){
# Get the current history number
n=$(history | tail -1 | awk '{print $1}')
# Call histdel with the appropriate range
histdel $(( $n - $1 )) $(( $n - 1 ))
}