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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T09:57:18+00:00 2026-05-13T09:57:18+00:00

I have a bash scripts which an argument enclosed with double quotes, which creates

  • 0

I have a bash scripts which an argument enclosed with double quotes, which creates a shape-file of map within the given boundries, e.g.

$ export_map "0 0 100 100"

Within the script, there are two select statements:

select ENCODING in UTF8 WIN1252 WIN1255 ISO-8859-8;
...
select NAV_SELECT in Included Excluded;

Naturally, these two statements require the input to enter a number as an input. This can by bypassed by piping the numbers, followed by a newline, to the script.

In order to save time, I would like to have a script that would create 8 maps – for each combination of ENCODING (4 options) and NAV_SELECT (2 options).

I have written another bash script, create_map, to server as a wrapper:

#!/bin/bash

for nav in 1 2 3 4;
do
    for enc in 1 2;
    do
        printf "$nav\n$enc\n" | /bin/bash -c "./export_map.sh \"0 0 100 100\"" 
    done
done

**This works (thanks, Brian!), but I can’t find a way to have the numeric argument "0 0 100 100" being passed from outside the outer script. **

Basically, I’m looking for way to accept an argument within double quotes to a wrapper bash script, and pass it – with the double quotes – to an inner script.

CLARIFICATIONS:

export_map is the main script, being called from create_map 8 times.

Any ideas?

Thanks,

Adam

  • 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-13T09:57:19+00:00Added an answer on May 13, 2026 at 9:57 am

    If I understand your problem correctly (which I’m not sure about; see my comment), you should probably add another \n to your printf; printf does not add a trailing newline by default the way that echo does. This will ensure that the second value will be read properly by the select command which I’m assuming appears in export_map.sh.

    printf "$nav\n$enc\n" | /bin/bash -c "./export_map.sh \"100 200 300 400\""
    

    Also, I don’t think that you need to add the /bin/bash -c and quote marks. The following should be sufficient, unless I’m missing something:

    printf "$nav\n$enc\n" | ./export_map.sh "100 200 300 400"
    

    edit Thanks for the clarification. In order to pass an argument from your wrapper script, into the inner script, keeping it as a single argument, you can pass in "$1", where the quotes indicate that you want to keep this grouped as one argument, and $1 is the first parameter to your wrapper script. If you want to pass all parameters from your outer script in to your inner script, each being kept as a single parameter, you can use "$@" instead.

    #!/bin/bash
    
    for nav in 1 2 3 4;
    do
        for enc in 1 2;
        do
            printf "$nav\n$enc\n" | ./export_map.sh "$1"
        done
    done
    

    Here’s a quick example of how "$@" works. First, inner.bash:

    #!/bin/bash
    
    for str in "$@"
    do
        echo $str
    done
    

    outer.bash:

    #!/bin/bash
    
    ./inner.bash "$@"
    

    And invoking it:

    $ ./outer.bash "foo bar" baz "quux zot"
    foo bar
    baz
    quux zot
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a python framework which has to execute bash scripts as plugins. We
I have a bash script which need to execute some php scripts and to
I have a makefile which calls some bash scripts and shell commands. One of
I have a bash script which takes a single argument and returns around 8-10
I have a little Bash script which suspends the computer after a given number
I have a number of bash scripts which invoke R scripts for plotting things.
I have a few bash and perl scripts which has been asked to be
I have few bash scripts which are adding to cron jobs with specified timing,
I have some ksh scripts which I'd like to convert to run with bash
Currently I have a bash script which runs the find command, like so: find

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.