I have a list of lines in variable (1,3,8,9). That list shows which lines I need to delete from a text file. which function I can use to delete specific lines number?
Thank you so much for your respond
I have a list of lines in variable (1,3,8,9). That list shows which lines I need to delete from a text file. which function I can use to delete specific lines number?
Thank you so much for your respond
# set -vx
lines2del="(1,3,8,9)"
sedCmds=${lines2del//,/d;}
sedCmds=${sedCmds/(/}
sedCmds=${sedCmds/)/}
sedCmds=${sedCmds}d
sed -i "$sedCmds" file
Remove the # before set -vx
to see the debug/trace for each cmd as it is executed.
If you don't really have ( )
(parens) around your data, fix the line2del
variable and remove the second and third sedCmds=
lines.
IHTH