Questions tagged [variable-expansion]

Evaluating or expanding a variable to get its value. Depending on the language, a variable may be expanded one or more times.

246 questions
0
votes
1 answer

Filter out non-aplhanumeric characters within Bash brace expansion

Is it possible to modify an environment variable prior to expanding it? Example: set ENV_VAR=some-stuff echo ${ENV_VAR} - get this to print "somestuff" instead of "some-stuff"
DigitalDisaster
  • 467
  • 3
  • 10
  • 25
0
votes
1 answer

Makefile secondary expansion: execution of escaped function?

Consider the following makefile: .SECONDEXPANSION: %.result: jobs/% $$(call get-job,$$<) echo $^ define get-job $(shell head -n 1 $(1)) $(shell tail -n +2 $(1)) endef The idea is that each file under jobs/ contains a list of filenames, which…
lenz
  • 5,658
  • 5
  • 24
  • 44
0
votes
1 answer

Bash Parameter expansion

I am trying to write bash-script with user input. Script gets user input and build find command with data from input(Use parameter if they aren't empty). I was reading about bash expansion from here and i did something like : eval find $USERPATH…
Farfax
  • 3
  • 1
0
votes
2 answers

Variable expansion inside single quotes

I am quite new to shell scripting. I have the following script: out="FAILURE" curl -X POST -d 'json={"json":"message"}' http://localhost:8888/json.tail.test I want to replace "message" with the $out's value. I tried different ways but could not get…
Mahbub Rahman
  • 1,295
  • 1
  • 24
  • 44
0
votes
1 answer

Why this expansion inside expansion pattern doesn't work?

Suppose you have something like: $ a=(fooa foob foox) Then you can do: $ b=(${(M)a:#*(a|b)}) To select a's elements matching the pattern. So you have: $ print ${(qq)b} 'fooa' 'foob' Then you expect to build…
Pablo Lalloni
  • 2,615
  • 19
  • 20
0
votes
3 answers

Expanding variables in an AHK string?

I’m stuck trying to figure out how to expand any variables in an AutoHotkey string. In my specific case, I read a line from a file and run it. The line may contain one or more variable references which need to be expanded before being passed to…
Synetech
  • 9,643
  • 9
  • 64
  • 96
0
votes
0 answers

escape brace expansion with echo

I can't make this line to work on my bash script: echo "VAR=$(ps ax | grep myprocess)" >> myprocess How should I do to escape the $(ps ax | grep myprocess) expansion? I want as a result, a myprocess file with this content: VAR=$(ps ax | grep…
Facundo Chambo
  • 3,088
  • 6
  • 20
  • 25
0
votes
1 answer

In bash how to insert a variable in a grep command and affect output to another?

I need to use the following grep command in a shell script: grep 'DUE TO TIME LIMIT' ./slurm-3364.out Which outputs the lines in slurm-3364.out containing the pattern 'DUE TO TIME LIMIT'. I want to replace the file name with a variable and affect…
JohnND
  • 103
  • 1
  • 12
0
votes
2 answers

Can't access global associate array using indirect expansion?

I have the following setup: #! /bin/bash init_globals() { declare -gA global_arr1=( ["key"]="val" ) } init_globals echo "${global_arr1["key"]}" # WORKS! print val local_arr1=( ["key"]="local val"…
Boyang
  • 2,520
  • 5
  • 31
  • 49
0
votes
1 answer

M/Monit config file variable expansion

On a Debian 8 server I have monit 5.9-1 setup and monitoring several services. I plan on monitoring atop 1.26-2, this I can simply do with the following config check process atop with pidfile /var/run/atop.pid group system group atop …
Alasdair
  • 41
  • 1
  • 6
0
votes
1 answer

Powershell expansion of regular expression groups and other variables

I'm trying to use regular expressions to match and replace text in a file. I'm using capture groups also. In the replacement text I'm using the capture groups and other variables that I want expanded. The problem is that when the other variables'…
kamcknig
  • 883
  • 3
  • 9
  • 27
0
votes
2 answers

bash let variable default to user input

I want to write a script for both interactive and batch use. If arguments are not provided the script will ask for the users input. Unlike here the user shouldn't be bothered if the variable is already defined by arguments. Using parameter expansion…
Horst
  • 334
  • 1
  • 12
0
votes
1 answer

bash paste: loop through pairs of files based on wildcard, generate separate output files

I am trying to get the paste command to loop through pairs of files, pasting them together and outputing each as a unique file. I've tried a lot of things, here are a few: for i in *_temp4.csv; do paste *_temp4.csv *_temp44.csv > ${i}_out.csv;…
Stonecraft
  • 860
  • 1
  • 12
  • 30
0
votes
1 answer

Simple forms post field specific field values

I am using simpleforms as a subscription form for subscribing to classes. The form uses a use_as and also sends the email to the sender as a confirmation. I have edited the email twig template and added further informatie about what the subscriber…
Tim
  • 43
  • 6
0
votes
1 answer

Bash expansion error defining function with pandoc

I'm using the advice here to setup an alias to convert markdown to man style output using the command, alias mdless="pandoc -s -f markdown -t man \!* | groff -T utf8 -man | less" I keep getting the error: pandoc: !*: openFile: does not exist (No…
DilithiumMatrix
  • 17,795
  • 22
  • 77
  • 119