Skip to main content
Unix & Linux

Questions tagged [variable]

A variable is a name, if correctly chosen with a symbolic meaning, that holds a value or values. Use this tag if your question is specific on the use of variables on shell scripting (if you want to ask about variables in programming languages you should probably ask on StackOverflow)

Filter by
Sorted by
Tagged with
0 votes
1 answer
63 views

bash conditional variable assignment cli not what I expected [duplicate]

Can anyone explain what's going on with DR here? user@host:~# DRYRUN=true user@host:~# echo "$DRYRUN" true user@host:~# $DRYRUN && export DR="-n" user@host:~# echo $DR user@...
0 votes
0 answers
38 views

bash subshell execution behaves unexpectedly [duplicate]

I have a script which is supposed to fetch 2 URLs sequentially: #!/bin/bash wget_command='wget --restrict-file-names=unix https://www.example.com/{path1,path2}/' $($wget_command) echo $wget_command ...
0 votes
2 answers
163 views

How to apply an ls to a file name with spaces in a variable

This code my_file="/tmp/file_without_spaces" if [ -f "${my_file}" ]; then my_ls_aaaammgg_hhss="$(ls ${my_file} -l --time-style='+%Y%m%d_%H%M%S' | cut -d' ' -f6)" mv &...
-1 votes
2 answers
93 views

set output into variable from grep from input variable

whats wrong with this bash script: acme2=$(dig txt @1ドル _acme-challenge.1ドル.de) acme3=$(echo $acme2 | grep "^_acme") ...
-3 votes
1 answer
86 views

Need working examples of using tilde expansion immediately following the : (colon) sign in variable assignment

In the Bash manual, it is written about the tilde expansion: Each variable assignment is checked for unquoted tilde-prefixes immediately following a ‘:’ or the first ‘=’. Read the Bash manual about ...
1 vote
3 answers
137 views

Bash/macOS: Getting a variable by its name, inside of a function [duplicate]

In Bash for macOS, I need to be able to pass a string to a function and return the value of a variable named after that string, as well as the string itself. Here's what I have so far, which doesn't ...
1 vote
1 answer
82 views

Zsh’s autocompletion options from variable

General overview I have to set a values auto-completion in zsh for a command (in the following minimal example, I will show it with testcmd). So my current code work quiet well with hardcoded values: ...
1 vote
1 answer
59 views

How To Use Quotes In Variable In Bash [duplicate]

I need to assign a command to a variable and execute it with variable in linux bash. The command executes fine from command line but not from the variable because of multiple quotes. I hope backslash ...
5 votes
4 answers
591 views

Getting multiple variables from the output of docker exec command in a bash script?

I would like to execute a script on a host machine (script_on_host.sh), which then reaches inside a docker container in order to grab some data using a second script (script_in_container.sh). The data ...
3 votes
1 answer
201 views

Write the contents of a .conf file into a variable located in a separate .conf file

I am configuring my hyprland.conf file and I am attempting to do it in a clean and modular fashion. I am trying for a modular fashion so that I can share my dotfiles and someone else can change which ...
-1 votes
1 answer
136 views

Bash local nameref declaration does not work

I am trying to set a local variable in a function with nameref. The script code is the following: #!/usr/bin/bash msg=hello myparam='' superfunc () { productfile=1ドル local -n refmyparam=2ドル } ...
1 vote
1 answer
86 views

How can you echo a variable name made of variable names I.e $$var1$var2 [duplicate]

In this test I'm expecting it to print "var1 is 999". user@penguin:~$ for num in {1..3}; do export var$num=9999 ; echo var$num is $var$num ; done var1 is 1 var2 is 2 var3 is 3 user@penguin:~...
2 votes
2 answers
452 views

Zsh Expanding Variables into Arrays or Lists

I looked through some of the posted threads and none of them cover my query. I have a simple line of code below which prints all the ASCII characters: echo {' '..'~'} I want to be able to use a ...
0 votes
3 answers
377 views

Convert json data to comma separated string

I have a json object that has an unknown number of variables, like this: { "var1": 123, "var2": 456, "var3": 789 } How can I automatically convert it to form ...
teeeeee's user avatar
  • 305
5 votes
1 answer
332 views

How to make MAKEFLAGS=--warn-undefined-variables apply to current Makefile?

Yes I read Communicating Options to a Sub-'make' but I want to set an option for this make, not a sub-make, and set it within the Makefile, not via the command line. $ cat Makefile MAKEFLAGS = --warn-...

15 30 50 per page
1
2 3 4 5
...
83

AltStyle によって変換されたページ (->オリジナル) /