Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8708379
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T04:07:30+00:00 2026-06-13T04:07:30+00:00

I’ve got a sequence of directories 079/af3 100/af4 120/af3 . . . Each ???/af?

  • 0

I’ve got a sequence of directories

079/af3
100/af4
120/af3
  . 
  .
  .

Each ???/af? directory contains a very long file results.stdout. Close to the end of this file, one finds the string

 Normal termination: iterations complete!

if the computation in af3 (resp. af4) was successful, otherwise one or more error messages are written in the file. To avoid having to check each file by hand, I’m writing a script which generates a summary file:

 Massflow        af3      af4 
      079    Success  Failure
      100    Failure  Success
      120    Success  Success
        .      .       .
        .      .       .

So far, I’ve been able to cook up the following:

#!/bin/bash

strlen="9" # want to keep the format flexible, instead than hardcode it
format0="%"$strlen"s %"$strlen"s %"$strlen"s\n"
# write the header of file summary
awk -v format="$format0" ' BEGIN { printf format, "Massflow", "af3", "af4"
                             } ' >> summary


for dir in ??? # loop on all the directories
do
    for j in 3 4 # loop on the two subdirs
    do
    result[$j]=$(tac $dir/af$j/results.stdout | awk '
    /TACOMA:- Normal termination: iterations complete!/ {success = 1; exit}
    END { if (success == 1)
              print "Success"
          else
              print "Failure"
        }')
    done
done
exit 

However, I don’t know how to write the summary file…I’d like to pass the result array to another awk program, but awk doesn’t accept array variables. Any suggestions? Feel free to change the approach or even the tools, if you think my programming style, tools choice or both suck 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T04:07:32+00:00Added an answer on June 13, 2026 at 4:07 am

    First, don’t use tac, because there’s no benefit in reversing the whole file. Just give the files to awk.

    You can omit the second for loop and save the two results and print them afterwards:

    for dir in ??? # loop on all the directories
    do
        for j in 3 4; do
            af[$j]=$(awk '/TACOMA:- Normal termination: iterations complete!/ {success = 1; exit}
                       END { if (success == 1)
                                 print "Success"
                             else
                                 print "Failure"
                       }'  $dir/af$j/results.stdout)
         done
    
         awk -v format="$format0" "BEGIN { printf format, \"$dir\", \"${af[3]}\", \"${af[4]}\"; } " >> summary
    done
    

    From @EdMorton in bash only without awk:

    for dir in ??? # loop on all the directories
    do
        for j in 3 4; do
            if grep -q "TACOMA:- Normal termination: iterations complete!" "$dir/af$j/results.stdout"; then
                af[$j]="Success"
            else
                af[$j]="Failure"
            fi
         done
    
         printf "$format0" "$dir" "${af[3]}" "${af[4]}" >> summary
    done
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have just tried to save a simple *.rtf file with some websites and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Basically, what I'm trying to create is a page of div tags, each has
I've got a string that has curly quotes in it. I'd like to replace
I want use html5's new tag to play a wav file (currently only supported
In my XML file chapters tag has more chapter tag.i need to display chapters
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.