All Questions
30 questions
0
votes
5
answers
140
views
What is the difference between using code $variable and ${variable}2?
What is the difference between using code $variable and ${variable}2 ?
Example:
file ='GLOBAL_AR_COLLECTOR_COMMENTS20240614ALYSSAB.TXT'
prefix ='GLOBAL_AR_COLLECTOR_COMMENTS'
In my shell script code ...
3
votes
1
answer
459
views
What is the precedence of operators '=', '||'
In this command, if curl succeeds, then res will be set to the output of curl. It seems = has higher precedence than ||.
res=$(curl -s "http://example.com")||true
But || should have higher ...
-1
votes
1
answer
86
views
How to specify several alternative conditions (OR operator) for single case statement? (Or Alternatively, where is shell case syntax description?) [duplicate]
I want something like this:
time="1m"
case "$time" in
*h*)
*m*)
*s*)
echo "handling several cases for h, m, s tokens" ;;
*)
echo "...
0
votes
1
answer
136
views
On simple filenames as commands versus arguments
I am reading Sobell's A Practical Guide to Linux Commands, Editors, and Shell Programming, 4e, and I am currently starting Chapter 5 on the basics of shells.
On page 135 Sobell explains that
From the ...
0
votes
2
answers
148
views
Dangers of executable file with '#' in name?
This might be a FAQ--happy to have the question closed if it's a dupe--but I'm not sure how to find it if so. I'd also be happy with an answer that simply told me how to find the relevant ...
23
votes
2
answers
32k
views
What does command eval "$(/opt/homebrew/bin/brew shellenv)" actually do?
Homebrew requires us to add eval $(/opt/homebrew/bin/brew shellenv) to ~/.zprofile. What does this actually evaluate to and what does this accomplish?
I am a bit new to shell scripting. I know $var is ...
0
votes
1
answer
220
views
Confused about java -version [duplicate]
For every program/utility on Unix, I would type the name of the program followed by --version to check its version, like so
program --version
If I understand correctly, the double dash -- is used to ...
1
vote
0
answers
34
views
Disk usage command not producing expected number of outputs [duplicate]
I want to run disk usage command (du) on both a parent directory (to find the total of all its contents), and then additionally on one of its subdirectories only.
If I try to pass multiple paths into ...
1
vote
0
answers
104
views
How should alias in command substitution behave?
I tested a few scripts with different shells, and the results differ.
# test 1
foo(){ echo $(al);}
alias al='echo 123'
foo
# test 2
alias al='echo 123'
foo(){ echo $(al);}
alias al='echo abc'
foo
# ...
13
votes
4
answers
1k
views
Empty variable is treated as logical "true" with `$var && action` (shell parsing)
Consider a simple debugging style where $debug would be set either to true or false according to some command-line flag:
$debug && echo "Something strange just happened" >&2
...
0
votes
1
answer
550
views
Syntax in conditional expression comparing with regex
I have tried to execute the code below on my Ubuntu machine, but it keeps saying "syntax error in conditional expression" and "syntax error near '0-9'" can you tell me why?
while ! ...
0
votes
1
answer
210
views
vconsole setup: unable to open the include file euro2
I formatted my Arch Linux and reinstalled for some reasons I wanted to start over
After installation, a very strange error appeared.
In the chrooted installation I created the file /etc/vconsole.conf ...
-6
votes
1
answer
70
views
Is there an example for a shell or computing accessibility culture aspiring a shell with more special characters and if so what is it? [closed]
I was always a bit frustrated from the lack of characters in modern computer systems such as, from what I know:
A global template literal character for which the closest character today is a backtick ...
1
vote
1
answer
411
views
How may I enter continuation lines nicer?
Usually, I type long command on separate lines like this:
myapp -a foooooooo1 \
-b foooo2 \
-c foooooooooooooooo3 \
-d foooooooo4 \
bar
But ...
1
vote
2
answers
1k
views
;ls bash: syntax error near unexpected token `;'
after typing ;ls
I got this return - bash: syntax error near unexpected token `;'
how do I fix this?