0

I have a large number of .pbs files that I want to submit to a remote cluster. I want to be able to name the .pbs file something like "param1_123_param2_45.pbs", and then feed them into the ARGS for a Julia code. Below is an example .pbs of what I'm trying to do:

1 #!/bin/tcsh 
2 #PBS -l mem=10gb,nodes=1:ppn=2,walltime=1:00:00
3 #PBS -j oe
4 #PBS -o ./log/julia.${PBS_JOBID}.out
5 #PBS -t 1-3
6 
7 module load julia/1.5.1 python/3.8.1
8 
9 cd path/to/file  
10 
11 julia Example.jl 123 45

Except 123 & 45 are replaced by some general terms given in the name of the .pbs file. Is there an easy way to do this?

1
  • 3
    You are asking for Bash support, but your shebang is for tcsh. ;) Commented Jan 15, 2021 at 19:22

1 Answer 1

1

You can use AWK. For example, content of file param1_123_param2_45.pbs:

PARAM1=$( echo ${0%%.pbs} | awk -F "_" '{print $2}' )
PARAM2=$( echo ${0%%.pbs} | awk -F "_" '{print $4}' )
echo "Filename: $0"
echo "Param 1: $PARAM1"
echo "Param 2: $PARAM2"

Running: bash param1_123_param2_45.pbs

Output:

Filename: param1_123_param2_45.pbs
Param 1: 123
Param 2: 45
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you; this solves the main problem I was having. However, I get a bizarre error when I submit to the cluster; you can see my error here: stackoverflow.com/questions/65755537/… If you had any additional insight, I'd greatly appreciate it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.