抱歉,如果这在其他地方有答案,我不知道如何搜索我的问题。
我在 redhat linux HPC 服务器上运行了一些模拟,我处理文件夹结构以保存输出的代码有一个不幸的错误。我创建文件夹的matlab代码是:
folder = [sp.saveLocation, 'run_', sp.run_number, '/'];
Run Code Online (Sandbox Code Playgroud)
其中sp.run_number是一个整数。我忘了将它转换为字符串,但由于某种原因运行mkdir(folder);(在 matlab 中)仍然成功。事实上,模拟运行顺利,数据被保存到匹配的目录中。
现在,当查询/打印文件夹结构时,我会遇到以下情况:
run_ run_^A/ run_^B/ run_^C/ run_^D/ run_^E/ run_^F/ run_^G/ run_^H/ run_^I/ls: run_ run_? run_? run_? run_? run_? run_? run_? run_? run_? run_?。--progress选项显示:run_\#003/等(我假设)与sp.run_number填充为三位数的整数匹配的数字,所以第 10 次运行是run_\#010/run_ run_ run_ run_ run_ run_ run_ run_ run_ run_?ls | LC_ALL=C sed …为什么ls需要一个单独的进程来执行?我知道为什么像这样的命令cd不能通过分叉机制执行,但是如果ls不分叉就执行有什么危害吗?
在这里发布一些令我感到困惑的东西;将应用服务器从 Jessie 升级到 Stretch 破坏了bash脚本。
经过调查,我们将其范围缩小到cd命令行为的改变。我不是在这里讨论脚本正在做什么是一个好主意,或者它是否可以改进,我只是专注于行为改变/改变心态的意识。
杰西
$echo *-*
xxxx-1.0b xxxx-run
$cd *-*
Run Code Online (Sandbox Code Playgroud)
cd 工作和 cds 到第一个目录;实际上 *-run 是指向同一目录的符号链接。
拉紧
$echo *-*
xxxx-1.0b xxxx-run
$cd *-*
bash: cd: too many arguments
Run Code Online (Sandbox Code Playgroud)
bash 在 Jessie 中为 4.3.30(1),在 Stretch 中为 4.4.12(1)。
为什么 Jessie 和 Stretch 之间的行为会发生变化?
是否可以将命令的输出重定向到cd?例如,我使用搜索目录locate并获得了它的路径。现在,cd我可以将locate输出重定向到cd?
我试过这个:
$ locate Descargas | grep Descargas$
/home/oliver/Descargas
$ locate Descargas | grep Descargas$ | cd
$ locate Descargas | grep Descargas$ > cd
$ locate Descargas | grep Descargas$ < cd
/home/oliver/Descargas
$
Run Code Online (Sandbox Code Playgroud)
没运气。这可能不是特别有用,但我很好奇。
我想知道,如果cd单独将我发送到我的主文件夹,而cd ~也是如此,那么为什么 ~ 是首先添加的?
它是 BASH 特有的,还是它们在另一个 Shell 中的行为会有所不同?
当我cd链接时,我当前的路径以链接的路径为前缀,而不是链接链接到的目录的路径。例如
~/dirlinks/maths$ ls -l logic
lrwxrwxrwx 1 tim tim 71 Jul 27 10:24 logic -> /windows-d/academic discipline/study objects/areas/formal systems/logic
~/dirlinks/maths$ cd logic
~/dirlinks/maths/logic$ pwd
/home/tim/dirlinks/maths/logic
~/dirlinks/maths/logic$ cd ..
~/dirlinks/maths$
Run Code Online (Sandbox Code Playgroud)
我希望将当前路径更改为链接目录的路径,以便我也可以使用链接目录的父目录。除了ls找出链接目录的链接,然后cd进入它,还有哪些更简单的方法可以实现这一目标?例如,cd进入链接后,如何将当前路径更改为链接目录的路径?
如何使用变量 -$BASE在我的 cd 中。我尝试了以下操作,但出现错误
$ cd ~/z/repo_1_ruby_193/
23:23:57 durrantm Castle2012 /home/durrantm/z/repo_1_ruby_193
$ BASE="~/z"
23:24:03 durrantm Castle2012 /home/durrantm/z/repo_1_ruby_193
$ cd $BASE/repo_1_ruby_193
-bash: cd: ~/z/repo_1_ruby_193: No such file or directory
23:24:25 durrantm Castle2012 /home/durrantm/z/repo_1_ruby_193
Run Code Online (Sandbox Code Playgroud) 在 cd 中,bash 帮助页面:
The variable CDPATH defines the search path for the directory containing
DIR. Alternative directory names in CDPATH are separated by a colon (:).
A null directory name is the same as the current directory. If DIR begins
with a slash (/), then CDPATH is not used.
Run Code Online (Sandbox Code Playgroud)
但是我不理解“替代目录”的概念,并且找不到说明冒号 ( :) 与cd命令一起使用的示例。
我正在使用 Zsh 在 Arch 上运行 gnome 3.10.1。我面临的问题是,当我从终端窗口创建新选项卡或窗口时,它会将当前目录重置为我的主目录。
我已经尝试过这个:gnome-terminal: keep track of directory in new tab,但它没有用。
我认为这可能是我的.zshrc文件中的一些配置,因此,我清理了它并只添加了以下行:
. /etc/profile.d/vte.sh
Run Code Online (Sandbox Code Playgroud)
但是,它没有按预期工作。
是的,这个文件存在,这里是它的内容:
# Copyright © 2006 Shaun McCance <shaunm@gnome.org>
# Copyright © 2013 Peter De Wachter <pdewacht@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at …Run Code Online (Sandbox Code Playgroud) 我想找到一个文件,然后进入包含它的目录。我试过了,find /media/storage -name "Fedora" | xargs cd但当然,我的is not a directory错误。
如何使用一行命令进入其父目录?