0

The following bash script is to run an azure command:

#!/bin/bash
RG=$1
echo "az cosmosdb list-keys -g $1 -n db01"
echo "az cosmosdb list-keys -g $RG -n db01"

Then run the script with this command:

cosmokeys.sh main-Resource-Grp

The output is

az cosmosdb list-keys -g main-Resource-Grp -n db01
-n db01sdb list-keys -g main-Resource-Grp

I don't know Unix/Linux, beginner questions are:

  1. How come $1 and $RG will yield a different result?

  2. How can I fix this so that I can still use $RG and yield the first result

kvantour
  • 25,269
  • 4
  • 47
  • 72
KaGo
  • 123
  • 1
  • 8
  • There is most likely a CRLF behind `RG`. Can you have print your source using `cat -A` or `cat -vET`. You notice this as the output overwrites itself. – kvantour Jan 14 '19 at 10:06
  • Thanks very much! You are correct and it solved my problem. – KaGo Jan 14 '19 at 10:26

0 Answers0