Sed无法正常工作

问题描述:

我制作了这个bash单行代码,用于列出正在运行的Weblogic实例及其完整路径.当我从shell运行它时,效果很好.

I made this bash one-liner which I use to list Weblogic instances running along with their full paths.This works well when I run it from the shell.

/usr/ucb/ps auwwx | grep weblogic | tr ' ' '\n' | grep security.policy | grep domain | awk -F'=' '{print $2}' | sed 's/weblogic.policy//' | sed 's/security\///' | sort

我试图将其合并到期望脚本中

I tried to incorporate this in an expect script

send "echo Weblogic Processes: ; /usr/ucb/ps auwwx | grep weblogic | tr ' ' '\n' | grep security.policy | grep domain | awk -F'=' '{print \$2}' | sed 's/weblogic.policy//' | sed 's/security\///' | sort ; echo ; echo\r"

但是我得到了这个错误sed:-e表达式1,字符13:`s'的未知选项

but I got this error sed: -e expression #1, char 13: unknown option to `s'

请帮助

在没有仔细计数或测试的情况下,我将尝试在"security \"之后添加另一个\,或者可能删除现有的一个.

Without careful counting or testing, I'd try adding another \ after "security\", or possibly deleting the existing one.

此外,您可以将两种sed合并为一个:sed -e 's/weblogic.policy//' -e 's/security\///'

Also, you can combine the two seds into one: sed -e 's/weblogic.policy//' -e 's/security\///'