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'm trying to concatenate, in text, my variables in my shell script but it does not work. I would like to understand why it does not work
firstName="Charles"
secondName="Montesquieu"
name="Hello $firstName"
echo "Hello $firstName with $lastName"
output: with Montesquieu
I wish I had:
Hello Charles with Montesquieu
Based on the command, the variable $lastName does not refer anything, it is NULL, your correct one is $secondName.
You haven't declared $lastName, you wanted to say $secondName no ?
In 'echo' instruction you're using
$lastname
instead of
$secondName
Try with:
echo "Hello $firstName with $secondName"
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
What does the 2nd "in" do? I can't seem to find this kind of example anywhere other than this one right here.
for a in in /home/davidwright/attachments/*/*.tar
do
echo "extracting $x"
tar -xvf $x
done
Looks like a typo. It means the loop iterates with the string "in" as the first value assigned to a, then proceeds to iterate over the results of the glob. The shell's just not that picky, and every item after the first in is a thing to iterate over in the for loop. Unless there is a file named in that is known to exist, tar will complain when it tries to unpack the non-existent in file.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 4 years ago.
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.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Improve this question
I'm writing a shell script in which I've created some variables.
RELEASE="something"
COMMONS="something else"
I've got a file file.txt in which there are some occurrences of $RELEASE and $COMMONS. I want to replace these strings with the corresponding shell variable. I've tried to run (and a lot of other variations):
sed "s|\$RELEASE|${RELEASE}|g" file.txt > result.txt
It replaces "$RELEASE" with "${RELEASE}." Have you any idea how to replace by the value of $RELEASE?
Try this :
sed 's|$RELEASE|'"$RELEASE"'|g' file.txt > result.txt
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 would like to delete the word blob from phrase $CHANGEDSITE. but my code isn't working. Any suggestions?
#!/bin/bash
OLD=$1 ex. https://github.com/retep-mathwizard/imitate/blob/master/bjqx
NEW=raw.githubusercontent.com
CHANGEDSITE="${OLD/github.com/$NEW}"
REMOVEDBLOB="${CHANGESITE/blob/}"
echo $REMOVEDBLOB
Forgot a D in my variable, So CHANGESITE was nothing , hence the output being nothing
You can use sed
OLD=https://github.com/retep-mathwizard/imitate/blob/master/bjqx
echo $OLD | sed 's/github.com/raw\.githubusercontent\.com/g' | sed 's/blob\///g'
The First sed change the url and the second remove the word blob/
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 am trying to check if a specific element is included in an output. I run:
results.include? {"_id"=>{"car_id"=>44, "page"=>"5"}, "summarized_time"=>100}
but I get an error:
Syntax error, unexpected =>, expecting '}'
What did I do wrong?
The problem is that the curly brackets in this case are interpreted as start of a block. Just put () around:
results.include?({"_id"=>{"car_id"=>44, "page"=>"5"}, "summarized_time"=>100})
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
Hello i am creating a simple case statement menu to implement an address book and i am having trouble.
the menu work fine but i am having trouble understanding why the file is not created through this command.
this is just primary testing to see if a file is created but is is giving me an operand error so i tried adding .txt to the end and it gave no feedback.
1) echo "Please enter a name for your addressbook"
read addName
touch $addname
break;;
read addName vs. $addname The names are not the same (uppercase n vs. lowercase n)
You could try this.
echo "Please enter a name for your addressbook"
read addName
touch $addName.txt
break;;
for a text file.