0

I have a text file which has blocks like

dir1/dir2/dir3/name_run_number1:
line1_run_number1_part1
line2_run_number1_part2
line3_run_number1_part3...

Each block is separated with a blank line and there is the ":" in the "header" of each one while each block has a unique "number1" after "run_" suffix which is also present in the lines inside the block

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

Thanks

  • bash is a command line interpreter, it doesn't do anything but call and orchestrate commands. Some of them can be sed, awk, python, perl... So "Any bash or python" makes little sense. – Stéphane Chazelas Jan 24 '15 at 17:55
  • Give longer example of input file and also desire output, it is hard to understand what do you want to achieve from given description. – jimmij Jan 24 '15 at 18:28
0

Based on given example of input|output decision can be:

awk -F_ '
    /:/ {
        for (i=0;i<20;i++) {
            getline
            sub("chunk","",$7)
            while ( i != +$7 ) {
                print "for " $2 " and " $5"_"$6 " you are missing chunk " i
                i++
                if (i>20)
                    break
                }
            }
    }' text.file
  • This does not work as expected...for instance sed -n '/number1:/,+20 {/:/d;/part[0-9]*$/! s/.*/your_message/p}' returns just "your_message" but nothing in case a "part" is missing and exactly which one – Just_Newbie Jan 24 '15 at 18:27
  • @Just_Newbie Therefore I ask for example input and desired output. – Costas Jan 24 '15 at 18:49
  • Input example Output/13TeV_modelA_1300_100/13TeV_modelA_1300_100_run_30756: 13TeV_modelA_1300_100_run_30756_chunk0 <br/> 13TeV_modelA_1300_100_run_30756_chunk1 <br/> 13TeV_modelA_1300_100_run_30756_chunk10 13TeV_modelA_1300_100_run_30756_chunk11 13TeV_modelA_1300_100_run_30756_chunk12 13TeV_modelA_1300_100_run_30756_chunk13 13TeV_modelA_1300_100_run_30756_chunk14 13TeV_modelA_1300_100_run_30756_chunk15 13TeV_modelA_1300_100_run_30756_chunk16 13TeV_modelA_1300_100_run_30756_chunk17 13TeV_modelA_1300_100_run_30756_chunk18 clearly in this, some "chunks" are missing – Just_Newbie Jan 24 '15 at 19:52
  • the output could be any kind of "report" ie like for modelA and run_30756 you are missing chunk X <br/> – Just_Newbie Jan 24 '15 at 19:54
  • @Just_Newbie Have edited. Please check for real data. – Costas Jan 24 '15 at 21:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.