创建目录时获取权限被拒绝以及如何将后缀添加到 .exe 到目录中的每个文件
Getting permission denied while creating a directory and how to add suffix to .exe to each files in a directory
我想创建一个目录,比如 source_dir 并向该目录中添加一些没有内容的虚拟文件,例如 file1.txt、file2.sh 等
现在我想创建另一个目录 destination_dir 并将所有文件从 source_dir 移动到 destination_dir 但所有从 source_dir 移动的文件应该是后缀为.exe
示例:
source_dir
file1.txt file2.sh
destination_dir 应该输出为
file1.txt.exe file2.sh.exe
我尝试过的:
- 我使用了
mkdir source_dir
-> 但是出现错误无法创建目录。权限被拒绝。
touch file1.txt file2.sh
-> 我想用这个命令来创建没有内容的文件,但不能自己创建目录。
- 一旦错误解决并在
source_dir
中创建了文件,那么我将使用
mv .* source_dir destination_dir
-> 要一次移动所有文件但是对于这个命令我不确定这是否有效
- 然后如何给所有文件加上.exe后缀也是我的一个难题,卡住了。
有人可以帮我解决创建目录的错误以及如何为每个文件添加后缀吗?
I used mkdir source_dir -> But getting error cannot create directory. Permission denied.
您似乎没有权限在这里创建一个fodler。您可以使用 sudo mkdir source_dir
,但最好将文件夹放在您具有 EG 写入权限的目录中。 $家.
Once error is resolved and files are created in source_dir then I will use mv .* source_dir destination_dir -> To move all the files at once but for this command I am not sure whether this will work or not
从 source_dir 移动使用 mv .* destination_dir
。 (IE,首先 cd source_dir
然后 运行 上面的移动命令)
Then how to suffix all the files with .exe is also challenging to me and got stuck.
您将不得不遍历文件并将它们一个接一个地移动。
for i in * ; do mv "$i" "${i}.exe" ; done
我想创建一个目录,比如 source_dir 并向该目录中添加一些没有内容的虚拟文件,例如 file1.txt、file2.sh 等
现在我想创建另一个目录 destination_dir 并将所有文件从 source_dir 移动到 destination_dir 但所有从 source_dir 移动的文件应该是后缀为.exe
示例:
source_dir
file1.txt file2.sh
destination_dir 应该输出为
file1.txt.exe file2.sh.exe
我尝试过的:
- 我使用了
mkdir source_dir
-> 但是出现错误无法创建目录。权限被拒绝。 touch file1.txt file2.sh
-> 我想用这个命令来创建没有内容的文件,但不能自己创建目录。- 一旦错误解决并在
source_dir
中创建了文件,那么我将使用mv .* source_dir destination_dir
-> 要一次移动所有文件但是对于这个命令我不确定这是否有效 - 然后如何给所有文件加上.exe后缀也是我的一个难题,卡住了。
有人可以帮我解决创建目录的错误以及如何为每个文件添加后缀吗?
I used mkdir source_dir -> But getting error cannot create directory. Permission denied.
您似乎没有权限在这里创建一个fodler。您可以使用 sudo mkdir source_dir
,但最好将文件夹放在您具有 EG 写入权限的目录中。 $家.
Once error is resolved and files are created in source_dir then I will use mv .* source_dir destination_dir -> To move all the files at once but for this command I am not sure whether this will work or not
从 source_dir 移动使用 mv .* destination_dir
。 (IE,首先 cd source_dir
然后 运行 上面的移动命令)
Then how to suffix all the files with .exe is also challenging to me and got stuck.
您将不得不遍历文件并将它们一个接一个地移动。
for i in * ; do mv "$i" "${i}.exe" ; done