Conditional Statement in Linux,Shell [closed]

Clash Royale CLAN TAG#URR8PPP
up vote
-3
down vote
favorite
Find a string and print nth field (value) from that string. If the value of nth field matches with particular value then go to the next command.
Eg.
Item Value Type
MF 1 No
RMSF 1 No
MDSP 3 No
RMMDSP 3 No
In my file, the above table occurs more than once. But only a few times that MF, RMSF, MSDP and RMMSDP have values YES in their corresponding 3rd column. I want to write a code in the following manner.
Find
MFand print the corresponding 3rd column and only if it is equal toYESgo to step 2, else exit the code.Find
RMSFand print the corresponding 3rd column and only if it is equal toYESgo to step 3, else exit the code.Find
MDSPand print the corresponding 3rd column and only if it is equal toYESgo to step 4, else exit the code.Find
RMMDSPand print the corresponding 3rd column and only if it is equal toYESgo to step 5, else exit the code.Now go to the string
Standard coordinatesand print the 5th line from there until you find the stringRotation.
Kindly note that the string Standard coordinates occur many times in the file. But I want to go only that Standard coordinates which occurs after satisfying all the 4 conditions mentioned above are met. And now. the 5th line from the the string Standard coordinates can be printed until the word Rotation.
Please let me know if I am not clear or you need any further information.
Thank you
linux shell-script
closed as unclear what you're asking by Kusalananda, Goro, roaima, Jeff Schaller, Vlastimil Sep 28 at 11:20
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, itâÂÂs hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
 |Â
show 10 more comments
up vote
-3
down vote
favorite
Find a string and print nth field (value) from that string. If the value of nth field matches with particular value then go to the next command.
Eg.
Item Value Type
MF 1 No
RMSF 1 No
MDSP 3 No
RMMDSP 3 No
In my file, the above table occurs more than once. But only a few times that MF, RMSF, MSDP and RMMSDP have values YES in their corresponding 3rd column. I want to write a code in the following manner.
Find
MFand print the corresponding 3rd column and only if it is equal toYESgo to step 2, else exit the code.Find
RMSFand print the corresponding 3rd column and only if it is equal toYESgo to step 3, else exit the code.Find
MDSPand print the corresponding 3rd column and only if it is equal toYESgo to step 4, else exit the code.Find
RMMDSPand print the corresponding 3rd column and only if it is equal toYESgo to step 5, else exit the code.Now go to the string
Standard coordinatesand print the 5th line from there until you find the stringRotation.
Kindly note that the string Standard coordinates occur many times in the file. But I want to go only that Standard coordinates which occurs after satisfying all the 4 conditions mentioned above are met. And now. the 5th line from the the string Standard coordinates can be printed until the word Rotation.
Please let me know if I am not clear or you need any further information.
Thank you
linux shell-script
closed as unclear what you're asking by Kusalananda, Goro, roaima, Jeff Schaller, Vlastimil Sep 28 at 11:20
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, itâÂÂs hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
Hello @Rag. Kindly, would you please clarify what is step 5 ?
â Goro
Sep 28 at 9:54
1
The example data provided does not contain the stringsStandard coordinatesandRotation.
â Kusalananda
Sep 28 at 9:54
2
Any attempts / ideas / thoughts from your side?
â RudiC
Sep 28 at 9:55
2
You should be able to edit the question and add the relevant data there. Data in comments is pretty much useless due to the (non-)formatting.
â Kusalananda
Sep 28 at 10:34
1
@Rag You keep defacing your question with bad formatting. Use the formatting tools to do it correctly. It's unreadable at the moment. I also wonder what the "thousands of lines removed" contains and how to distinguish these from the lines that you actually want to get. I notice in particular that there may be thousands of lines betweenStandard coordinatesand the lines that you'd like to get. I will leave thes question until later when the formulation has stabilised.
â Kusalananda
Sep 28 at 11:02
 |Â
show 10 more comments
up vote
-3
down vote
favorite
up vote
-3
down vote
favorite
Find a string and print nth field (value) from that string. If the value of nth field matches with particular value then go to the next command.
Eg.
Item Value Type
MF 1 No
RMSF 1 No
MDSP 3 No
RMMDSP 3 No
In my file, the above table occurs more than once. But only a few times that MF, RMSF, MSDP and RMMSDP have values YES in their corresponding 3rd column. I want to write a code in the following manner.
Find
MFand print the corresponding 3rd column and only if it is equal toYESgo to step 2, else exit the code.Find
RMSFand print the corresponding 3rd column and only if it is equal toYESgo to step 3, else exit the code.Find
MDSPand print the corresponding 3rd column and only if it is equal toYESgo to step 4, else exit the code.Find
RMMDSPand print the corresponding 3rd column and only if it is equal toYESgo to step 5, else exit the code.Now go to the string
Standard coordinatesand print the 5th line from there until you find the stringRotation.
Kindly note that the string Standard coordinates occur many times in the file. But I want to go only that Standard coordinates which occurs after satisfying all the 4 conditions mentioned above are met. And now. the 5th line from the the string Standard coordinates can be printed until the word Rotation.
Please let me know if I am not clear or you need any further information.
Thank you
linux shell-script
Find a string and print nth field (value) from that string. If the value of nth field matches with particular value then go to the next command.
Eg.
Item Value Type
MF 1 No
RMSF 1 No
MDSP 3 No
RMMDSP 3 No
In my file, the above table occurs more than once. But only a few times that MF, RMSF, MSDP and RMMSDP have values YES in their corresponding 3rd column. I want to write a code in the following manner.
Find
MFand print the corresponding 3rd column and only if it is equal toYESgo to step 2, else exit the code.Find
RMSFand print the corresponding 3rd column and only if it is equal toYESgo to step 3, else exit the code.Find
MDSPand print the corresponding 3rd column and only if it is equal toYESgo to step 4, else exit the code.Find
RMMDSPand print the corresponding 3rd column and only if it is equal toYESgo to step 5, else exit the code.Now go to the string
Standard coordinatesand print the 5th line from there until you find the stringRotation.
Kindly note that the string Standard coordinates occur many times in the file. But I want to go only that Standard coordinates which occurs after satisfying all the 4 conditions mentioned above are met. And now. the 5th line from the the string Standard coordinates can be printed until the word Rotation.
Please let me know if I am not clear or you need any further information.
Thank you
linux shell-script
linux shell-script
edited Sep 28 at 11:18
asked Sep 28 at 9:45
Rag
43
43
closed as unclear what you're asking by Kusalananda, Goro, roaima, Jeff Schaller, Vlastimil Sep 28 at 11:20
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, itâÂÂs hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
closed as unclear what you're asking by Kusalananda, Goro, roaima, Jeff Schaller, Vlastimil Sep 28 at 11:20
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, itâÂÂs hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
Hello @Rag. Kindly, would you please clarify what is step 5 ?
â Goro
Sep 28 at 9:54
1
The example data provided does not contain the stringsStandard coordinatesandRotation.
â Kusalananda
Sep 28 at 9:54
2
Any attempts / ideas / thoughts from your side?
â RudiC
Sep 28 at 9:55
2
You should be able to edit the question and add the relevant data there. Data in comments is pretty much useless due to the (non-)formatting.
â Kusalananda
Sep 28 at 10:34
1
@Rag You keep defacing your question with bad formatting. Use the formatting tools to do it correctly. It's unreadable at the moment. I also wonder what the "thousands of lines removed" contains and how to distinguish these from the lines that you actually want to get. I notice in particular that there may be thousands of lines betweenStandard coordinatesand the lines that you'd like to get. I will leave thes question until later when the formulation has stabilised.
â Kusalananda
Sep 28 at 11:02
 |Â
show 10 more comments
Hello @Rag. Kindly, would you please clarify what is step 5 ?
â Goro
Sep 28 at 9:54
1
The example data provided does not contain the stringsStandard coordinatesandRotation.
â Kusalananda
Sep 28 at 9:54
2
Any attempts / ideas / thoughts from your side?
â RudiC
Sep 28 at 9:55
2
You should be able to edit the question and add the relevant data there. Data in comments is pretty much useless due to the (non-)formatting.
â Kusalananda
Sep 28 at 10:34
1
@Rag You keep defacing your question with bad formatting. Use the formatting tools to do it correctly. It's unreadable at the moment. I also wonder what the "thousands of lines removed" contains and how to distinguish these from the lines that you actually want to get. I notice in particular that there may be thousands of lines betweenStandard coordinatesand the lines that you'd like to get. I will leave thes question until later when the formulation has stabilised.
â Kusalananda
Sep 28 at 11:02
Hello @Rag. Kindly, would you please clarify what is step 5 ?
â Goro
Sep 28 at 9:54
Hello @Rag. Kindly, would you please clarify what is step 5 ?
â Goro
Sep 28 at 9:54
1
1
The example data provided does not contain the strings
Standard coordinates and Rotation.â Kusalananda
Sep 28 at 9:54
The example data provided does not contain the strings
Standard coordinates and Rotation.â Kusalananda
Sep 28 at 9:54
2
2
Any attempts / ideas / thoughts from your side?
â RudiC
Sep 28 at 9:55
Any attempts / ideas / thoughts from your side?
â RudiC
Sep 28 at 9:55
2
2
You should be able to edit the question and add the relevant data there. Data in comments is pretty much useless due to the (non-)formatting.
â Kusalananda
Sep 28 at 10:34
You should be able to edit the question and add the relevant data there. Data in comments is pretty much useless due to the (non-)formatting.
â Kusalananda
Sep 28 at 10:34
1
1
@Rag You keep defacing your question with bad formatting. Use the formatting tools to do it correctly. It's unreadable at the moment. I also wonder what the "thousands of lines removed" contains and how to distinguish these from the lines that you actually want to get. I notice in particular that there may be thousands of lines between
Standard coordinates and the lines that you'd like to get. I will leave thes question until later when the formulation has stabilised.â Kusalananda
Sep 28 at 11:02
@Rag You keep defacing your question with bad formatting. Use the formatting tools to do it correctly. It's unreadable at the moment. I also wonder what the "thousands of lines removed" contains and how to distinguish these from the lines that you actually want to get. I notice in particular that there may be thousands of lines between
Standard coordinates and the lines that you'd like to get. I will leave thes question until later when the formulation has stabilised.â Kusalananda
Sep 28 at 11:02
 |Â
show 10 more comments
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Hello @Rag. Kindly, would you please clarify what is step 5 ?
â Goro
Sep 28 at 9:54
1
The example data provided does not contain the strings
Standard coordinatesandRotation.â Kusalananda
Sep 28 at 9:54
2
Any attempts / ideas / thoughts from your side?
â RudiC
Sep 28 at 9:55
2
You should be able to edit the question and add the relevant data there. Data in comments is pretty much useless due to the (non-)formatting.
â Kusalananda
Sep 28 at 10:34
1
@Rag You keep defacing your question with bad formatting. Use the formatting tools to do it correctly. It's unreadable at the moment. I also wonder what the "thousands of lines removed" contains and how to distinguish these from the lines that you actually want to get. I notice in particular that there may be thousands of lines between
Standard coordinatesand the lines that you'd like to get. I will leave thes question until later when the formulation has stabilised.â Kusalananda
Sep 28 at 11:02