Hi,
my file has below details and I want remove the # char from only specific line.
#TEST:00:START
#TEST1:01:INPROCESS
#TEST2:02:ABOUTTO
#TEST3:03:COMP
i.e if want remove the # from 2nd line then file to be updated as
#TEST:00:START
TEST1:01:INPROCESS
#TEST2:02:ABOUTTO
#TEST3:03:COMP
please provide the script to do this.
Thanks,
Sandy
rdrtx1
2
try:
awk 'NR==2 {sub("^#","")} 1' infile
or:
sed '2{s/^#//}' infile
sed '2s/^#//' infile
--
@rdrxt1, some seds require a semicolon before the closing brace.
Jotne
4
And if you like to program the line to remove
line=2
awk 'NR==inp {sub("^#","")} 1' inp=line infile
Thanks quick solutions.
if the line number is unknow, will it be posible to update based on the content means TEST or TEST1?
Try:
sed '/TEST1:/s/^#//' file
Jotne
7
awk '/TEST1:/ {sub("^#","")} 1' infile
awk '/TEST:/ {sub("^#","")} 1' infile
The :
is needed so that it selects only TEST
and not TEST1 and TEST
when search for TEST