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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T06:24:18+00:00 2026-06-07T06:24:18+00:00

If I am writing a bash script, and I choose to use a config

  • 0

If I am writing a bash script, and I choose to use a config file for parameters. Can I still pass in parameters for it via the command line? I guess I’m asking can I do both on the same command?

The watered down code:

#!/bin/bash 

source builder.conf 
function xmitBuildFile { 
    for IP in "{SERVER_LIST[@]}" 
    do 
        echo $1@$IP 
    done 
} 
xmitBuildFile

builder.conf:

SERVER_LIST=( 192.168.2.119 10.20.205.67 )

$bash> ./builder.sh myname

My expected output should be myname@192.168.2.119 and myname@10.20.205.67, but when I do an $ echo $#, I am getting 0, even when I passed in ‘myname’ on the command line.

  • 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-07T06:24:23+00:00Added an answer on June 7, 2026 at 6:24 am

    Assuming the “config file” is just a piece of shell sourced into the main script (usually containing definitions of some variables), like this:

    . /etc/script.conf
    

    of course you can use the positional parameters anywhere (before or after “. /etc/…”):

    echo "$@"
    test -n "$1" && ...
    

    you can even define them in the script or in the very same config file:

    test $# = 0 && set -- a b c
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a bash script to modify a config file which contains a bunch
I am writing a bash script to search for a pattern in a file
I'm writing a bash script that needs to sudo multiple commands. I can do
I am currently writing a bash script and when i run the useradd command
I'm writing a Bash script where I need to pass a string containing spaces
I'm writing a bash script, and I'd like to monitor file changes into a
I'm writing a bash script that will (hopefully) redirect to a file whose name
I am writing a bash script to redirect output from another command to the
I am writing a bash script that modifies a file that looks like this:
I am writing some BASH shell script that will continuously check a file to

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.