添加到路径以便文件在任何地方都可用-bash
我正在尝试将几个目录添加到我的路径中,以便该目录及其子目录中的文件可以从命令提示符跨会话访问添加到路径以便文件在任何地方都可用-bash,bash,unix,path,terminal,ubuntu-11.10,Bash,Unix,Path,Terminal,Ubuntu 11.10,我正在尝试将几个目录添加到我的路径中,以便该目录及其子目录中的文件可以从命令提示符跨会话访问 export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/username/OpenFOAM/OpenFOAM-2.1.0/etc/bashrc:/usr/share/texmf-texlive/tex/latex:/etc/crontab:/home/username/Research/Disserta
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/username/OpenFOAM/OpenFOAM-2.1.0/etc/bashrc:/usr/share/texmf-texlive/tex/latex:/etc/crontab:/home/username/Research/Dissertation/wigner/ic/L=lambda:/home/username/Research/Dissertation/wigner/ic/L=2lambda:/home/username/Research/Dissertation/wigner/ic/L=3lambda:/home/username/Research/Dissertation/wigner/ic
附加以下内容
/home/username/Research/Dissertation/wigner/ic/L=lambda:/home/username/Research/Dissertation/wigner/ic/L=2lambda:/home/username/Research/Dissertation/wigner/ic/L=3lambda:/home/username/Research/Dissertation/wigner/ic
到我的.bashrc
的导出路径
行,它没有帮助。我做错了什么?当我试图从say/home/username/Research/deposition/wigner/ic
访问文件时,我做不到
我在这里读过一些帖子,但它们根本没有什么帮助。我是否缺少冒号、分号、美元符号 听起来您可能误解了
$PATH
的用途$PATH
只告诉Bash在哪里查找可执行文件和脚本。例如,此命令:
foo bar.txt
foo/bar baz.txt
将(通常)搜索名为foo
的可执行文件$PATH
,并执行以下命令:
bash foo.sh
. foo.sh
cat foo.txt
vi foo.txt
less foo.txt
将(通常)搜索$PATH
查找foo.sh
,除非当前目录中有foo.sh
;但这些命令:
bash foo.sh
. foo.sh
cat foo.txt
vi foo.txt
less foo.txt
不会在$PATH
中搜索foo.txt
此外,您还可以编写“该目录及其子目录中的文件”,但是$PATH
对子目录没有用处。如果可执行文件名包含/
,Bash将永远不会搜索$PATH
。例如,此命令:
foo bar.txt
foo/bar baz.txt
将运行/foo/bar
,并且不会在$PATH
中搜索名为foo
的目录
编辑后添加:那么,您可以做些什么来代替 最后,您需要在
montage
命令中包含目录信息:
cd /home/username/Research/Dissertation/wigner/ic
montage -geometry +4+4 L=3lambda/three.jpg L=2lambda/two.png output.jpg
如果每次都无法键入目录信息,那么可以在.bashrc
中设置自己的变量,然后显式使用它。例如,.bashrc
可能有:
export IC=/home/username/Research/Dissertation/wigner/ic
export ICL=$IC/L=lambda
export ICL2=$IC/L=lambda2
export ICL3=$IC/L=lambda3
然后你可以写:
montage -geometry +4+4 $ICL3/three.jpg $ICL2/two.png output.jpg
如果您甚至不想记住给定文件所在的子目录,可以使用fileglob:
export IC=/home/username/Research/Dissertation/wigner/ic
export ICLs=$IC/L=lambda*
并写下:
montage -geometry +4+4 $ICLs/three.jpg $ICLs/two.png output.jpg
让贝壳为你找到它。(当然,这只有在不同子目录中的文件之间没有名称冲突时才能正常工作。)听起来您可能误解了
$PATH
的用途$PATH
只告诉Bash在哪里查找可执行文件和脚本。例如,此命令:
foo bar.txt
foo/bar baz.txt
将(通常)搜索名为foo
的可执行文件$PATH
,并执行以下命令:
bash foo.sh
. foo.sh
cat foo.txt
vi foo.txt
less foo.txt
将(通常)搜索$PATH
查找foo.sh
,除非当前目录中有foo.sh
;但这些命令:
bash foo.sh
. foo.sh
cat foo.txt
vi foo.txt
less foo.txt
不会在$PATH
中搜索foo.txt
此外,您还可以编写“该目录及其子目录中的文件”,但是$PATH
对子目录没有用处。如果可执行文件名包含/
,Bash将永远不会搜索$PATH
。例如,此命令:
foo bar.txt
foo/bar baz.txt
将运行/foo/bar
,并且不会在$PATH
中搜索名为foo
的目录
编辑后添加:那么,您可以做些什么来代替 最后,您需要在
montage
命令中包含目录信息:
cd /home/username/Research/Dissertation/wigner/ic
montage -geometry +4+4 L=3lambda/three.jpg L=2lambda/two.png output.jpg
如果每次都无法键入目录信息,那么可以在.bashrc
中设置自己的变量,然后显式使用它。例如,.bashrc
可能有:
export IC=/home/username/Research/Dissertation/wigner/ic
export ICL=$IC/L=lambda
export ICL2=$IC/L=lambda2
export ICL3=$IC/L=lambda3
然后你可以写:
montage -geometry +4+4 $ICL3/three.jpg $ICL2/two.png output.jpg
如果您甚至不想记住给定文件所在的子目录,可以使用fileglob:
export IC=/home/username/Research/Dissertation/wigner/ic
export ICLs=$IC/L=lambda*
并写下:
montage -geometry +4+4 $ICLs/three.jpg $ICLs/two.png output.jpg
让贝壳为你找到它。(当然,只有在不同子目录中的文件之间没有名称冲突时,这项功能才能正常工作。)您可以在
中定义一些变量。bashrc
:
H="/home/username/Research/Dissertation/wigner/ic"
oneLam="$H/L=lambda"
twoLam="$H/L=2lambda"
threeLam="$H/L=3lambda"
因此,可以从任何地方引用文件,如:
user@box:/some/horrendously/deep/path/$ vi $twoLam/some_file.txt
您可以在
.bashrc
中定义几个变量:
H="/home/username/Research/Dissertation/wigner/ic"
oneLam="$H/L=lambda"
twoLam="$H/L=2lambda"
threeLam="$H/L=3lambda"
因此,可以从任何地方引用文件,如:
user@box:/some/horrendously/deep/path/$ vi $twoLam/some_file.txt
您试图调用的文件是否可由用户执行?@choroba否,我正在尝试使用
montage
将图片连接在一起(eps、PNG等),以便将它们并排比较。问题是,这些图片位于不同的目录中……这不是$PATH(或其他任何内容)可以更改的。@choroba所以基本上我被破解了?所有这些文件都有不同的名称吗?您试图调用的文件是否可由用户执行?@choroba不,我正在尝试将图片连接在一起(eps、PNG等)使用蒙太奇
将它们并排比较。问题是,这些图片在不同的目录中…这不是$PATH(或其他任何东西)可以更改的。@choroba所以基本上我被破解了?所有这些文件都有不同的名称吗?好的。。。所以添加到路径对我没有帮助。。。我该怎么办?我试图用蒙太奇将图片连接在一起(eps、PNG等),并将它们并排进行比较。问题是,这些图片在不同的目录中…哦,糟了,我这样做实际上是为了将我的论文
路径保存在一个名为$deshem的变量中!谢谢,我相信这会有用的。好的。。。所以添加到路径对我没有帮助。。。我该怎么办?我试图用蒙太奇将图片连接在一起(eps、PNG等),并将它们并排进行比较。问题是,这些图片在不同的目录中…哦,糟了,我这样做实际上是为了将我的论文
路径保存在一个名为$deshem的变量中!谢谢,我相信这会奏效的。