我在这里可能弄错了,但我正在观察有人使用 cd 命令进行导航,并且在没有实际执行它的情况下,他们能够显示当前文件夹的文件夹内容。
那么,如果我键入cd Downloads/Stuff然后不按 Enter 键,我可以列出 Download/Stuff 文件夹的内容吗?
我创建了自己的函数,而不是普通的 cd
function cd {
builtin cd "$@" && ls -F
}
Run Code Online (Sandbox Code Playgroud)
当我使用像这样的命令时,这非常有用,cd someDir/subDir但当我通过 zsh 的 auto_cd 更改目录时却不起作用someDir/subDir。
有没有办法自定义调用什么命令auto_cd?
是否可以设置符号链接,以便cd在链接上调用重定向到链接路径?有点像这样:
$ ln /A/B /B/C
$ cd /A/B
$ pwd
/B/C
$
Run Code Online (Sandbox Code Playgroud) 我找不到whereis将cd命令的输出传递给同一行中的命令的方法,因此我不必cd在第二步中执行此操作。
我试过像下面这样传递:
cd $(whereis node_modules)
Run Code Online (Sandbox Code Playgroud)
或者
cd "`dirname $(whereis node_modules)`"
Run Code Online (Sandbox Code Playgroud)
还
cd "$(whereis node_modules)"
Run Code Online (Sandbox Code Playgroud)
但上述方法均无效。
有人能找到上面代码中应该有什么问题吗?
我有一个位于里面的目录/var/www/html。我将这个目录mv从example1重命名为example2。
如何在名称更改时输入新命名的目录?
你将如何实现这一目标?可以用find, mmin,0*60吗?
我的目标是重命名和输入一个操作而不是两个不同的操作。
理想情况下,我的目标是单行解决方案,而无需在系统中自定义任何内容。
我有一个经常使用的目录。假设它是:
/etc/insserv.conf.d/testname
Run Code Online (Sandbox Code Playgroud)
我在我的中设置了一个变量/root/.bashrc:
mydir=/etc/insserv.conf.d/testname
Run Code Online (Sandbox Code Playgroud)
现在,我可以通过这个命令打开这个目录
cd $mydir
Run Code Online (Sandbox Code Playgroud)
但我真的不喜欢那个角色$。有什么解决方法可以实现这个吗?我的意思是:我只想通过 来打开这个目录cd mydir,在 中可以Ubuntu 16.04吗?
转到包含特定文件的目录的最佳方法是什么?(假设我们从我们希望搜索的根开始)。我正在使用 Cygwin。
解决方案:我的最终解决方案是将其放入我的 .bashrc 文件中。
jump2_func() {
cd "$(find . -name $1 -printf %h -quit 2>/dev/null)"
}
alias jump2=jump2_func
Run Code Online (Sandbox Code Playgroud) 在 Ranger 中,您可以转到带有g. 当您键入时,g它会为您提供一个可以非常轻松前往的地点列表。比如g,然后p带我去/tmp。我如何回到我所在的目录?什么是游侠当量cd -?
当我输入时,g我没有看到cd返回选项。
bash的手册页(和help cd)提到cd支持-@参数(“在支持它的系统上”)以“将具有扩展属性的文件呈现为包含文件属性的目录”
有使用这个的例子吗?(理想情况下使用常见的文件,或者使用创建示例的设置(我对xattrcurrnelt 不太熟悉))
哪里支持?到处都支持xattrs,还是需要更多内核支持?(即我可以将其与xattrOS X、Solaris、FreeBSD、Linux 等支持版本一起使用吗)
我的猜测是,如果一个文件/path/f具有xattr我可以执行的操作cd -@ /path/f,ls然后会将 xattrs 显示为模拟“目录”中的(模拟)“文件” /path/f?(为此,我假设内核需要对此模拟提供某种支持,因为诸如lslive Outside之类的东西bash,这意味着bash无法进行模拟)
当我能够切换到目录本身时,为什么我无法 cd 进入具有 700 权限、由普通用户(作为 root)拥有的符号链接目录?
\n\nttucker@plato:/tmp# uname -a\nLinux plato 4.4.0-140-generic #166~14.04.1-Ubuntu SMP Sat Nov 17 01:52:43 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux\n\nttucker@plato:/tmp$ whoami\nttucker\nttucker@plato:/tmp$ mkdir -v test_dir\nmkdir: created directory \xe2\x80\x98test_dir\xe2\x80\x99\nttucker@plato:/tmp$ chmod -v 700 test_dir\nmode of \xe2\x80\x98test_dir\xe2\x80\x99 changed from 0775 (rwxrwxr-x) to 0700 (rwx------)\nttucker@plato:/tmp$ ln -s -v test_dir/ test_sym\n\xe2\x80\x98test_sym\xe2\x80\x99 -> \xe2\x80\x98test_dir/\xe2\x80\x99\nttucker@plato:/tmp$ ls -ld test_*\ndrwx------ 2 ttucker ttucker 4096 Mar 21 10:29 test_dir\nlrwxrwxrwx 1 ttucker ttucker 9 Mar 21 10:29 test_sym -> test_dir/\n\nttucker@plato:/tmp$ sudo su -\nroot@plato:~# whoami\nroot\nroot@plato:~# …Run Code Online (Sandbox Code Playgroud) cd-command ×10
command-line ×4
bash ×3
shell ×2
symlink ×2
cygwin ×1
directory ×1
linux-kernel ×1
ls ×1
mv ×1
permissions ×1
ranger ×1
variable ×1
xattr ×1
zsh ×1