Sed无法正常工作 [英] Sed does not work in expect

查看:119
本文介绍了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\///'

这篇关于Sed无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆