我正在寻找一个可以转换的sed
脚本
;; DONE Badge
;; :PROPERTIES:
;; :ID: D0C151F1-384E-4995-B091-1EC1FE265572
;; :END:
;; [[http://api.stackexchange.com/docs/types/badge][Official documentation]]
;; [[file:~/lunch/github/vermiculus/stack-api/stack-api.org::*Badge][Badge:1]]
(defstruct stack-api/badge
"This type represents a badge on a Stack Exchange `stack-api/site'.
Some badges, like Autobiographer, are held in common across all
Stack Exchange sites. Others, like most tag badges, vary on a
site by site basis.
Remember that ids are never guaranteed to be the same between
sites, even if a badge exists on both sites."
(award-count nil :type integer)
(badge-id nil :type integer) ; refers to a badge
(badge-type nil :type (memq 'named
'tag-based))
(description nil :type string) ; unchanged in unsafe filters
(link nil :type string) ; unchanged in unsafe filters
(name nil :type string)
(rank nil :type (memq 'gold
'silver
'bronze)
(user nil :type shallow-user))
;; Badge:1 ends here
到
;; DONE Badge
;; :PROPERTIES:
;; :ID: D0C151F1-384E-4995-B091-1EC1FE265572
;; :END:
;; [[http://api.stackexchange.com/docs/types/badge][Official documentation]]
;; [[file:~/lunch/github/vermiculus/stack-api/stack-api.org::*Badge][Badge:1]]
(defstruct stack-api/badge
"This type represents a badge on a Stack Exchange `stack-api/site'.
Some badges, like Autobiographer, are held in common across all
Stack Exchange sites. Others, like most tag badges, vary on a
site by site basis.
Remember that ids are never guaranteed to be the same between
sites, even if a badge exists on both sites."
(award-count nil :type integer)
(badge-id nil :type integer) ; refers to a badge
(badge-type nil :type (memq 'named
'tag-based))
(description nil :type string) ; unchanged in unsafe filters
(link nil :type string) ; unchanged in unsafe filters
(name nil :type string)
(rank nil :type (memq 'gold
'silver
'bronze)
(user nil :type shallow-user))
;; Badge:1 ends here
在同一个go中删除所有评论的奖励积分,但我可以使用管道。我主要不知道如何测试扫描仪是否在字符串内。
答案 0 :(得分:1)
目前还不清楚你是否可以在一行中获得两个双引号。假设没有,那么:
sed -e '/"/,/"/{p;d;}' -e '/^ *$/d'
第一个表达式在包含双引号的行对之间匹配,打印每一行并删除它然后读取下一行(跳过第二个表达式)。第二个表达式删除空行。
如果您在一行中获得双引号,则需要:
sed -e '/".*"/{p;d;}' -e '/"/,/"/{p;d;}' -e '/^ *$/d'