Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
使用 sed,如果文件中的一行上有空格字符,我需要打印带有空格字符的输出以及删除后的任何内容。代码示例:
sed "s/"something here I think"//g' file
所以,假设一个文件在一行上说:
Chuck Norris is the man
我只需要它打印:
Chuck
多行也适用:
Chuck Norris is the man So is Arnold
替换:
Chuck So
这应该为你做:
sed 's/ .*//g' file
要从行首删除到第一个空格,请使用以下命令:
sed 's/^[^ ]* //g'