我尝试使用sudo cd name_of_dir但收到错误消息:
sudo: cd: command not found
Run Code Online (Sandbox Code Playgroud)
有没有其他方法可以进入另一个拥有 700 权限的用户拥有的目录?
我只想写一个脚本来改变我的目录。
我将以下命令放在文件中 /home/alex/pathABC
#!/bin/sh
cd /home/alex/Documents/A/B/C
echo HelloWorld
Run Code Online (Sandbox Code Playgroud)
我做了
chmod +x pathABC
Run Code Online (Sandbox Code Playgroud)
在终端中,在 中/home/alex,我运行了./pathABC,但输出只是HelloWorld并且当前目录未更改。
那么有什么问题呢?
我想在终端中输入以下文件夹:
Milano, Torino (Jan)-Compressed
Run Code Online (Sandbox Code Playgroud)
我应该如何编写cd进入这个目录的命令?
空间和其他一些特殊字符,例如\,*,),(和?事业问题,当我尝试在命令行或脚本,例如使用它们:
Milano, Torino (Jan)-Compressed
Run Code Online (Sandbox Code Playgroud)
通常如何在终端中输入包含特殊字符的文件或目录名称?
我cd -今天错误地输入了终端,我收到一条错误消息:
bash: cd: OLDPWD not set
Run Code Online (Sandbox Code Playgroud)
不幸的是,man cd不存在。
No manual entry for cd
Run Code Online (Sandbox Code Playgroud)
它实际上有什么作用?
如何在最新版本的 Ubuntu 12.10 中将目录更改为从主文件夹下载的目录?我试过了cd /downloads,但它给出了一个错误,说没有这样的目录。
我编写了一个 bash 脚本,它创建一系列目录并将项目克隆到选定的目录。
为此,我需要到cd每个目录(project 1和project 2),但脚本不会cd到第二个目录,也不会执行命令。
相反,它会cd在project2目录中克隆后停止。为什么不调用cd_project1下面代码中的函数?
#!/bin/bash
#Get the current user name
function my_user_name() {
current_user=$USER
echo " Current user is $current_user"
}
#Creating useful directories
function create_useful_directories() {
if [[ ! -d "$scratch" ]]; then
echo "creating relevant directory"
mkdir -p /home/"$current_user"/Downloads/scratch/"$current_user"/project1/project2
else
echo "scratch directory already exists"
:
fi
}
#Going to project2 and cloning
function cd_project2() {
cd /home/"$current_user"/Downloads/scratch/"$current_user"/project1/project2 &&
git clone …Run Code Online (Sandbox Code Playgroud) 我刚刚将我的 Ubuntu 16.04 升级到 17.04,发现cd命令有点问题。
假设我有两个文件夹:album-01&album-02
在 Ubuntu 16.04 中,如果我这样做cd album*,它将转到找到的第一个文件夹album-01
但是在新的 Ubuntu 17.04 中,如果我这样做cd album*会导致我
-bash: cd: too many arguments
如何cd像cd在 Ubuntu 16.04 中一样在 Ubuntu 17.04中制作?
问题是有时我输入cd错误,然后将我带到主目录。
例如,我在一个包含隐藏目录和可见目录的目录中,我快速按cd+tab将我带到主目录
我经常在 bash 中键入这些命令:
mkdir something
cd something
Run Code Online (Sandbox Code Playgroud)
我几乎从不这样做:
mkdir something
ls # something in the current directory, not ./something/
Run Code Online (Sandbox Code Playgroud)
从来没有这个:
mkdir something something2
Run Code Online (Sandbox Code Playgroud)
我怎样才能mkdir cd进入新创建的目录?我的意思是,如果 I mkdir something,则命令cd something在之后立即执行。
例子:
$ pwd
/home/me
$ mkdir something
$ pwd
/home/me/something
Run Code Online (Sandbox Code Playgroud) cd-command ×10
command-line ×8
bash ×4
scripts ×2
coreutils ×1
directory ×1
filename ×1
mkdir ×1
permissions ×1
sudo ×1