在 cygwin 中指定动态配置文件名称的命令/语法
在 linux 命令中指定动态配置文件名称的语法是什么?例如,
perl genhtml /home/$(usrProfile)/*
如果 usrProfile 是动态的,则替换它的语法是什么?
谢谢。
编辑:我在 cygwin 下的 Windows 命令行中运行它。
更新:我尝试执行以下操作:
$ECHO $HOME
chmod 444/home/~username/*
但我收到错误消息,说
No such file or directoryine 1: /home/Administrator
chmod: cannot access '/home/~username/*': No such file or directory
我在 cygwin 主目录中拥有的唯一配置文件是管理员,因此该目录物理存在。
我的目标是能够直接在构建脚本(MsBuild)中或通过 cygwin 的 bash 命令调用上述命令,而不必担心配置文件名称。
谢谢。
What is the syntax for specifying a dynamic profile name in linux command? E.g.
perl genhtml /home/$(usrProfile)/*
What is the syntax to replace usrProfile if it is dynamic?
Thanks.
EDIT: I'm running this in Windows Command line under cygwin.
UPDATE: I have tried doing the following:
$ECHO $HOME
chmod 444/home/~username/*
But I've gotten the error saying
No such file or directoryine 1: /home/Administrator
chmod: cannot access '/home/~username/*': No such file or directory
The only profile I have in the cygwin's home directory is Administrator so the directory exists physically.
My goal is to be able to call the above command without worrying profile name either directly in a build script (MsBuild), or via cygwin's bash command.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
编辑:
在您的更新中,我假设您没有在
echo
之前输入美元符号。另外,我会使用小写命令,即使它们在 Cygwin 下工作 - 它们在其他地方不会。权限设置后需要有一个空格。另外,我怀疑实际用户名中是否有波浪号。您真的确定要盲目地将所有文件设置为相同的权限吗?如果存在现有文件怎么办?您可能真正想做的是更像:
或者
Edit:
In your update, I'm assuming you're not typing the dollar sign before the
echo
. Also, I would use lowercase for commands, even though they work under Cygwin - they won't elsewhere. There needs to be a space after the permission setting. Plus, I doubt there's a tilde in the actual username. And are you really sure you want to blindly set all the files to the same permission? What if there are existing files?What you probably really want to do is something more like:
or
路径名开头的
~/
指定当前用户的主目录。使用~username/
来获取特定用户的主目录。~/
at the beginning of a pathname specifies the current user's home directory. Use~username/
to get a specific user's home directory instead.即使用户的主目录设置为
/home/$user
以外的目录,这也将起作用。This will work even if the user's home directory is set to something other than
/home/$user
.您需要反引号或 $() 表示法。
在最新版本的 Bash 上,两者都运行
program args
,并将程序的输出替换到命令行中。反引号表示法是执行此操作的经典方法,并且适用于大多数 shell。 $() 是最近出现的(尽管我认为它已经存在 10 年了)。 $() 表示法是首选,因为它更容易嵌套 -
prog1 $(prog2 $(prog3))
You want either backticks or $() notation.
On recent versions of Bash, both of those run the
program args
, and substitutes the output of the program into the command line.The backtick notation is the classic way to do this and will work on most shells. The $() is more recent (although I think it's been around for 10 years at this point). The $() notation is preferred because it is easier to nest -
prog1 $(prog2 $(prog3))