gpt4 book ai didi

regex - 如何删除文本文件中第一个空格后每一行中的所有字符?

转载 作者:行者123 更新时间:2023-11-29 09:35:41 24 4
gpt4 key购买 nike

我有一个很大的日志文件,我需要从中提取文件名。

文件看起来像这样:

/path/to/loremIpsumDolor.sit /more/text/here/notAlways/theSame/here
/path/to/anotherFile.ext /more/text/here/differentText/here
.... about 10 million times

我需要像这样提取文件名:

loremIpsumDolor.sit
anotherFile.ext

我认为我的第一个策略是查找/替换所有 /path/to/ 为 ''。但我不知道如何删除空格后的所有字符。

你能帮忙吗?

最佳答案

sed 's/ .*//' file

不再需要了。当然,转换后的输出会出现在标准输出中。

关于regex - 如何删除文本文件中第一个空格后每一行中的所有字符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13404897/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com