1

What is this code doing? Especially the ${1}.TmpOut.

#!/usr/bin/env bash

if [ ! -f mergedOrca.out ]; then echo "" > O2.out.orc fi

cat ${1}.TmpOut >> O2.out.orc

  • 1
    This isn't brace expansion (but you probably didn't know that). It's just a regular parameter expansion, just on the first positional parameter. ${1} is the same as $1. See https://mywiki.wooledge.org/BashGuide/Parameters – ilkkachu Oct 22 '22 at 16:04
  • 1
    This title isn’t really applicable, since you have no preconceived notions, but see ${variable_name} doesn’t mean what you think it does …, where this particular usage is addressed in a footnote. Please pay attention to the guidance that you should always quote your shell variable/parameter references (e.g., "${1}.TmpOut" or "${1}".TmpOut) unless you have a good reason not to, and you’re sure you know what you’re doing. – G-Man Says 'Reinstate Monica' Oct 23 '22 at 02:14

1 Answers1

1

You are seeing a positional parameter in the last line. The value of the first argument to the script is $1 or if you prefer, ${1}.

The curly braces also resolve ambiguity in expressions.

JRFerguson
  • 14,740