我有一个包含以下代码行的文件。这里的文件显示了一个逐一排序的时间表。
at 12:00 the schedule of james version1 is :
first_task:eating:nothing
second_task:rest:onehour
third_task:watching:nothing
at 12:00 the schedule of james version2 is :
first_task:eating:fruits
second_task:rest:twohour
third_task:watching:manga
at 12:00 the schedule of alex version1 is :
first_task:eating:fruit
second_task:rest:halfhour
third_task:watching:horrorfilm
at 12:00 the schedule of alex version2 is :
first_task:eating:meal
second_task:rest:nothing
third_task:watching:nothing
at 18:00 the schedule of james version1 is :
first_task:eating:fastfood
second_task:rest:twohours
third_task:watching:series
at 18:00 the schedule of james version2 is :
first_task:eating:nothing
second_task:rest:onehours
third_task:watching:series
at 18:00 the schedule of alex version1 is :
first_task:eating:vegetals
second_task:rest:threehours
third_task:watching:manga
at 18:00 the schedule of alex version2 is :
first_task:eating:bread
second_task:rest:fivehours
third_task:watching:manga
at 22:00 the schedule of james version1 is :
first_task:eating:nothing
second_task:rest:sevenhours
third_task:watching:nothing
at 22:00 the schedule of james version2 is :
first_task:eating:meal
second_task:rest:sixnhours
third_task:watching:nothing
at 22:00 the schedule of alex version1 is :
first_task:eating:vegetals
second_task:rest:sevehours
third_task:watching:manga
at 22:00 the schedule of alex version2 is :
first_task:eating:icecream
second_task:rest:sevenhours
third_task:watching:nothing
我尝试这样排序:
12:00 eating:fruit
18:00 eating:vegetals
22:00 eating:nothing
12:00 rest:onhour
18:00 rest:threehour
22:00 rest:sevenhour
12:00 watching:horrorfilm
18:00 watching:manga
22:00 watching:nothing
使用这些命令:
awk -F '[\ :]' '/the schedule is/{h=$2;m=$3} /eating/{print " "h":"m" watching:"$3}' f.txt
awk -F '[\ :]' '/the schedule is/{h=$2;m=$3} /rest/{print " "h":"m" rest:"$3}' f.txt
awk -F '[\ :]' '/the schedule is/{h=$2;m=$3} /watching/{print " "h":"m" watching:"$3}' f.txt
现在我希望通过忽略所有不重要的单词并对表中最有价值的信息进行排序来改进过滤的文件,我试图思考/搜索如何获得这种格式但徒劳。
None
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)