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

  • Home
  • SEARCH
  • 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 9020307
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:59:04+00:00 2026-06-16T04:59:04+00:00

I have a csh script in which I access several header files to extract

  • 0

I have a csh script in which I access several header files to extract xmin, ymin co-ordinates of various bounding boxes. Is there a simple way of finding minx, maxx, miny maxy from an echo piped to something such as awk. Eg

set minx=`echo $x1\t$x2 | awk {something}`

set maxx = `echo $x1\t$x2 | awk {something else}

I doubt awk is the best way to go and am unsure what is. Here is a bit of my code:

   set bb1 = `label_file -g "bounding box[0]" r$start_roi`

@ bb1_x = $bb1[1]
@ bb1_y = 1023 - $bb1[4]
@ bb1_h = $bb1[4] - $bb1[2]
@ bb1_w = $bb1[3] - $bb1[1]

This will return the xmin, ymin width and height of a rectangular region of interest. I will tweak and repeat the above code to find the same parameters of a second region.

What I would then like to do is find the global xmin, ymin, xmax and ymax in order to define a larger rectangle that completely encompasses the smaller 2.

i.e set xmin to be the smaller number from $bb1[1] and $bb2[1]
set xmax to be the larger from $bb1[3] and $bb2[3]

etc

thanks

  • 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-16T04:59:05+00:00Added an answer on June 16, 2026 at 4:59 am

    This will print the min and max values given a pipe or file or numbers:

    awk '{
       min = ($0 =< min ? $0 : min)
       max = ($0 >= max ? $0 : max)
    }
    END {
       print min, max
    }'
    

    If that’s not what you want, provide some sample input and expected output.

    You are almost certainly approaching your larger task in completely the wrong way by parsing files in (c)shell and invoking awk to do arithmetic. awk was designed to parse text files.

    EDIT: based on this code segment from your updated question:

    set bb1 = `label_file -g "bounding box[0]" r$start_roi`
    @ bb1_x = $bb1[1]
    @ bb1_y = 1023 - $bb1[4]
    @ bb1_h = $bb1[4] - $bb1[2]
    @ bb1_w = $bb1[3] - $bb1[1]
    

    and assuming “label_file” is some command that outputs 4 space-separated numbers, you could do that as:

    label_file -g "bounding box[0]" "r$start_roi" |
    awk '{
       bb1_x = $1
       bb1_y = 1023 - $4
       bb1_h = $4 - $2
       bb1_w = $3 - $1
    }'
    

    You say you have a second region too. Let’s assume “$start_roi” is the argument for label_file that changes. Then you could do something like:

    ( label_file -g "bounding box[0]" "r$start_roi";
      label_file -g "bounding box[0]" "r$other_roi" ) |
    awk '{
       bb1_x[NR] = $1
       bb1_y[NR] = 1023 - $4
       bb1_h[NR] = $4 - $2
       bb1_w[NR] = $3 - $1
    }'
    

    and at that point bbl_x[1] will hold the X values for the start_roi box while bbl_x[2] will hold the X values for the other_roi box. You can see that with:

    ( label_file -g "bounding box[0]" "r$start_roi";
      label_file -g "bounding box[0]" "r$other_roi" ) |
    awk '{
       bb1_x[NR] = $1
       bb1_y[NR] = 1023 - $4
       bb1_h[NR] = $4 - $2
       bb1_w[NR] = $3 - $1
    }
    END {
       for (i=1; i<=NR; i++) {
          print i, bbl_x[i], bbl_y[i], bbl_h[i], bbl_w[i]
       }
    }'
    

    If you need help figuring out what to do from there, let us know.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a csh script and no matter what I do it never echoes
I have a C shell script that does something like this: #!/bin/csh gcc example.c
So I have .csh script generate.csh I want to call another .csh script from
How to extract filename from the path; i have a list of files. I'm
Is there a csh script/command to list all the files in source source tree
I have a csh script, my goal is to read an ini config file
I have a csh script (although I can change languages if it has any
have written this little class, which generates a UUID every time an object of
Have a procedure which looks like Procedure TestProc(TVar1, TVar2 : variant); Begin TVar1 :=
Have deployed numerous report parts which reference the same view however one of them

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.