Skip to main content

Powershell: Copy-Item doesn’t work when file name contains square bracket ([]) characters

· One min read

I have a file whose name contains square bracket characters, and I want to copy the file to another location via Powershell.

So I use the Copy-Item founcation to do this. like this:

Copy-Item -Path "C:\FileTest\1\[Control]Test.txt" -Destination "C:\FileTest\2\[Control]Update.txt"

No errors occurred when executing the script, but the target file was not copied either.

After looking through the official document, I found that changing the -Path parameter to the -LiteralPath parameter will make the script work. It is because the -Path parameter allows wildcard characters, square bracket characters will be treated as special usage. For example:

Copy-Item -LiteralPath "C:\FileTest\1\[Control]Test.txt" -Destination "C:\FileTest\2\[Control]Update.txt"

References:

Follow the official document to install docker on debian/jessie meets an error

· 2 min read

Update the apt package index and install packages to allow apt to use repository over HTTPS:

apt-get update
apt-get install \
ca-certificates \
curl \
gnupg \
lsb-release

Add Docker’s official GPG key:

curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

Use the following command to set up the stable repository

echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian \
$(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null

Install Docker Engine

apt-get update
apt-get install docker-ce docker-ce-cli containerd.io

When execute apt-get upate, it’s occurs an error:

Get:12 https://download.docker.com jessie/stable Translation-en [391 B]
Ign https://download.docker.com jessie/stable Translation-en
Fetched 44.8 kB in 3s (14.7 kB/s)
Reading package lists... Done
W: GPG error: https://download.docker.com jessie InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 7EA0A9C3F273FCD8

Execute the following scripts can easily fix this error:

curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add -

But you may also encounter other errors during the installation that requires more follow-up. So the better solution is update debian jessie 8 to stretch 9, then to install docker again.

reference: https://stackoverflow.com/questions/60137344/docker-how-to-solve-the-public-key-error-in-ubuntu-while-installing-docker

ClustrMaps