how to concatenate two string variables (alphanumeric)
hello,
below my piece of code initializing two queue names variables when iam running for loop with counter varibale it is not giving the value of queue1 and queue2 to my command. how to solve this? queue1=ABCD queue2=PQRS for i in {1..2} do echo "DISPLAY Q(*)"| runmqsc $queue$i done |
The pipe sends data via stdin. So if your utility is expecting to read that, then the pipe is the way to go. Otherwise, xargs is the way to go.
About the variables, if what you are aiming for is an indirect reference where the name of a variable is held in a second variable and the value accessed via that, then : Code:
#!/bin/sh Also [code] [/code] will help keep your script readable. |
^ Interesting but I prefer ${!} notation.
So I would say: Code:
queue1=ABCD |
provided both feedback not working .
below script used Code:
queue1=ABCD when script run its take single quote but no value inside . Code:
+ runmqsc '' |
Quote:
To concatenate the variables: Code:
runmqsc $queue1$queue2 Code:
queue[1]=abcd |
Since the OP seems to be using Bash, maybe an array would be more useful.
|
Quote:
https://www.linuxquestions.org/quest...2/#post5655038 ...where you post (when asked) a small piece of a 'script', get a few suggestions, then come back asking folks to finish it for you. How about this: you take the advice you've been given thus far, put it to use in a script, and post that script back here if it doesn't work? |
All times are GMT -5. The time now is 01:05 PM. |