我一直在上网UNIX
当然,并遇到了我一直坚持的这个问题。将不胜感激任何帮助!
You are provided with a set of files each one of which contains personal details about an individual. Each file is laid out in the following format, with one file per individual:
name:Niko Tanaka age:41 occupation:Doctor
我知道答案必须采用以下形式:
n=$(awk -F: ' / /{print }' filename)
最佳答案
n=$(awk -F: '/name/{print $2}' infile)
/ /
里面的任何内容是正则表达式。在这种情况下,您只想匹配包含“名称”的行。
关于unix - 使用 awk 命令从文件中提取第一行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9057480/