zsh /home/kaffe/.aliases:13:在`|'

时间:2015-08-31 23:11:37

标签: zshrc

我写了一个巨大的单线作为检查工作日志的工具,我想分手和评论,所以我可以在以后理解它。当我完成这一切时,我碰到了这个错误:

  

/home/kaffe/.aliases:13:在“|”

附近解析错误
11 mlog () {
12     cat /home/kaffe/progs/muse/nxaa* \                                     # Look in all muse logs
13     | grep "$(date +'%Y-%m-%d')\|$(date --date '-1 days' +'%Y-%m-%d')" \   # Dynamic search for date - today and yesterday
14     | sed -e 's/ com.*(): / /; \                                           # Start sed, remove irrelevant information
15     s/;/ /;s/;/ /; \                                                       # Remove first two instances of semi-colon in every line
16     s/, severity../ /; \                                                   # Globally remove mention of severity level
17     s/.*New alarm:/    New: &/g; \                                         # If "New alarm:" exists, add "New:" to beginning of line
18     s/ New alarm: / /g1; \                                                 # Globally remove "New alarm:" from line
19     s/.*Alarm cleared:/Cleared: &/g; \                                     # If "Alarm cleared:" exists, add "Cleared:" to beginning
20     s/ Alarm cleared: / /g1; \                                             # Globally remove "Alarm cleared:" from line
21     s/.*Alarm changed:/Changed: &/g; \                                     # If "Alarm changed:" exists, add "Changed:" to beginning
22     s/ Alarm changed: / /g1' \                                             # Globally remove "Alarm changed:" from line
23     -e ''/    New:/s//$(printf "\033[31mNew:\033[0m")/g'' \                # Color "New:" red
24     -e ''/Cleared:/s//$(printf "\033[32mCleared:\033[0m")/g'' \            # Color "Cleared:" green
25     -e ''/Changed:/s//$(printf "\033[33mChanged:\033[0m")/g'' \            # Color "Changed:" yellow
26     | sort -k1.24 \                                                        # Sort from 14th character (date)
27     | egrep -i $1                                                          # Insert custom search pattern, allow regexp, case insensitive
28 }

但该功能似乎按预期工作。我只是想明白为什么会有一个错误,而我糟透了的zsh-fu限制我搞清楚。知道是什么原因可能会对我未来的zsh努力有所帮助。

提前感谢任何贡献。

OS和zsh版本:

$ uname -a
Linux kaffe-noc 3.2.0-4-amd64 #1 SMP Debian 3.2.68-1+deb7u3 x86_64 GNU/Linux
$ zsh --version
zsh 4.3.17 (x86_64-unknown-linux-gnu)

1 个答案:

答案 0 :(得分:1)

您是否在实际代码中有这些评论? 在\之后你不能有任何东西,但是换行符的换行符。

man bash

  

非引用的反斜杠()是转义字符。它保留   随后的下一个字符的字面值,用   例外。如果出现\对,那么   反斜杠本身没有引用,\被视为一行   continuation(也就是说,它从输入流中删除并且   有效地忽略了。)