Author Topic: [BASH] Using input as text variables without spaces.  (Read 535 times)

0 Members and 1 Guest are viewing this topic.

Offline icon

  • Serf
  • *
  • Posts: 26
  • Cookies: 6
  • Ghost
    • View Profile
[BASH] Using input as text variables without spaces.
« 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.
De Oppresso Liber

Offline Stackprotector

  • Administrator
  • Titan
  • *
  • Posts: 2515
  • Cookies: 205
    • View Profile
Re: [BASH] Using input as text variables without spaces.
« Reply #1 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
~Factionwars

Offline RedBullAddicted

  • Moderator
  • Sir
  • *
  • Posts: 519
  • Cookies: 189
    • View Profile
Re: [BASH] Using input as text variables without spaces.
« Reply #2 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?
Deep into that darkness peering, long I stood there, wondering, fearing, doubting, dreaming dreams no mortal ever dared to dream before. - Edgar Allan Poe

Offline Deque

  • P.I.N.N.
  • Global Moderator
  • Overlord
  • *
  • Posts: 1203
  • Cookies: 518
  • Programmer, Malware Analyst
    • View Profile
Re: [BASH] Using input as text variables without spaces.
« Reply #3 on: March 31, 2014, 09:57:48 am »
You probably mean to do:

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

?

Offline icon

  • Serf
  • *
  • Posts: 26
  • Cookies: 6
  • Ghost
    • View Profile
Re: [BASH] Using input as text variables without spaces.
« Reply #4 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.
De Oppresso Liber