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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:56:29+00:00 2026-05-23T02:56:29+00:00

I am working with the PBS queue on a server. I want to submit

  • 0

I am working with the PBS queue on a server.
I want to submit several jobs automatically and
therefore need to replace a variable with a path.
Since it is not possible to get arguments into a
running script running with the queue, I want to
replace the shell variables that are normally used
with hardcoded parameters.

What I need is:

#! /bin/sh
#PBS -N runme_$file
#PBS -o $file.out
#PBS -e $file..err
#PBS -q batch
#PBS -j oe
#PBS -m abe
#PBS -r n
#PBS -l nodes=1:ppn=1
#PBS -l walltime=24:00:00

/home/example/proggie script $file $parameter2
echo "DONE"

replacing $file with ‘/tmp/output’, so it should be converted to:

#! /bin/sh
#PBS -N runme_/tmp/output
#PBS -o /tmp/output.out
#PBS -e /tmp/output.err
#PBS -q batch
#PBS -j oe
#PBS -m abe
#PBS -r n
#PBS -l nodes=1:ppn=1
#PBS -l walltime=24:00:00

/home/example/proggie script /tmp/output $parameter2
/home/example2/proggie2 /tmp/output
echo "DONE"

The PBS part is important because it hinders usage of parameters.
So i cannot just use $1 and $2 and give the script the parameters
it needs via arguments. Instead i have to change the file via a
substitution command, then i can submit it to the queuing system.
I still want to be able to use the script from the command line,
for quick testing.

I tried already using sed, but the possibility of special characters
occurring in the file screws up everything. There has to be a better way.

  • 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-23T02:56:29+00:00Added an answer on May 23, 2026 at 2:56 am

    Using sed:

    sed "s%\$file%$file%" script.in > script.out
    

    Using awk (gawk or GNU Awk):

    awk '{ gsub(/\$file/, file); print }' file="$file" script.in > script.out
    

    In both examples, I assume that this editing context has the correct value for the file name in $file. I’m also assuming that you don’t have any other variables such as $file1 or $filename in the script; if you do have such variables, the regular expressions have to be more complex. I also assume in the sed example that you don’t embed percent symbols in your file names.

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

Sidebar

Related Questions

Working on an old Kohana 2 project and I want to link two models.
Working with an API where I need to send a value over in an
Working on dom html . I want to convert node value to string: $html
Working on a project an need a specific effect on the homepage. When a
Working in C#, I need to find all local peaks in a List of
Working with SQL server with isolation level read committed snapshot, we routinely write data
Working on a team where people are prone to amending dev SQL Server tables
Working on a simple poker script in PHP and need a way to determine
Working version http://jsfiddle.net/uxBZN/ Would it be better to just replace password or text within
Working with dates in ruby and rails on windows, I'm having problems with pre-epoch

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.