0

I want to use bash script to generate some files. The file names will be in the format 2_x.yRandom.txt, where x is 2, 4, 6, 8, 10 and y is from 1 to 5. eg. "2_2.2Random.txt" or "2_4.3Random.txt"

This is my script:

#Generate input for sort1
for i in 2 4 6 8 10
do
    for j in 1 2 3 4 5
    do
        java utils.StringGenerator r 2 $i > "2_$i.$jRandom.txt" 
        java utils.StringGenerator s 2 $i > "2_$i.$jSorted.txt 
        java utils.StringGenerator v 2 $i > "2_$i.$jReversed.txt 
    done
done

The output file is always 2_2..txt or 2_4..txt, it seems that $j is not in the output.

What am I doing wrong?

Thanks! PS: I'm using a Mac.

1 Answer 1

2

You forgot to tell bash where the variable name ends.

    java utils.StringGenerator r 2 $i > "2_$i.${j}Random.txt" 
Sign up to request clarification or add additional context in comments.

Comments

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.