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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:47:36+00:00 2026-06-18T11:47:36+00:00

Is it possible to expand variables in comments inside a bash script? I want

  • 0

Is it possible to expand variables in comments inside a bash script?

I want to write a script to feed into SGE. The qsub syntax allows me to pass additional parameters to the grid engine using lines inside the bash script which begin with #$. For example,

#$ -q all.q
#$ -S /bin/bash
#$ -V
#$ -m beas
#$ -o run_20120103.out

What I want is that the -o parameter is dynamically set to a variable, say $1. So I would naively write

#$ -o run_${1}.out

However, since the line starts with a #, bash ignores it and the variable $1 is not expanded.

Any ideas? Some bash preprocessor? Some other way?

EDIT I just chose $1 as an example. It could just as well be $FOO or $BAR.

  • 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-18T11:47:38+00:00Added an answer on June 18, 2026 at 11:47 am

    Variable expansion happens in shell memory, it doesn’t affect the file. Therefore, it doesn’t matter what bash expands.

    Instead, you can probably generate the script to be run on the fly, with everything expanded in place:

    cat << EOF | qsub [options] -
    #$ -o run_$1.out
    cmds
    EOF
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible with the standard asp:dropdownlist to make the list expand upwards instead
Possible Duplicate: How can I convert a list<> to a multi-dimensional array? I want
Possible Duplicate: How to do the vector of sets in C++? I want to
Possible Duplicate: check whether internet connection is available with C# I just want to
In Visual Studio debug mode it's possible to hover over variables to show their
Is it possible to expand the width of navigation bar in iPhone?
Would it somehow be possible to display every column in the Click to expand
Possible Duplicate: Multiple index variables in PHP foreach loop I am trying to create
When calling a cmdlet, is it possible to expand the value of a powershell
Possible Duplicate: Expand a random range from 1-5 to 1-7 I understood the solution

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.