【发布时间】:2020-10-23 16:09:51
【问题描述】:
我尝试使用 awk 拆分列来打印一个句子,但第一列有空格。
我的初学者代码示例:
$ awk '/Linux/ { print "The filename","\""$1"\"","is located in",$2 }' test.txt
The filename "The" is located in test
The filename "Some" is located in file
The filename "File" is located in name
The filename "Something_here" is located in /ABC
The filename "Another_test" is located in /DEFG
The filename "Label" is located in test
来自文件:test.txt
Filename Folder Type
-------------------------------------- -------------- ------
The test file /test/folder Linux
Some file / Linux
File name /Temp Linux
Something_here /ABC Linux
Another_test /DEFG Linux
Label test /HIJK Linux
我想要达到的目标:(包括引号)
The filename "Default file" is located in /
The filename "The test file" is located in /test/folder
问题是当我使用“空格”或“/”作为分隔符时,打印时无法获取整行
【问题讨论】:
-
请提供您正在使用的脚本或命令。另外,你现在得到的输出。
-
@KimochiIku 你可以编辑你的帖子。请将您的评论内容移至您的帖子中。
标签: awk