Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在每个路径上使用当前目录设置unix别名_Unix_Path_Find_Cygwin_Alias - Fatal编程技术网

如何在每个路径上使用当前目录设置unix别名

如何在每个路径上使用当前目录设置unix别名,unix,path,find,cygwin,alias,Unix,Path,Find,Cygwin,Alias,我的别名在/directory上工作,但在路径更改时停止工作 alias exesh='chmod +x $(find . -maxdepth 1 -name '*.sh')' 我是Unix新手,欢迎任何帮助 *我用的是cygwin,这是不是问题* Bash在这个问题上这么说 find: paths must precede expression: 2b.sh Usage: find [-H] [-L] [-P] [-Olevel] [-D help|tree|sear

我的别名在/directory上工作,但在路径更改时停止工作

    alias exesh='chmod +x $(find . -maxdepth 1 -name '*.sh')'
我是Unix新手,欢迎任何帮助 *我用的是cygwin,这是不是问题* Bash在这个问题上这么说


    find: paths must precede expression: 2b.sh
    Usage: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec] [path...] [expression]
    chmod: missing operand after '+x'
    Try 'chmod --help' for more information.
但是如果我粘贴在命令行chmod+x$find上-maxdepth 1-名称'*.sh'它工作正常,因此我认为它取决于当前目录。

请尝试:

alias exesh='chmod +x $(find . -maxdepth 1 -name '"'"'*.sh'"'"')'
你的问题是你的虱子里面有虱子-。勾号和引号-可以自由连接,因此这是在勾号中对勾号进行编码的可靠方法


我还打算建议使用find-exec而不是命令扩展,但在这种结构中,我找不到从find中转义+字符的方法。

有了关于使用find-exec的建议,我终于解决了我的问题。解决办法是:
别名exesh='find-name*.sh-exec/bin/chmod+x{}\;'

根据您的建议,我尝试将外部记号改为背面记号,现在您的别名为exesh=`chmod+x$find-maxdepth 1-名称“”*.sh“”`?不,现在我有了:别名exesh=`chmod+x$find-maxdepth 1-name'*.sh'`我认为这不会真正起作用`command`与$command相同。它可能在您创建别名的目录中工作,但我打赌它在其他目录中不会工作。输入alias exesh时会发生什么情况?