Ryd*_*per 3 regex linux bash grep sed
我需要帮助在 Bash 中提取“@”符号和空格“”之间的字符串。
我正在使用 Python Twitter 工具,输出是这样的:
430438229200740352 2014-02-03 14:30:45 CST <HorizonAwon> @SawBlastt @WereAutomatic 101 for me to join as well
Run Code Online (Sandbox Code Playgroud)
我需要提取两个字符串:
锯片
是自动的
我还需要将它们分别设置为一个单独的变量。我试过搞乱 sed 和 grep,但没有成功的结果。我真的坚持这一点。非常感谢帮助。谢谢!
您可以使用:
s='430438229200740352 2014-02-03 14:30:45 CST <HorizonAwon> @SawBlastt @WereAutomatic 101 for me to join as well'
grep -oP '@\K[^ ]*' <<< "$s"
SawBlastt
WereAutomatic
Run Code Online (Sandbox Code Playgroud)