2013-09-24 161 views
0

我想编写一个脚本,用一些标签打开一个shell,我希望每个标签自动执行一些东西。由于某种原因,当我管道命令它不起作用。shell脚本中的管道命令

gnome-terminal \ 
    --tab-with-profile=Titleable -t "A" \ 
    --tab-with-profile=Titleable -t "B" -e "sudo tail -f /var/log/syslog" \ 
    --tab-with-profile=Titleable -t "C" -e "sudo tail -f /var/log/syslog | grep txt" 

由于某种原因,一种TAB用&乙工作,但在C grep的TXT被忽略。

任何人都知道为什么?

感谢 垫

回答

0

使用shell打电话给你的命令:

gnome-terminal \ 
    --tab-with-profile=Titleable -t "A" \ 
    --tab-with-profile=Titleable -t "B" -e "sudo tail -f /var/log/syslog" \ 
    --tab-with-profile=Titleable -t "C" -e 'sh -c "sudo tail -f /var/log/syslog | grep txt"' 
+0

这是一个类型:)仍然无法正常工作。 – user690936

+0

@ user690936使用shell来调用命令可以很好地与我一起工作。你看到的任何错误? – konsolebox

+0

@ user690936我的意思是:'-e'sh -c“sudo tail -f/var/log/syslog | grep txt”''。这不是你原来的命令的一部分。 – konsolebox