EvilZone

Programming and Scripting => Scripting Languages => : icon March 31, 2014, 04:17:30 AM

: [BASH] Using input as text variables without spaces.
: icon March 31, 2014, 04:17:30 AM
So, I kinda feel like an idiot because I can't figure this out. I would like to be able to use a command line argument in line with text. Not sure if the phrasing is right for what I want, but hopefully this example will help:

:
var1 = $1
var2 = $2

someCommand "$var1x$var2" blah blah blah

So, my problem is that the "x" is being grouped in with the variables. Any thoughts would be appreciated.
: Re: [BASH] Using input as text variables without spaces.
: Stackprotector March 31, 2014, 09:19:14 AM
So, I kinda feel like an idiot because I can't figure this out. I would like to be able to use a command line argument in line with text. Not sure if the phrasing is right for what I want, but hopefully this example will help:

:
var1 = $1
var2 = $2

someCommand "$var1x$var2" blah blah blah

So, my problem is that the "x" is being grouped in with the variables. Any thoughts would be appreciated.
Yes you are phrasing this wrong :P
: Re: [BASH] Using input as text variables without spaces.
: RedBullAddicted March 31, 2014, 09:26:10 AM
Yep.. I don't get it either :) Could you maybe post your script and explain what you trying to do and what does not work for you?
: Re: [BASH] Using input as text variables without spaces.
: Deque March 31, 2014, 09:57:48 AM
You probably mean to do:

:
someCommand "${var1}x${var2}" blah blah blah

?
: Re: [BASH] Using input as text variables without spaces.
: icon March 31, 2014, 05:07:56 PM
Thanks for the quick responses.

Something like this:

:
#!/bin/bash

hRes = $1
vRes = $2

xrandr --newmode "$hResx$vRes.00"  173.00 $vRes 2048 2248 2576 $hRes 1083 1088 1120 -hsync +vsync
xrandr --addmode Virtual1 $vResx$hRes_60.00
xrandr --output Virtual1 --mode $vResx$hRes_60.00


Yes you are phrasing this wrong :P

I think we've all had the problem of know what we mean, but not knowing how to express it.