我正在创建脚本,我将在路径中找到一个可执行脚本,一旦找到,我将后退两步并转到另一个目录进行备份,但当 cd 到该目录时,我将在目录名称 Cell 中使用星号通配符,但在创建新文件或复制文件等时,带有通配符的/Cell/不接受。我认为,与其将星号视为通配符,不如将其视为目录名称本身。
用简单的方式理解。我通过触摸命令重新创建了它。
有人可以帮我解决这个问题吗?
使用 Cell 的文件列表
# ls -lrt /usr/WebSphere/AppServer70/profiles/Dmgr01/bin/../config/cells/*Cell*/admin-authz.xml
-rw-rw-r-- 1 wasadm wasadm 84047 Mar 28 06:14 /usr/WebSphere/AppServer70/profiles/Dmgr01/bin/../config/cells/lmsdqndpv01Cell07/admin-authz.xml`
创建文件失败,单元格
`# touch /usr/WebSphere/AppServer70/profiles/Dmgr01/bin/../config/cells/*Cell*/test
touch: cannot touch ‘/usr/WebSphere/AppServer70/profiles/Dmgr01/bin/../config/cells/*Cell*/test’: No such file or directory`
使用 *lmsdqndpv01Cell07 创建文件
`# touch /usr/WebSphere/AppServer70/profiles/Dmgr01/bin/../config/cells/lmsdqndpv01Cell07/test`
使用 Cell 的文件列表
`# ls -lrt /usr/WebSphere/AppServer70/profiles/Dmgr01/bin/../config/cells/*Cell*/test
-rw-r--r-- 1 root root 0 Mar 28 07:00 /usr/WebSphere/AppServer70/profiles/Dmgr01/bin/../config/cells/lmsdqndpv01Cell07/test
最佳答案
我通过下面的命令实现了这一点,但想知道是否有任何简单的方法可以做到这一点。
for file in $(find $bin/../config/cells/*Cell*/ -name admin-authz.xml) ;
do
cp $file "$file"_"$LanID"_consoleaccess_`date '+%Y-%m-%d-%H:%M'`
done
关于linux - 如果文件路径包含通配符 (*),则创建或复制文件将不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55396361/