Extract info and find/count strings from blocks inside text file
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Each block is separated with a blank line and there is the ":" in the "header" of each one while each block carries the same "number1" after "run_" suffix
What I want to do is for each block, extract the "number1" as shown in the first line and then for the lines below count from 1-20 and give a message if a "partX" line is missing. Any bash or python would be fine
Help us to help you. You gave a sample input file (that's good) and some words (also good). Construct a sample output file which corresponds to your sample input and post it here. With "Before and After" examples we can better understand your needs and also judge if our proposed solution fills those needs.
Well, if I had something more specific, then I could write the code my self wouldnt I ? I am new to all these, so if you can provide any code example would be great...
Well, if I had something more specific, then I could write the code my self wouldnt I ? I am new to all these, so if you can provide any code example would be great...
You are unwilling or unable to provide the requested sample. Therefore I bow out of this thread. Maybe someone else will step in to respond.
Well, if I had something more specific, then I could write the code my self wouldnt I ? I am new to all these, so if you can provide any code example would be great...
I hate to tell you, but if you want this program then you are going to HAVE TO write it yourself. We will be happy to HELP you, but we aren't going to write your scripts for you. Read both the LQ Rules and the "Question Guidelines" link in my posting signature.
Again, as danielbmartin asked, provide at least a sample of what you want the output to look like. Write it manually if need be, and you will also have to provide us what YOU have written/tried on your own, and tell us where you're stuck. There are thousands of very easily found bash scripting tutorials you can find with a brief Google search...there is one on my posting signature, and the ones on TLDP are excellent, and all have samples. http://www.tldp.org/ http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html
Show effort of your own, and don't ask people to do things for you. You will *NEVER* learn how to do anything if you keep asking others to do it for you.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.