Conditional Statement in Linux,Shell [closed]

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
-3
down vote

favorite
1












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.



  1. Find MF and print the corresponding 3rd column and only if it is equal to YES go to step 2, else exit the code.


  2. Find RMSF and print the corresponding 3rd column and only if it is equal to YES go to step 3, else exit the code.


  3. Find MDSP and print the corresponding 3rd column and only if it is equal to YES go to step 4, else exit the code.


  4. Find RMMDSP and print the corresponding 3rd column and only if it is equal to YES go to step 5, else exit the code.


  5. Now go to the string Standard coordinates and print the 5th line from there until you find the string Rotation.


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
enter image description here










share|improve this 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 strings Standard coordinates and Rotation.
    – 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 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














up vote
-3
down vote

favorite
1












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.



  1. Find MF and print the corresponding 3rd column and only if it is equal to YES go to step 2, else exit the code.


  2. Find RMSF and print the corresponding 3rd column and only if it is equal to YES go to step 3, else exit the code.


  3. Find MDSP and print the corresponding 3rd column and only if it is equal to YES go to step 4, else exit the code.


  4. Find RMMDSP and print the corresponding 3rd column and only if it is equal to YES go to step 5, else exit the code.


  5. Now go to the string Standard coordinates and print the 5th line from there until you find the string Rotation.


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
enter image description here










share|improve this 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 strings Standard coordinates and Rotation.
    – 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 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












up vote
-3
down vote

favorite
1









up vote
-3
down vote

favorite
1






1





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.



  1. Find MF and print the corresponding 3rd column and only if it is equal to YES go to step 2, else exit the code.


  2. Find RMSF and print the corresponding 3rd column and only if it is equal to YES go to step 3, else exit the code.


  3. Find MDSP and print the corresponding 3rd column and only if it is equal to YES go to step 4, else exit the code.


  4. Find RMMDSP and print the corresponding 3rd column and only if it is equal to YES go to step 5, else exit the code.


  5. Now go to the string Standard coordinates and print the 5th line from there until you find the string Rotation.


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
enter image description here










share|improve this question















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.



  1. Find MF and print the corresponding 3rd column and only if it is equal to YES go to step 2, else exit the code.


  2. Find RMSF and print the corresponding 3rd column and only if it is equal to YES go to step 3, else exit the code.


  3. Find MDSP and print the corresponding 3rd column and only if it is equal to YES go to step 4, else exit the code.


  4. Find RMMDSP and print the corresponding 3rd column and only if it is equal to YES go to step 5, else exit the code.


  5. Now go to the string Standard coordinates and print the 5th line from there until you find the string Rotation.


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
enter image description here







linux shell-script






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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 strings Standard coordinates and Rotation.
    – 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 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
















  • 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 coordinates and Rotation.
    – 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 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















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















active

oldest

votes






















active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes

Popular posts from this blog

How to check contact read email or not when send email to Individual?

Bahrain

Postfix configuration issue with fips on centos 7; mailgun relay