Problem executing TCL script from Bourne Shell (redirection trouble)

I am working with VMD (a molecular dynamics visualization package) and I want to open VMD from a Perl script, run a Tcl script, print the output to a log file, then close VMD and return to the Perl script. The ordinary syntax to do this is: system("vmd -dispdev text -eofexit < program.tcl > LOG"); which breaks down as follows, as best as I understand: system(""); : executes B

从Bourne Shell执行TCL脚本时出现问题(重定向问题)

我正在使用VMD(分子动力学可视化包),我想从Perl脚本中打开VMD,运行Tcl脚本,将输出打印到日志文件,然后关闭VMD并返回到Perl脚本。 执行此操作的普通语法是: system("vmd -dispdev text -eofexit < program.tcl > LOG"); 按照我的理解,最好如下所示: system(""); :执行包含在引号中的Bourne Shell命令 vmd :调用VMD -dispdev text :以文本模式打开VMD -eofexit :在达到STDIN上的EOF时终止

Why does the wc utility generate multiple lines with "total"?

I am using the wc utility in a shell script that I run from Cygwin, and I noticed that there is more than one line with "total" in its output. The following function is used to count the number of lines in my source files: count_curdir_src() { find . '(' -name '*.vb' -o -name '*.cs' ')' -a '!' -iname '*.Designer.*' -a '!' -iname '.svn' -print0 | xargs -0 wc -l } Bu

为什么wc实用程序会用“total”生成多行?

我在一个从Cygwin运行的shell脚本中使用了wc实用程序,并且我注意到其输出中有多行“total”。 以下函数用于计算我的源文件中的行数: count_curdir_src() { find . '(' -name '*.vb' -o -name '*.cs' ')' -a '!' -iname '*.Designer.*' -a '!' -iname '.svn' -print0 | xargs -0 wc -l } 但是它对于某个目录的输出如下所示: $ find . '(' -name '*.vb' -o -name '*.cs' ')' -a '!' -iname '*.Designer.*'

how to split in unix using special character

This question already has an answer here: Extract filename and extension in Bash 35 answers $ python -c "import os; base, ext = os.path.splitext(os.path.basename('/home/user/pigscripts/abc.pig')); print base" pig

如何使用特殊字符在unix中分割

这个问题在这里已经有了答案: 在Bash中提取文件名和扩展名35个答案 $ python -c "import os; base, ext = os.path.splitext(os.path.basename('/home/user/pigscripts/abc.pig')); print base" pig

How to pass command line arguments to a shell alias?

How do I pass the command line arguments to an alias? Here is a sample: alias mkcd='mkdir $1; cd $1;' But in this case the $xx is getting translated at the alias creating time and not at runtime. I have, however, created a workaround using a shell function (after googling a little) like below: function mkcd(){ mkdir $1 cd $1 } Just wanted to know if there is a way to make aliases that

如何将命令行参数传递给shell别名?

如何将命令行参数传递给别名? 这是一个示例: alias mkcd='mkdir $1; cd $1;' 但是在这种情况下,$ xx会在创建时间的别名时进行翻译,而不是在运行时进行翻译。 不过,我已经创建了一个解决方法,使用一个shell函数(google搜索一下之后),如下所示: function mkcd(){ mkdir $1 cd $1 } 只是想知道是否有办法让别名接受CL参数。 顺便说一句 - 我使用'bash'作为我的默认shell。 你找到了方法:创建一

How to check if command exists in a shell script?

I am writing my first shell script. In my script I would like to check if a certain command exists, and if not, install the executable. How would I check if this command exists? if #check that foobar command doesnt exist then #now install foobar fi In general, that depends on your shell, but if you use bash, zsh, ksh or sh (as provided by dash), the following should work: if ! type "$foo

如何检查命令是否存在于shell脚本中?

我正在编写我的第一个shell脚本。 在我的脚本中,我想检查某个命令是否存在,如果没有,请安装可执行文件。 我将如何检查该命令是否存在? if #check that foobar command doesnt exist then #now install foobar fi 一般来说,这取决于你的shell,但是如果你使用bash,zsh,ksh或sh(由破折号提供),下面的代码应该可以工作: if ! type "$foobar_command_name" > /dev/null; then # install foobar here fi 对

How to check if Docker is installed in a Unix shell script?

This question already has an answer here: Check if a program exists from a Bash script 29 answers 使用rickdenhaan评论中的答案的建议: if [ -x "$(command -v docker)" ]; then echo "Update docker" # command else echo "Install docker" # command fi 这一个为我工作: if [[ $(which docker) && $(docker --version) ]]; then echo "Update docker" # command else echo "I

如何检查Docker是否安装在Unix shell脚本中?

这个问题在这里已经有了答案: 检查一个程序是否存在来自Bash脚本的29个答案 使用rickdenhaan评论中的答案的建议: if [ -x "$(command -v docker)" ]; then echo "Update docker" # command else echo "Install docker" # command fi 这一个为我工作: if [[ $(which docker) && $(docker --version) ]]; then echo "Update docker" # command else echo "Install docker" # comma

custom icon in dialog

I have a file in my current directory Icon.png . How do I make this the icon for an applescript dialog? I have tried $ osascript -e 'display dialog "Hey" with icon file "./Icon.png"' 0:54: execution error: File file ./Icon.png wasn’t found. (-43) So how can I get a local image and use it as the icon in a dialog? I am happy to convert the image to a .icns if necessary. As mentioned in th

定制图标在对话框中

我在当前目录Icon.png有一个文件。 我如何使这个applescript对话框的图标? 我努力了 $ osascript -e 'display dialog "Hey" with icon file "./Icon.png"' 0:54: execution error: File file ./Icon.png wasn’t found. (-43) 那么如何获取本地图像并将其用作对话框中的图标? 如果需要,我很乐意将图像转换为.icns 。 正如评论中提到的那样,默认情况下,AppleScript不会理解POSIX路径,您需要给它一个完整的,而不是

ipython shell awk : Escaping "$" sign

I am figuring out the Ipython shell support. Its seems awk doesn't work ie following command !ls -l | awk '{print $1}' just prints "1". How do I pass the "$" sign correctly to shell. I am using zsh. 两个美元符号给你一个字面的美元符号,所以试试: !ls -l | awk '{print $$1}' 尝试将$转义为$ !ls -l | awk '{print $1}'

ipython shell awk:转义“$”符号

我计算出Ipython shell支持。 它似乎awk不工作,即下面的命令 !ls -l | awk '{print $1}' 只是打印“1”。 如何正确地将“$”标志传递给shell。 我正在使用zsh。 两个美元符号给你一个字面的美元符号,所以试试: !ls -l | awk '{print $$1}' 尝试将$转义为$ !ls -l | awk '{print $1}'

include option for multiple file types?

When I want to grep all the html files in some directory, I do the following grep --include="*.html" pattern -R /some/path which works well. The problem is how to grep all the html,htm,php files in some directory? From this Use grep --exclude/--include syntax to not grep through certain files, it seems that I can do the following grep --include="*.{html,php,htm}" patt

包含多种文件类型的选项?

当我想要grep某些目录中的所有html文件时,我会执行以下操作 grep --include="*.html" pattern -R /some/path 这工作得很好。 问题是如何在某些目录中grep所有的html,htm,php文件? 从这个使用grep --exclude / - 包括语法不通过某些文件grep,似乎我可以做到以下几点 grep --include="*.{html,php,htm}" pattern -R /some/path 但可悲的是,它不适合我。 仅供参考,我的grep版本是2.5.1。

How to kill all processes matching a name?

Say I want to kill every process containing the word amarok. I can print out the commands I want to execute. But how do I actually make the shell execute them. ie. ps aux | grep -ie amarok | awk '{print "kill -9 " $2}' Output: kill -9 3052 kill -9 3071 kill -9 3076 kill -9 3077 kill -9 3079 kill -9 3080 kill -9 3082 kill -9 3083 kill -9 3084 kill -9 3085 kill -9 3086 kill -9 3087 kill -9 3088

如何杀死所有匹配名称的进程?

假设我想杀死包含amarok这个词的每个进程。 我可以打印出我想要执行的命令。 但是我怎么才能让shell执行它们。 即。 ps aux | grep -ie amarok | awk '{print "kill -9 " $2}' Output: kill -9 3052 kill -9 3071 kill -9 3076 kill -9 3077 kill -9 3079 kill -9 3080 kill -9 3082 kill -9 3083 kill -9 3084 kill -9 3085 kill -9 3086 kill -9 3087 kill -9 3088 kill -9 3089 kill -9 4031 从man 1 pkill -f The p