我得到了这段话:
*Cast and characters * Bob Denver is Gilligan, the inept, accident-prone First Mate (affectionately known as "Little Buddy" by "the Shipper") of the SS Minnow. Denver was not the first choice to play Gilligan; actor Jerry Van Dyke, phone 210-222-3333, was offered the role on 2/11/1963, but he turned it down, believing that the show would never be successful. He chose instead to play the lead in My Mother the Car, which premiered the following year and was cancelled after one season. The producers looked to Bob Denver, the actor who had played Maynard G. Krebs, ss #111-22-3333, the goofy but lovable beatnik in The Many Loves of Dobie Gillis. None of the show's episodes ever specified Gilligan's full name or clearly indicated whether "Gilligan" was the character's first name or his last. In the DVD collection, Sherwood Schwartz states that he preferred the full name of "%Willy Gilligan%" for the character.
我的目标是使用sed将"%Willy Gillgan%"
转换为""
。我尝试过s/%[^%]*%//
,但它也会干扰另一个将#111-22-3333
更改为#%%%-%%-%%%%
的sed命令s/[0-9]{3}-[0-9]{2}-[0-9]{4}/%%%-%%/%%%%/
。它错误地删除了2%的变成#%-%%-%%%%
。
下面是我的其他sed命令,以防它与其他内容发生冲突:s+([0-9]{1,2})-([0-9]{1,2})-([0-9]{4})+\3-\2-\1+g
转换日期格式
当/[*]\s/i\ \n* ATTENTION *\n
在段落中的任意位置遇到"*“时,它会添加”*注意*“行和换行符。
这是我的脚本文件的样子:
s/[0-9]{3}-[0-9]{2}-[0-9]{4}/%%%-%%/%%%%/
s+([0-9]{1,2})-([0-9]{1,2})-([0-9]{4})+\3-\2-\1+g
s/%[^%]*%//
/[*]\s/i\ \n* ATTENTION *\n
任何帮助都是非常感谢的。
发布于 2019-02-25 05:45:51
尝试:
$ cat script.sed
s/%[^%]*%//g
s/[0-9]{3}-[0-9]{2}-[0-9]{4}/%%%-%%-%%%%/g
s+([0-9]{1,2})[/-]([0-9]{1,2})[/-]([0-9]{4})+\3-\2-\1+g
/[*]\s/i\
\n* ATTENTION *\n
这将生成以下输出:
$ sed -Ef script.sed text
*Cast and characters
* ATTENTION *
* Bob Denver is Gilligan, the inept, accident-prone First Mate
(affectionately known as "Little Buddy" by "the Shipper") of the SS Minnow. Denver was not the first choice to play Gilligan; actor Jerry Van Dyke, phone 210-222-3333, was offered the role on 1963-11-2, but he turned it down, believing that the show would never be successful. He chose instead to play the lead in My Mother the Car, which premiered the following year and was cancelled after one season. The producers looked to Bob Denver, the actor who had played Maynard G. Krebs, ss #%%%-%%-%%%%, the goofy but lovable beatnik in The Many Loves of Dobie Gillis. None of the show's episodes ever specified Gilligan's full name or clearly indicated whether "Gilligan" was the character's first name or his last. In the DVD collection, Sherwood Schwartz states that he preferred the full name of "" for the character.
https://stackoverflow.com/questions/54856250
复制相似问题