Questions tagged [syntax]
The syntax tag has no summary.
200 questions
2
votes
2
answers
93
views
Merging values from 2 YAML files in bash
A bash command:
$(System.DefaultWorkingDirectory)/yq_linux_amd64 '. *= load("${{ parameters.HELM_CHART_PATH }}/values/DEV/${{ parameters.COMPONENT }}.yaml")' ${{ parameters.HELM_CHART_PATH }}...
5
votes
1
answer
100
views
Why can a list within a group be terminated with a space instead of a semicolon/newline as defined in the manual?
I am using the following version of the bash:
GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu)
Man bash states the following for the "group" compound commnad:
{ list; }
list is ...
0
votes
4
answers
88
views
Details with bash's syntax checking and breaking over several lines
There are two cases in which I do not understand why bash behaves as it behaves regarding syntax checking and asking for a newline.
Case 1
bash can execute the line ( (ls) | cat), but depending on ...
2
votes
1
answer
62
views
Get PID of command in one line bash script [duplicate]
When trying to get the PID of a shell command, it is possible using a script file:
#!/bin/bash
ls -lha &
echo "$!"
However, it is not possible using only the terminal.
/bin/bash -c 'ls ...
-5
votes
1
answer
59
views
After wrote prompt $ sort [closed]
After I wrote prompt $ sort
display doesn't shown anything what the next step?
0
votes
1
answer
902
views
bash 5.2.x + ternary operator: How can I use this combo when checking if my string variable is empty or not?
I have tried
#!/bin/bash
distro=""
myvar1=[[ -n "$distro" ]] && echo $distro || echo "debian"
myvar2=$((-n $distro ? $distro : "debian"))
these are ...
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 ...
3
votes
1
answer
230
views
Convention of parameter naming - undocumented options
GNU has long pushed for a combination of short options (-h) and long options (--help), which goes a long way to clearing up the syntactical mess of commands like tar and dd, with their legacy syntax ...
0
votes
1
answer
185
views
ShellCheck does not detect error? How to fix my snippet?
I likely have syntax errors in the following (POSIX) shell snippet:
#!/bin/sh
if tput setaf >/dev/null 2>&1; then tput_init_linux else tput_init_none;
elif tput AF >/dev/null 2>&1;...
-1
votes
1
answer
82
views
awk inside function causing errors
I'm trying to add the following to my .bashrc:
cpu_info() {
top -b -n1 | grep Cpu(s) | awk '{print $2 + $4}'
}
but bash is telling me:
bash: .bashrc: line 131: syntax error near unexpected token `...
-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
4k
views
"Error in network definition: expected mapping (check indentation)" Syntax error in Netplan, I am trying to set up a static IP for my LAMP stack
Below are the configs for the yaml: file /etc/netplan/{filename}.yaml
network:
version: 2
renderer: networkd
ethernets:
eno1:
dhcp4: false
dhcp6: false
addresses:
[10.0....
0
votes
0
answers
100
views
Better understanding accels/nemo file syntax to add keyboard shortcuts for custom Nemo scripts
I carefully followed the instructions to add keyboard shortcuts to custom Nemo scripts as explained in this Ask Ubuntu answer and this Stack Overflow answer.
Although this technique works great to ...
4
votes
1
answer
131
views
lsof output file descriptor with asterisk not documented
When I run lsof I see the output
java 1752736 user 9995u sock 0,8 0t0 1432559505 protocol: TCPv6
java 1752736 ...