This question already has answers here:
What does the Bash operator <<< (i.e. triple less than sign) mean?
(3 answers)
Closed 2 years ago.
I get the following code to get a fingerprint from private key of OpenSSH.
$ key=`ssh-keygen -yf ~/.ssh/id_rsa`; ssh-keygen -lf /dev/stdin <<<$key
However, I do not know <<< $key syntax.
What behavior is this? Is there a web site that explains this syntax?
From man bash:
Here Strings
A variant of here documents, the format is:
<<<word
The word is expanded and supplied to the command on its standard input.
Related
This question already has answers here:
Difference between ${} and $() in Bash [duplicate]
(3 answers)
Brackets ${}, $(), $[] difference and usage in bash
(1 answer)
Closed 6 months ago.
This post was edited and submitted for review 6 months ago and failed to reopen the post:
Original close reason(s) were not resolved
In the bash shell,
$ date +%Y%m%d%H%M
202208161535
So I put it in a bash script
#!/bin/bash
dat=${date +%Y%m%d%H%M}
echo "dat=" ${dat}
But when I run it, I get
$ test.bash
./test.bash: line 2: ${date +%Y%m%d%H%M}: bad substitution
dat=
How should I do it?
ADD
I found
dat=`date +%Y%m%d%H%M`
works. But I'm curious how I can do it with dat = ${data +%Y%m%d%H%M}.
ADD2
This question arose because of the mistake, or rather from not knowing the difference of ( ) and { }. Those who cannot notice this difference cannot search with search pattern 'difference of ( ) and { } in bash'. So the referenced links 'supposed to have solution for this question' cannot be searchable by the people like me. So I think this question is worth being kept as is.
#!/bin/bash
dat=`date +%Y%m%d%H%M`
echo "dat="${dat}
The above code is working code
This question already has answers here:
What's the magic of "-" (a dash) in command-line parameters?
(5 answers)
Closed 1 year ago.
I tried to add generated ssh id_rsa to the gitlab-ci.
Command I have found is echo "$SSH_PRIVATE_KEY" | ssh-add -.
I can not find any information about param - that was added to command ssh-add.
How can I interprate this?
In a man I have found information about running it without any argument and some flags but add single dash is not describe there.
I used ubuntu latest image for this process
As #Aaron said
It's a reference to the standard input of the command, so the output of the piped echo
This question already has answers here:
When do we need curly braces around shell variables?
(7 answers)
Closed 6 years ago.
It is doing something to my path_bash variable but what?
Google pulls up this but I can't find it exactly.
#!/bin/bash
path_bash="$HOME/root/config/bash/"
source "${path_bash}_private.sh"
source "${path_bash}config.sh"
source "${path_bash}utility.sh"
source "${path_bash}workflow.sh"
source "${path_bash}net.sh"
source "${path_bash}makeHTM.sh"
and can I put
path_bash
in another file?
It's used to tell bash where the name of your variable ends.
And example to explain:
$ a="gg"
$ echo $ab
$ echo ${a}b
ggb
This question already has answers here:
Shell command to retrieve specific value using pattern
(3 answers)
Closed 8 years ago.
I have file test.txt contains the following
AA=testing
BB=help
CC=hello
How can i make a bash script that will get each value and assign to a new variable?
#!/bin/bash
var1=testing
var2=help
var3=hello
thanks for the help
First of all a = value is not correct syntax in shell. In shell the spaces are important.
When you have a valid file, you can use the eval function to evaluate that file as a string, or simply source it.
This question already has answers here:
Trouble understanding parameter substitution in a script
(1 answer)
Usage of :- (colon dash) in bash
(2 answers)
Closed 9 years ago.
I've found this in a shell script that I use and I'm having trouble finding a formal description/definition of this syntax:
ACTION=${1:-update}
I'm assuming that if $1 variable does not exist (no command line arguments) then "-update" is used.
It's not esoteric. It's POSIX, and even Bourne. In every shell manpage ever. man bash or man ksh. The assumption is mostly right, if the parameter 1 is unset or empty string, then expand the alternate.
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_02