过滤文件内容到排序表

2024-01-27

我有一个包含以下代码行的文件。这里的文件显示了一个逐一排序的时间表。

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(使用前将#替换为@)

过滤文件内容到排序表 的相关文章

随机推荐

  • 通过 python 使用 Google Drive API V3 获取 Google Drive 文件所有者电子邮件地址

    我无法通过 Google Drive API v3 获取 Google 云端硬盘上文件的所有者 我可以在 v2 下做到这一点 但事情已经改变了 根据文档 https developers google com drive api v3 re
  • 在Android Studio中使用自定义框架库(android.jar)

    我有自己的定制框架 android jar 并想在 Android Studio 中使用它 我的 build gradle 中有如下描述 dependencies compile files myandroid jar 但Android S
  • 如何将material-ui时间选择器更改为24小时格式

    目前使用的是Timepicker来自材料用户界面 我已将其设置为type time 它允许我通过 AM PM 选项选择一天中 12 小时内的时间 我希望我的选择器采用 24 小时格式 从而删除 AM PM 选项 我查看了material u
  • 为什么变量在更改其因变量后没有更新? [复制]

    这个问题在这里已经有答案了 我不明白为什么当我更改 x 时变量 y 不更新 y 变量依赖于 x 对吧 x 5 y x 2 print x print y x 3 Expect it to print 3 and 6 instead it p
  • 我可以在 robots.txt 中使用“Host”指令吗?

    Searching for specific information on the robots txt I stumbled upon a Yandex help page http help yandex com webmaster c
  • 为什么此保存方法不调整图像大小?

    我重写保存方法以便在上传后调整图像大小 以下代码似乎并未调整图像大小 我仔细检查了媒体文件夹 发现上传图像的原始尺寸 900x850 只有一份副本 Django 没有抛出任何错误 所以我不知道如何解决这个问题 需要明确的是 我可以毫无问题地
  • SQLAlchemy 自定义查询列

    我有一个如下定义的声明表 class Transaction Base tablename transactions id Column Integer primary key True account id Column Integer
  • Request.Url.Authority 未返回预期的域

    我正在网站的控制器中生成一封电子邮件 其中包含指向我的网站的链接 http Request Url Authority some page 当我在本地计算机上测试它时 这是有效的 返回localhost 12345 和生产中 返回www c
  • Angular 6 httpClient 使用凭据发布

    我有一些代码可以发布一些数据来创建数据记录 它在一个服务中 这是代码 import Injectable from angular core import HttpClient HttpHeaders from angular common
  • CakePHP 2.1 测量页面执行时间

    如何测量 CakePHP 2 1 中的页面执行时间 在 1 3 中 它在调试模式下呈现在代码中 你可以使用调试工具包插件 https github com cakephp debug kit找出执行时间 或者您可以在 app 中编辑 ind
  • 在 Windows 10 IoT 上使用 UWP 进行 LDAP 查询

    经过几个小时的搜索后 似乎无法从 UWP 应用程序查询本地 LDAP 目录 Microsoft Active Directory 或其他 这似乎是 UWP 产品中的一个相当奇怪的漏洞 因此我希望我只是错过了明显的漏洞 通用 Windows
  • 如何在构建的电子应用程序中获取开发工具?

    是否可以在构建的电子应用程序中显示开发工具 我使用构建的可执行文件electron packager与使用运行的应用程序的行为不同electron在命令行中 我无法看到抛出了哪些类型的异常 是的 可以在打包的应用程序中显示 DevTools
  • Android:单击时更改按钮颜色

    基本上 我正在尝试创建一个单击时的按钮 注意 NOT按下 会将颜色从 color1 更改为 color2 再次单击时 颜色将从 color2 变回 color1 我疯狂地搜索 我设法提取的唯一信息是如何在按下按钮时改变颜色 即当用户按住按钮
  • 将构造函数添加到 deftype 创建的类中

    为了与 Java 实现互操作性 我需要一个具有执行初始化的空构造函数的类 此类的对象需要具有类似于可变java字段的东西 即该对象代表游戏的后端 并且需要保持游戏状态 deftype 确实一切我想要做except提供一个无效构造函数 因为我
  • 如何检索高质量的指南针方向(如 Google 地图)?

    我发现的所有在 Android 中获取指南针方向的指南都有一个错误 当您以纵向模式握住手机并 看 地平线上方时 指南针箭头会从正确方向旋转 180 度 谷歌地图方向指示器不存在这个问题 谷歌地图的另一个好处是它们可以以某种方式估计指南针的准
  • Vue.js 对数组进行过滤

    我正在尝试使用 vue js 中的计算属性来过滤数组 我想搜索多个字段 名称 状态 标签等 My data events id 1 name Name of event url datetime 2017 05 10T00 00 00Z d
  • 不完整类型的静态字段 - 合法吗?

    在 C 中声明在类定义时不完整的类型的静态字段是否合法 例如 Foo h class Foo public private class Bar static Bar something Foo cpp class Foo Bar Foo B
  • 标准对 char 数组作为模板参数有何规定?

    在我研究答案的过程中这个问题 https stackoverflow com q 57003010 9883438我发现 我之前不知道 gcc 和 clang 允许char如果声明了数组 则它们将成为模板参数static 例如 此代码使用
  • 如何从 ruby​​ 中的反引号命令获取颜色?

    在 ruby 文件中 当我做system rspec file spec rb 我得到一个很好的彩色输出 当我这样做时 result rspec file spec rb puts result 我一点颜色都没有 有什么办法可以保留颜色 顺
  • 过滤文件内容到排序表

    我有一个包含以下代码行的文件 这里的文件显示了一个逐一排序的时间表 at 12 00 the schedule of james version1 is first task eating nothing second task rest