Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
So I have a bash script
!#/bin/bash
while [ true ];do
ls -lah /sth/ | grep sth*
sleep 0.001
done
exit 0
I thoought thai it was ok but when I run it I get
line 7: syntax error: unexpected end of file
But the code has only 6 lines?
What may be a problem? I edited the file in linux, deleted unnecessary spaces but still my scropt doesn't work.
The shebang line is wrong. You are not running it under Bash at all.
#!/bin/bash
Notice the order of the sharp (#) and the bang (!).
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
command:
/usr/bin/ruby “${SRCROOT}/generate-games.rb” “${SRCROOT}/sample-data.csv”
error: /usr/bin/ruby: No such file or directory --
“/Users/rays/Desktop/GenerateTestData/generate-games.rb” (LoadError)
Command PhaseScriptExecution failed with a nonzero exit codet I
Yet I confirmed the script is where it should be.
You are using UTF-8 quotes: “...” instead of standard ASCII quotes "...". Your shell will will only recognize ASCII quotes as delimiters, and therefore will interpret the UTF-8 quotes as part of the file name (which they obviously are not).
Conclusion:
Fix your quotes and that should fix your problem.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 3 years ago.
Improve this question
I copied and running the command on my ubuntu 18.04 from here
https://kite.com/linux/ but got an error like:
$ bash -c “$(wget -q -O – https://linux.kite.com/dls/linux/current)”
bash: “”: command not found
$ type quote
quote is a function
quote ()
{
local quoted=${1//\'/\'\\\'\'};
printf "'%s'" "$quoted"
}
Any suggestions of the error?
You probably copied and pasted that from some word processor or website that turned the straight, regular, ASCII quotes " into pretty, curly Unicode quotes “ ”. Bash doesn't understand those. Just type them in by hand to fix the problem.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 4 years ago.
Improve this question
I'm sure this is quite simple. However, it's just not working for me. What stupid thing am I doing wrong please? I am running the following shell script like this:
bash test1.sh
Here's the code:
#!/bin/bash
bluesman_a="Magic Slim"
bluesman_b=($echo "$bluesman_a" | sed "/s/Slim/Sam/")
echo $bluesman_b
I get:
syntax error near unexpected token `|'
Thanks for your time
You need to use "$(...)" to wrap a command to assign the output to a variable and you need to remove the first / in the sed replacement command. Also, you do not need to use echo to pass a variable to sed.
bluesman_b="$(sed 's/Slim/Sam/' <<< "$bluesman_a")"
Or, to replace Slim with Sam just once, use
bluesman_b="${bluesman_a/Slim/Sam}"
See 10.1. Manipulating Strings.
See the online Bash demo
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 5 years ago.
Improve this question
I want a bash command (perl?) that will output a non-zero exit code if a non-ASCII character is found in a text file.
Here's what I have so far:
perl -nle 'print "$." if m/[\x80-\xFF]/' file_that_has_non_ascii_characters.txt
This prints out each line that a non-ASCII character is found on. I tried a variant with exit 1 in it, but it doesn't seem to work:
➜ perl -nle 'exit 1 if m/[\x80-\xFF]/' file_that_has_non_ascii_characters.txt
➜ echo $!
0
How do I do this?
You should be using $? instead of $!.
!: Expands to the process ID of the most recently executed background (asynchronous) command.
?: Expands to the exit status of the most recently executed foreground pipeline.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
I have this bash script;
~/build/mosesdecoder/scripts/training/mert-moses.perl \
~/factored_translation/dataset/dev.tr ~/factored_translation/dataset/dev.en \
~/build/mosesdecoder/bin/moses unfactored/model/moses.ini \
--mertdir ~/build/mosesdecoder/bin \
--input-factor-max 4 \
--decoder-flags="-threads all"
When I run it, it gives me this error:
./tune-model.sh: line 2:
/export/students/sait/build/mosesdecoder/scripts/training/mert-moses.perl:
No such file or directory
But I am sure that mert-moses.pl is under /export/students/sait/build/mosesdecoder/scripts/training/ directory, and it exists.
How can I solve this problem?
You say in the comments that mert-moses.pl exists, but your script looks for mert-moses.perl. This is probably the source of your problem.