Through the source method its working,
my source_file.sh contain
# cat /root/source_file.sh
#!/bin/bash
history -d $1
and my master_file.sh have below lines
# cat /root/master_file.sh
#!/bin/bash
if [ "$1" == "" ]; then
echo -e "Enter command number from history(syntax: source script_name.sh xxxx)"
else
source /root/source_file.sh && echo -e "Line number $1 removed successfully"
fi
we can test the script now,
# source /root/master_file.sh
Enter command number from history(syntax: source script_name.sh xxxx)
okay lets add the line number
# history | tail -n 10
1193 grep disable /etc/sysconfig/selinux
1194 grep enforce /etc/sysconfig/selinux
1195 sestatus
1196 arch
1197 uname -r
1198 uname -a
1199 history
1200 history | tail -n 10
1201 pwd
1202 history | tail -n 10
Lets remove the line 1196
# source /root/master_file.sh 1196
Line number 1196 removed successfully
# history | tail -n 10
1194 grep enforce /etc/sysconfig/selinux
1195 sestatus
1196 uname -r
1197 uname -a
1198 history
1199 history | tail -n 10
1200 pwd
1201 history | tail -n 10
1202 source /root/master_file.sh 1196
1203 history | tail -n 10