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 with spring, below, the code of applicationContext-service.xml: <bean id=mediaObjectService class=path.MediaObjectServiceImpl> <property name=mediaObjectDao >
I'm working on a project in C# w/ XNA, and I want to reorganize
Working in C#, I need to find all local peaks in a List of
Working on a project an need a specific effect on the homepage. When a
Working with dates in ruby and rails on windows, I'm having problems with pre-epoch
Working with a SqlCommand in C# I've created a query that contains a IN
Working on a project at the moment and we have to implement soft deletion
Working on a somewhat complex page for configuring customers at work. The setup is
Working on a project that parses a log of events, and then updates a
Working with python interactively, it's sometimes necessary to display a result which is some

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.