我可以帮助您进行翻译。这段文字的意思是:“我有一个任务,需要使用'sed'从包含以下内容的文本文件中提取莫尔斯电码(短划线和点号)。”
它查找跟随字符的破折号或句号的实例,并删除第一个,这正是我遇到的问题。然后它会清理其余的字符、空格、冒号和撇号。谢谢!
A test to see if the morse code can be removed from a file. .--- -. ..
This is a test --. -.- .-- .. -.. --- .- .. of sorts and so on. Let's see if the code snippets can be found.
Also can they be .- . -.- removed and yet leave the periods at the end
of sentences alone. ---- -. There are also hyphenated words like the
following: Edgar-Jones. -.
我可以使用sed命令删除所有[a-z]和[A-Z]的字符,但问题是句子末尾的句号以及Edgar-Jones中的连字符也会被拾取。我找不到方法来一并排除它们...
非常感谢您的帮助。
感谢所有答案,每一个都有帮助。我选择了这个方案。
sed "s/[a-zA-Z][-.]//g;s/[a-zA-Z: ']*//g" file
它查找跟随字符的破折号或句号的实例,并删除第一个,这正是我遇到的问题。然后它会清理其余的字符、空格、冒号和撇号。谢谢!