How to understand the command awk 'for(x=1;x<=NF;x++)if($x~/0.00000/)sub(/0.00000/,++i)1' file
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I'm new in awk so maybe my question might seem very basic but I need some help here, please
Command:
awk 'for(x=1;x<=NF;x++)if($x~/0.00000/)sub(/0.00000/,++i)1'
I know this command will look for "0.00000" in a file and replace it with an incremental number starting from 1. I understood almost everything except for 'x<=NF' and the number 1 at the end "sub(/0.00000/,++i)}1'. Can you enlighten me on these two points, please?
Also, If I want to do the same thing but replacing the match with an incremental number starting from 0, would it be correct to do:
awk 'for(x=0;x<=NF;x++)if($x~/0.00000/)sub(/0.00000/,++i)1' file
awk
New contributor
Zeineb Si Chaib is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |Â
up vote
0
down vote
favorite
I'm new in awk so maybe my question might seem very basic but I need some help here, please
Command:
awk 'for(x=1;x<=NF;x++)if($x~/0.00000/)sub(/0.00000/,++i)1'
I know this command will look for "0.00000" in a file and replace it with an incremental number starting from 1. I understood almost everything except for 'x<=NF' and the number 1 at the end "sub(/0.00000/,++i)}1'. Can you enlighten me on these two points, please?
Also, If I want to do the same thing but replacing the match with an incremental number starting from 0, would it be correct to do:
awk 'for(x=0;x<=NF;x++)if($x~/0.00000/)sub(/0.00000/,++i)1' file
awk
New contributor
Zeineb Si Chaib is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I'm new in awk so maybe my question might seem very basic but I need some help here, please
Command:
awk 'for(x=1;x<=NF;x++)if($x~/0.00000/)sub(/0.00000/,++i)1'
I know this command will look for "0.00000" in a file and replace it with an incremental number starting from 1. I understood almost everything except for 'x<=NF' and the number 1 at the end "sub(/0.00000/,++i)}1'. Can you enlighten me on these two points, please?
Also, If I want to do the same thing but replacing the match with an incremental number starting from 0, would it be correct to do:
awk 'for(x=0;x<=NF;x++)if($x~/0.00000/)sub(/0.00000/,++i)1' file
awk
New contributor
Zeineb Si Chaib is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
I'm new in awk so maybe my question might seem very basic but I need some help here, please
Command:
awk 'for(x=1;x<=NF;x++)if($x~/0.00000/)sub(/0.00000/,++i)1'
I know this command will look for "0.00000" in a file and replace it with an incremental number starting from 1. I understood almost everything except for 'x<=NF' and the number 1 at the end "sub(/0.00000/,++i)}1'. Can you enlighten me on these two points, please?
Also, If I want to do the same thing but replacing the match with an incremental number starting from 0, would it be correct to do:
awk 'for(x=0;x<=NF;x++)if($x~/0.00000/)sub(/0.00000/,++i)1' file
awk
awk
New contributor
Zeineb Si Chaib is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Zeineb Si Chaib is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Zeineb Si Chaib is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked 1 min ago


Zeineb Si Chaib
1
1
New contributor
Zeineb Si Chaib is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Zeineb Si Chaib is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Zeineb Si Chaib is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |Â
add a comment |Â
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Zeineb Si Chaib is a new contributor. Be nice, and check out our Code of Conduct.
Zeineb Si Chaib is a new contributor. Be nice, and check out our Code of Conduct.
Zeineb Si Chaib is a new contributor. Be nice, and check out our Code of Conduct.
Zeineb Si Chaib 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%2f474905%2fhow-to-understand-the-command-awk-forx-1x-nfxifx-0-00000-sub-0-00%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