EvilZone

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

Title: [BASH] Using input as text variables without spaces.
Post by: icon on 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:

Code: [Select]
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.
Title: Re: [BASH] Using input as text variables without spaces.
Post by: Stackprotector on 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:

Code: [Select]
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
Title: Re: [BASH] Using input as text variables without spaces.
Post by: RedBullAddicted on 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?
Title: Re: [BASH] Using input as text variables without spaces.
Post by: Deque on March 31, 2014, 09:57:48 AM
You probably mean to do:

Code: [Select]
someCommand "${var1}x${var2}" blah blah blah

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

Something like this:

Code: [Select]
#!/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.