If a line starts with condition, insert variable after 187th character
Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
I have a .txt file with >10k lines. Some of the lines start with 1,POS,MGC=
or 1,NEG,MGC=
. For these lines, I want to insert a variable after the 187th character on the line while preserving the text after.
So far what I have is
awk 'BEGINFS=OFS=""
if (substr($0,1,10)~"1,...,MGC=")
$187=$variable inputfile > outputfile
which doesn't really work at all.
text-processing
New contributor
add a comment |Â
up vote
1
down vote
favorite
I have a .txt file with >10k lines. Some of the lines start with 1,POS,MGC=
or 1,NEG,MGC=
. For these lines, I want to insert a variable after the 187th character on the line while preserving the text after.
So far what I have is
awk 'BEGINFS=OFS=""
if (substr($0,1,10)~"1,...,MGC=")
$187=$variable inputfile > outputfile
which doesn't really work at all.
text-processing
New contributor
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I have a .txt file with >10k lines. Some of the lines start with 1,POS,MGC=
or 1,NEG,MGC=
. For these lines, I want to insert a variable after the 187th character on the line while preserving the text after.
So far what I have is
awk 'BEGINFS=OFS=""
if (substr($0,1,10)~"1,...,MGC=")
$187=$variable inputfile > outputfile
which doesn't really work at all.
text-processing
New contributor
I have a .txt file with >10k lines. Some of the lines start with 1,POS,MGC=
or 1,NEG,MGC=
. For these lines, I want to insert a variable after the 187th character on the line while preserving the text after.
So far what I have is
awk 'BEGINFS=OFS=""
if (substr($0,1,10)~"1,...,MGC=")
$187=$variable inputfile > outputfile
which doesn't really work at all.
text-processing
text-processing
New contributor
New contributor
New contributor
asked 7 mins ago
erik
61
61
New contributor
New contributor
add a comment |Â
add a comment |Â
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
erik is a new contributor. Be nice, and check out our Code of Conduct.
erik is a new contributor. Be nice, and check out our Code of Conduct.
erik is a new contributor. Be nice, and check out our Code of Conduct.
erik is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f474698%2fif-a-line-starts-with-condition-insert-variable-after-187th-character%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password