用于文件信息的 AIX 脚本
AIX script for file information
我在 AIX 服务器中有一个文件,其中包含以下格式的多个记录条目
Name(ABC XYZ) Gender(Male)
AGE(26) BDay(1990-12-09)
我的问题是我想从文件中提取所有记录的姓名和生日。我想像下面这样列出它:
ABC XYZ 1990-12-09
有人可以帮我编写脚本吗
可能是这样的:
awk -F"[()]" '/Name/ && /Gender/{name=} /BDay/{print name,}' file.txt
也就是说... "treat opening and closing parentheses as field separators. If you see a line go by that contains Name
and Gender
, save the second field in the variable name
. If you see a line go by that contains the word Bday
, print out the last name you saw and also the fourth field on the current line."
我在 AIX 服务器中有一个文件,其中包含以下格式的多个记录条目
Name(ABC XYZ) Gender(Male)
AGE(26) BDay(1990-12-09)
我的问题是我想从文件中提取所有记录的姓名和生日。我想像下面这样列出它:
ABC XYZ 1990-12-09
有人可以帮我编写脚本吗
可能是这样的:
awk -F"[()]" '/Name/ && /Gender/{name=} /BDay/{print name,}' file.txt
也就是说... "treat opening and closing parentheses as field separators. If you see a line go by that contains Name
and Gender
, save the second field in the variable name
. If you see a line go by that contains the word Bday
, print out the last name you saw and also the fourth field on the current line."