假设命令为my_command
此命令必须在当前工作目录中准备特定文件(文件1,文件2和文件3)。
因为我经常在许多不同的目录中使用my_command
,所以我想将某些文件保留在某个目录中,然后在工作目录中不使用这三个文件地执行my_command
。
我的意思是我不想将这三个文件复制到每个工作目录中。
例如:
包含三个文件/home/chest
工作目录:/home/wd
如果我执行命令my_command
,它将自动识别/home/chest/
中的三个文件
我认为添加$ PATH的方式与添加可执行文件相似,而不仅仅是文件。
答案 0 :(得分:1)
似乎文件需要位于vasp_std
命令的当前工作目录中,才能按预期工作,我认为您只需将所有文件添加到主目录的include文件夹中,然后创建从脚本到此文件夹的符号链接。在脚本末尾,符号链接将被删除:
#!/bin/bash
# create a symbolic link to our resource folder
ln -s ~/include src
# execute other commands here
# finally remove the symbolic link from the current directory
unlink src
如果vasp_std
命令要求将文件直接放置在当前工作目录下,则可以为每个文件创建符号链接:
#!/bin/bash
# create link for to all resource files
for file in ~/include/*
do
ln -s $file `basename $file`
done
# execute other commands here
# remove any previously created links
for file in ~/include/*
do
unlink `basename $file`
done