Questions tagged [variable-substitution]

This tag is misspelled. variable-substitution is correct. `t` is missing. This is the process of evaluating a string literal containing one or more placeholders, yielding a result in which the placeholders are replaced with their corresponding values.

74 questions
1
vote
0 answers

String distances and variable substitution costs

I want to quantify distance between word pairs based on phonological features. Insertion and deletion costs will stay constant but substitution costs will vary according to letter pair which are stored in a matrix. I am thinking of using the…
Rkindellan
  • 11
  • 1
1
vote
1 answer

Bash: Insert variable content into command substitution as arguments - how to quote correctly?

I really really don't find a solution to this problem: Say I have a variable that has multiple lines, each line should be one argument in the end. line 1 line two ... I only get this data at runtime, but it should be build like this to an…
flix
  • 85
  • 7
1
vote
1 answer

How to nest bash command output into an array inline?

Note - this is not a duplicate! There are other questions covering converting bash output to a bash array - but none of them do it inline. The reason you need inline is because of until. I'm trying to write an until command that parses the port…
hawkeye
  • 34,745
  • 30
  • 150
  • 304
1
vote
8 answers

How do i break an in-string variable in php?

This should be simple to answer. When I have a variable, say $id, and in a string, I want it between two underlines. Something like this: $id = 1; $myString = "row_$id_info"; Now, php will see "row_" and the variable $id_info - And that's not what…
Hubro
  • 56,214
  • 69
  • 228
  • 381
1
vote
2 answers

Python: Substitute variable values before passing to another function

I want to determine whether the input string is a valid function name or not. Is there any way to substitute the value of the variable before being passed to isfunction call ? #!/usr/bin/python def testFunc(): print "Hello world!"; …
Ashwin
  • 993
  • 1
  • 16
  • 41
1
vote
1 answer

Converting Linux style substitutions to Windows style substitutions in Python

Is there a way to convert Linux style shell substitutions to Windows substitutions in Python? Let's say there's a command in a Linux environment: my_command=cd ${my_command} .. OR $my_command .. resolves to cd .. In Windows: SET…
Andrew
  • 1,355
  • 2
  • 13
  • 28
1
vote
2 answers

Does R support indirect variable expansion or variable substitution?

In bash one can use an exclamation mark to use a variable's value as a variable. See explanation here. This is known as variable indirect expansion. This can be used to used to name a new variable using another variable in your code. I was wondering…
Gabriel Fair
  • 4,081
  • 5
  • 33
  • 54
1
vote
3 answers

Substituting variables in a text string

I have a text string in a variable in bash which looks like this: filename1.txt filename2.txt varname1 = v1value $(varname1)/filename3.txt $(varname1)/filename4.txt varname2 =…
user2664470
  • 781
  • 1
  • 7
  • 17
1
vote
2 answers

How to expand environment variables with substitutions?

Goal We are using environment variables like %logonserver% and %userdomain% in our .NET application's configuration files, to support configuration freedom to application managers. When parsing the configuration file a call to…
1
vote
2 answers

Parameter Substitution on Left Side of Variable Assignment - BASH and Arrays

I am processing some folders that each represent a page of a book. E.g. "Iliad-001" would be Book=Iliad, Page=001. I want to iterate through all of the folders, create an array for each book and add an entry to that array for each page that is…
Seth
  • 147
  • 2
  • 11
1
vote
2 answers

variable substitution removing quotes

I seem to have some difficulty getting what I want to work. Basically, I have a series of variables that are assigned strings with some quotes and \ characters. I want to remove the quotes to embed them inside a json doc, since json hates quotes…
HM Stanley
  • 145
  • 4
  • 14
1
vote
1 answer

Bash Command Substitution with Variables

I have a bash script that builds a command based on a list of files so the command is built on the fly. Building it on the fly means it gets stored in a variable. I then want to run that command and store the output in a separate variable. When I…
1
vote
1 answer

Order of substitution in bash

I need to demonstrate the order in which command substitution, variable substitution and globbing occurs. Any ideas on how to do it?
SharkTiles
  • 585
  • 3
  • 9
  • 22
0
votes
7 answers

$_SESSION[] inside of Double quotation

$_SESSION['result'] = '2011-08-14 20:34:12'; echo $dateTime = "$_SESSION['result'] +1 hour"; Expect output: '2011-08-14 20:34:12 +1 hour' I know there is error on the double quotation, but don't know how to fix it. Can anyone help me out? It would…
Acubi
  • 2,793
  • 11
  • 41
  • 54
0
votes
0 answers

Solved: How do i loop through arrays using variable expansion on strings in batch?

In batch, I'm failing to use "variable expansion" such as %%~x (culls all but an extension from a string) on array elements, for strings that have no tangible file structure equivalent. These paths and file names are intangible. There are no actual…