This question already has answers here:
Are shell scripts sensitive to encoding and line endings?
(14 answers)
How to convert Windows end of line in Unix end of line (CR/LF to LF)
(8 answers)
Closed 29 days ago.
Trying to generate Wireguard key. And stuck with such behavior of echo command.
As you can see FINISH goes to the beginning and I can't understand how to avoid this.
#echo START$(wg genkey)FINISH
FINISH1111111111111111111111111111111111111111111
But in fact, the purpose of the command is to enclose the key in quotes.
With START/FINISH it’s clearer what happens.
#echo \"$(wg genkey)\"
"1111111111111111111111111111111111111111111
As a goal i need something like this, with existing quotes as part of an output.
"1111111111111111111111111111111111111111111"
Related
This question already has answers here:
How do I pass on script arguments that contain quotes/spaces?
(2 answers)
Bash script to cd to directory with spaces in pathname
(14 answers)
Closed 24 days ago.
I have a script that appends the date and time to all files in a folder. I use the script like this...
bash append_date.sh /home/user/Documents/Podcasts/
and that will append the date to all files in the /home/user/Documents/Podcasts/ folder
Problem is that if there is a whitespace in the directory tree it fails to do anything. ie
bash append_date.sh /home/user/Documents/My Stuff/
I have tried passing the following, but that does not work
bash append_date.sh /home/user/Documents/My\ Stuff/
How do I get this script to play nice with whitespaces?
Many thanks for any help.
This question already has answers here:
Batch equivalent of Bash backticks
(5 answers)
How to set commands output as a variable in a batch file [duplicate]
(9 answers)
Closed 3 years ago.
As the question title states, I want to know what control character is used in the windows command line when we want all content within the proceeding brackets to be evaluated as the output one expects if that content were executed on a separate command line for example in Linux to assign a value to a variable:
variable=$(a valid command sequence);
This question already has answers here:
How to execute a bash command stored as a string with quotes and asterisk [duplicate]
(5 answers)
Command not found error in Bash variable assignment
(5 answers)
Closed 4 years ago.
I have an application in Unix. I use the below command to connect to it:
./application -a "connect"
I want to do the same through the shell script, for which i assigned the command line to a variable like:
newcommand = './application -a "connect"'
$newcommand
But this is not working.
However the first part of the code is working. i.e.,:
newcommand = "./application"
$newcommand
Can anyone point out what i am missing.
Believe it or not, this:
newcommand = "./application"
...has the shell run the command, newcommand with the arguments, =, and ./application.
In shell simple assignments cannot have any unprotected whitespace or they'll be interpreted as a command.
Consider:
newcommand=./application
$newcommand
...notice that there's no space around the = sign in the assignment.
This question already has answers here:
What does an echo followed immediately by a slash do in a Windows CMD file?
(1 answer)
Batch file new line problems
(2 answers)
Closed 4 years ago.
I was reading this question where I saw not one but two separate answers where the code provided used a form of echo( with no closing parenthesis.
What does this form of the command do?
I am familiar with echo. to perform an echo of an empty line but I've not seen this other form before.
This question already has an answer here:
Windows shell string operations (changing backslash to slash)
(1 answer)
Closed 9 years ago.
whats the easiest way of converting all backslashes to forward in a path in a batch file, since I need to use bash for execution.
SET "string=D:\path\to\folder"
ECHO %string:\=/%
Basically, you need first to store the string value into an environment variable, then use the following template:
%variable:str1=str2%
to replace every occurrence of str1 in variable with str2.
You can always remind yourself about this pattern by invoking SET /? from the command prompt.
echo 'C:\Program Files\Program' | sed -e 's/\\/\//g'