All Questions
Tagged with syntax-error bash
175 questions
0
votes
1
answer
93
views
bash: conditional statement causes "unexpected end of file" on macOS
When I source the following simple script in a bash shell on macOS (Sonoma 14.4.1), I get
"syntax error: unexpected end of file".
#!/bin/bash
echo "Hello"
echo "$SHELL"
...
0
votes
1
answer
71
views
How to use quotation marks with bash regex? [closed]
I want to use a regex in my Bash script like the code below:
REGEX='^\s*-.*|^\s*file:\s*["'\''].*'
if [[ ${LINE} =~ ${REGEX}.* ]]; then
# TODO
fi
If I execute this in the script in Windows it ...
-1
votes
2
answers
126
views
while there is no line 16 but still giving error "line 16 : syntax error: unexpected end of line" [closed]
a=10
b=20
c=30
if [[ $a -gt $b && $a -gt $c ]]
then
echo "A is the greater number"
if [[ $b -gt $a && $b -gt $c ]]
then
echo "B is the greater number"
else
echo &...
1
vote
1
answer
195
views
ACR task for cleanup avoiding specific tags giving syntax error
I'm trying to create ACR tasks that would run acr purge command to cleanup of ACR registry.
Here is a command for ACR cleanup of 3 repositories, except those with the tag latest :
az acr run --cmd '...
0
votes
2
answers
69
views
Postgres Syntax error caused by dash ind CLI command
I have a script with this command
/usr/bin/psql postgres -h localhost -U postgres -c "GRANT CONNECT ON DATABASE "famdb-develop" TO fullwood;"
When I ran it, I got this error:
...
0
votes
1
answer
55
views
AWK syntax error when the variable output has a full stop in it
I am trying to add this variable (it takes the batch job number and extracts the ID from a text file, with one ID being a new row) so that it can be inputted into the different locations as a variable....
0
votes
1
answer
937
views
scr.sh: 3: Syntax error: word unexpected (expecting ")") [duplicate]
I'm doing a task, but I got an error: scr.sh: 3: Syntax error: word unexpected (expecting ")"). When I try to run my schell script on my local computer server, it works, but on the helios ...
2
votes
2
answers
98
views
What is `test ( foo )` / `[ ( foo )` in Bash?
The Bash Reference Manual mentions the following about the test / [ command:
1 argument
The expression is true if, and only if, the argument is not null.
So far so good:
$ test "foo"
$ ...
0
votes
1
answer
576
views
How do I fix 'syntax error near unexpected token' when adding Homebrew to my path on Linux using this code?
I m trying to add homebrew into my path via this code
Echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv) "') >> /home/mohit/.profile
And getting this error
-bash :syntax ...
-1
votes
1
answer
482
views
Extract a particular field from json output using jq
I'm working a bash script to extraxt specific field from json output using jq.
USERNAME=$(echo "$OUTPUT" | jq -r '.[] | .name')
Due to jq it always fails with parse error: Invalid numeric ...
0
votes
2
answers
69
views
Conditional Statement Command Syntax Error in Bash Script
I ran into a command syntax issue for a conditional statement in a script that someone else wrote. The script is as follows (truncated).
#! /bin/bash
# app_upgrade.sh
# Verify file integrity
...
0
votes
2
answers
75
views
Syntax error while trying to generate a 2048bit long prime number
I'm trying to generate a 2048 bit long prime number, this is my code so far:
#!/bin/bash
generate_random() {
hex=$(head -c 256 /dev/urandom | xxd -p)
bc <<< "ibase=16; $hex"...
0
votes
2
answers
55
views
Weird behavior of bash function definitions inside if statements with the foo(){} syntax [duplicate]
Let's start with a code that works
$ cat foo1
#!/bin/bash
foo() {
echo "I'm here";
}
foo # prints: I'm here
$ ./foo1
I'm here
$
so far so good.
Now let's introduce a syntax error
$ ...
0
votes
1
answer
281
views
Parentheses inside command substitution expression
I need to get array of filenames that have .jpg or .png extensions in my bash script. For that purpose I write this command:
imagesArray=( $(ls (*.png|*.jpg)) )
which supposed to execute ls command ...
0
votes
2
answers
242
views
Syntax error at beginning of command when running script
I am trying to run a script with ./insert_data.sh; and I get an error saying there is a syntax error at or near the "."
Am working in PSQL, thanks
Edit #1: My script:
#!/bin/bash
# Script ...