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 6769209
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:09:57+00:00 2026-05-26T15:09:57+00:00

I am running bash scripts on windows using a msys and mingw environment. I

  • 0

I am running bash scripts on windows using a msys and mingw environment. I have seem to have an issue where using a command like ‘cut’ or sed’ causes an overhead for each call. I’m not sure if this is an effect of windows running .exe’s or what. anyways here is my code:

SOMETHING=`m6811-elf-readelf.exe -l "${TARGET_BASENAME}.elf" | sed '1,/Type / d' | sed '1,/^$/!d'`

echo "$SOMETHING" | while read -r line; do 
    # MEMORY_ADDRESSES=`echo $line | sed -ne 's/LOAD[^0-9a-z]*0x\([^ ]*\) 0x\([^ ]*\) 0x\([^ ]*\) 0x\([^ ]*\) 0x\([^ ]*\) .*/\1 \2 \3 \4 \5/p;'`
     OFFSET=`echo "$line" | cut -f12 -d\ `
     VIRTADDR=`echo "$line" | cut -f13 -d\ `
     PHYSADDR=`echo "$line" | cut -f14 -d\ `
     FILESIZE=`echo "$line" | cut -f15 -d\ `
     MEMSIZE=`echo "$line" | cut -f16 -d\ `
     echo $OFFSET $VIRTADDR $PHYSADDR $FILESIZE $MEMSIZE 
done

I would like to get this running as fast as possible. I thought that the sed line was slowing me down, so I removed it and I am just using cut. For every cut line that I use, this code is much slower.

The contents of the SOMTHING variable are:

  LOAD           0x000000 0x00000000 0x00000000 0x00680 0x00680 RW  0x1000
  LOAD           0x001100 0x00002100 0x00002100 0x00000 0x0005a R   0x1000
  LOAD           0x00115a 0x0000215a 0x0000215a 0x00615 0x00669 RWE 0x1000
  LOAD           0x002000 0x00010000 0x00008000 0x00056 0x00056 R E 0x1000
  LOAD           0x003000 0x00018000 0x00028000 0x03ffe 0x03ffe R E 0x1000
  LOAD           0x007000 0x0001c000 0x00038000 0x03e60 0x03e60 R E 0x1000
  LOAD           0x00b000 0x00020000 0x00048000 0x021b5 0x021b5 R E 0x1000
  LOAD           0x00e000 0x00024000 0x00058000 0x0236a 0x0236a R E 0x1000

The purpose of this code is to extract each hex address from the $SOMETHING output so I can do some simple math. As this file gets longer (up to 20 lines) it gets pretty slow.

If you know an efficient way for me to assign the OFFSET,VIRTADDR,PHYSADDR etc variables, it would help a lot!!

  • 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-05-26T15:09:57+00:00Added an answer on May 26, 2026 at 3:09 pm
    echo "$SOMETHING" | while read -r junk OFFSET VIRTADDR PHYSADDR FILESIZE MEMSIZE junk2; do
         echo $OFFSET $VIRTADDR $PHYSADDR $FILESIZE $MEMSIZE 
    done
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a system that has some Bash scripts running besides Java code. Since
I'm having an issue executing jruby from the mingw git bash shell in windows.
i have a bash script I edit on windows using UltraEdit and save as
I have a bash shell script which calls some python scripts. I am running
Suppose we have a BASH script running some commands in the background. At some
I have a bash script activated by crontab and running in background. I would
When scripting in bash or any other shell in *NIX, while running a command
I have never used PHP with CLI, but I have seen scripts running with
I have a strange issue with array manipulation within a bash script on Solaris.
I am using Rscript more and more where I would have normally used bash

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.