Special chars in Laravel .env file [duplicate] - laravel

This question already has an answer here:
Escaping the # character in .env file
(1 answer)
Closed 2 years ago.
I'm having troubles using special chars in values of a Laravel .env file.
For example:
DB_PASSWORD=some#secret
Now the env('DB_PASSWORD') is just 'some'
Is there a way to escape characters or some other method to use values like this in the .env file?
In case it makes a difference, my server is running on CentOS 8.2.2004
UPDATE: Forget the whole thing. It turned out it was a different issue altogether. Answer below is correct on the actual question though.

# is for commenting in a .env file. If you want to use # as a value, you need to wrap it in ":
DB_PASSWORD='some#secret'

Related

How do I escape "#g" in sed (with the -global setting)? [duplicate]

This question already has answers here:
Using different delimiters in sed commands and range addresses
(3 answers)
Closed 12 months ago.
I have many repositories with the remote origin set to HTTPS. Now I want to change all origin remotes to SSH.
I am using a command for this in which I want to replace all preceeding url = https://gitlab.mypath/ with git#gitlab.maypath:.
Is there a way to express this with one sed call. Something like:
's#https://gitlab.mypath/#git#gitlab.mypath:#g'
I have to be able to escape the first "#g"
The correct anwers
Switch from s### to s|||
Apart from choosing any character for the delimiter, you can also escape that character: #
The explanation
The character after the s specifies the separator, which must occur three times in your s command.
Thanks
#Cyrus #dan

Bash: how to rename a file to a string containing forward slashes? [duplicate]

This question already has answers here:
Is it possible to use "/" in a filename?
(8 answers)
Closed 1 year ago.
I have a file that I want to rename to a date like "20/02/21", but if I do mv file.txt 20/02/21 it interprets the forward slashes as referencing sub-folders. Is there a way to do this?
No, there's no way to do it. On Unix forward slash / is used to
separate directories and cannot be used in the filename. You have to
use another delimiter - 20\02\21, 20-02-21, 20.02.21 etc.

bash variable eats multiple spaces, turning them to one [duplicate]

This question already has answers here:
When to wrap quotes around a shell variable?
(5 answers)
Closed 3 years ago.
# export var="many spaces"; echo =${var}=
=many spaces=
What is going on here?
Why multiply spaces are turned to one? How to keep all?
You’re simply missing quotations around your variable. Changing your code to this:
$ export var="many spaces"; echo ="${var}"=
=many spaces=
should give the result you’re looking for. One “feature” of bash that you need to watch out for is word splitting, which is based on the value of your IFS (internal field separator) variable. Typically IFS defaults to
IFS=$' \t\n'
so you need to take care in quoting variables that contain spaces, tabs, and newlines.

Why does * put all file names in the argument vector? [duplicate]

This question already has answers here:
What is file globbing?
(1 answer)
Stop shell wildcard character expansion?
(4 answers)
command line * linux [duplicate]
(1 answer)
Closed 4 years ago.
I stumbled upon this while working through the exercises in K&R2. Why does echo * prints the names of all files in the current directory? More generally, when I write a C program that takes command-line arguments, and when I give it * as an argument, it puts the names of all files in its parent directory in to the argument vector. Why does this happen? What is so special about *?
I could not find anything about this in the internet.
This is called globbing. Here's a detailed description. Other wildcards include ? for one character, [abc] for one of a set of characters, and [a-z] for one of a range of characters. This is built into various shells, including Bash.
In response to your comment "I think echo is written in C" — this doesn't matter a bit. Once source code is compiled into an executable containing machine code, it doesn't matter what language it was written in.

In YAML, how do I make a comment over multiple lines [duplicate]

This question already has answers here:
How do you do block comments in YAML?
(11 answers)
Closed 6 years ago.
I know that you can make a single line comment in YAML by using the # tag, but I haven't been able to find something like /* in java that starts a comment & has to be finished off with a */. Does such an operator exist in YAML?
YAML does not support multiple line comments. If you want to use them. You can just try
# this
# is a multiple
# line comment

Resources