AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / user-850238

user115930's questions

Martin Hope
user115930
Asked: 2020-03-12 21:34:12 +0800 CST

如何使用 awk 或像其他人一样拆分不规则的空白字段?

  • 5

我想将数据拆分如下:

$1       $2           $3               $4  $5  $6 $7       $8   .........
---------------------------------------------------------------------------------------------------
root     tty5                          Wed Dec 18 13:42:28 2019   still logged in             
                      ~~~~~~~~~~~~~    ~~~
                      ^                ^
root     tty5                          Wed Dec 18 11:23:20 2019 - Wed Dec 18 11:24:47 2019  (00:01)    
john     pts/2        xx.xxx.xx.xxx    Tue Sep  3 10:11:31 2019 - Tue Sep  3 10:21:18 2019  (00:09)    
john     pts/3        xx.xxx.xx.xxx    Mon Sep  2 14:42:29 2019 - Mon Sep  2 14:57:33 2019  (00:15)    
john     pts/2        xx.xxx.xx.xxx    Mon Sep  2 14:40:03 2019 - Mon Sep  2 14:45:27 2019  (00:05)    
john     pts/2        xx.xxx.xx.xxx    Mon Sep  2 13:52:09 2019 - Mon Sep  2 14:34:12 2019  (00:42)    
john     pts/3        xx.xxx.xx.xxx    Mon Sep  2 13:14:39 2019 - Mon Sep  2 14:03:24 2019  (00:48)    
john     pts/2        xx.xxx.xx.xxx    Mon Sep  2 13:08:11 2019 - Mon Sep  2 13:23:16 2019  (00:15)    
john     pts/2        xx.xxx.xx.xxx    Mon Sep  2 10:22:27 2019 - Mon Sep  2 11:10:48 2019  (00:48)    
john     pts/2        xx.xxx.xx.xxx    Fri Aug 30 17:25:19 2019 - Fri Aug 30 17:33:34 2019  (00:08)    
john     pts/2        xx.xxx.xx.xxx    Wed Aug 28 10:43:56 2019 - Wed Aug 28 10:52:48 2019  (00:08)    
john     pts/2        xx.xxx.xx.xxx    Tue Aug 27 16:59:30 2019 - Tue Aug 27 17:52:50 2019  (00:53)    
john     pts/2        xx.xxx.xx.xxx    Tue Aug  6 11:06:46 2019 - Tue Aug  6 11:12:05 2019  (00:05)    
john     pts/2        xx.xxx.xx.xxx    Tue Aug  6 10:48:39 2019 - Tue Aug  6 11:01:46 2019  (00:13)    
john     pts/2        xx.xxx.xx.xxx    Tue Aug  6 10:38:18 2019 - Tue Aug  6 10:43:18 2019  (00:05)    
john     pts/2        xx.xxx.xx.xxx    Tue Aug  6 10:28:02 2019 - Tue Aug  6 10:36:04 2019  (00:08)    
john     pts/2        xx.xxx.xx.xxx    Fri Aug  2 14:24:00 2019 - Fri Aug  2 14:24:16 2019  (00:00)    
root     tty5                          Fri Aug  2 14:21:30 2019 - Fri Nov 22 11:03:20 2019 (111+20:41) 
root     tty5                          Fri Jul 26 11:02:17 2019 - Fri Jul 26 11:03:58 2019  (00:01)    
john     pts/3        xx.xxx.xx.xxx    Thu Jul 25 16:24:44 2019 - Thu Jul 25 16:33:36 2019  (00:08)    
john     pts/2        xx.xxx.xx.xxx    Thu Jul 25 16:08:41 2019 - Thu Jul 25 16:33:53 2019  (00:25)   

但是,如果 $3 为空,我无法正确获得 $3 和下一个字段的值。例如:

$ last -F | grep -E 'tty|pty|pts' | awk '{print $3}'
Wed                 <- not correct
Wed                 <- not correct
xx.xxx.xx.xxx
xx.xxx.xx.xxx
xx.xxx.xx.xxx
xx.xxx.xx.xxx
xx.xxx.xx.xxx
xx.xxx.xx.xxx
xx.xxx.xx.xxx
xx.xxx.xx.xxx
xx.xxx.xx.xxx
xx.xxx.xx.xxx
xx.xxx.xx.xxx
xx.xxx.xx.xxx
xx.xxx.xx.xxx
xx.xxx.xx.xxx
xx.xxx.xx.xxx
Fri                 <- not correct
Fri                 <- not correct
xx.xxx.xx.xxx
xx.xxx.xx.xxx

如何使用 awk 或类似的命令行工具正确解析它?

linux string
  • 1 个回答
  • 88 Views
Martin Hope
user115930
Asked: 2020-01-08 02:27:04 +0800 CST

Windows 修补程序中的 01d15614cbaee92c 等时间格式是什么?

  • 7

Windows 修补程序的时间戳 ( InstalledOn) 格式不规律,它显示各种类型,如MM-DD-YYYY,和.YYYY/MM/DDYYYYMMDD01d15614cbaee92c

这些值可以从Win32_QuickFixEngineering中获得WMIC。

我想知道什么是时间戳01d15614cbaee92c以及如何解析它。

示例数据:

Update KB955484 10cd4bf3009a2541
Update KB971512 01cd35e8c07bdeb1
Security Update KB2079403 01cd04587fa78c94
Security Update KB3109094 01d15614cbaee92c

谢谢你。

windows wmic
  • 2 个回答
  • 499 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何减少“vmmem”进程的消耗?

    • 11 个回答
  • Marko Smith

    从 Microsoft Stream 下载视频

    • 4 个回答
  • Marko Smith

    Google Chrome DevTools 无法解析 SourceMap:chrome-extension

    • 6 个回答
  • Marko Smith

    Windows 照片查看器因为内存不足而无法运行?

    • 5 个回答
  • Marko Smith

    支持结束后如何激活 WindowsXP?

    • 6 个回答
  • Marko Smith

    远程桌面间歇性冻结

    • 7 个回答
  • Marko Smith

    子网掩码 /32 是什么意思?

    • 6 个回答
  • Marko Smith

    鼠标指针在 Windows 中按下的箭头键上移动?

    • 1 个回答
  • Marko Smith

    VirtualBox 无法以 VERR_NEM_VM_CREATE_FAILED 启动

    • 8 个回答
  • Marko Smith

    应用程序不会出现在 MacBook 的摄像头和麦克风隐私设置中

    • 5 个回答
  • Martin Hope
    Vickel Firefox 不再允许粘贴到 WhatsApp 网页中? 2023-08-18 05:04:35 +0800 CST
  • Martin Hope
    Saaru Lindestøkke 为什么使用 Python 的 tar 库时 tar.xz 文件比 macOS tar 小 15 倍? 2021-03-14 09:37:48 +0800 CST
  • Martin Hope
    CiaranWelsh 如何减少“vmmem”进程的消耗? 2020-06-10 02:06:58 +0800 CST
  • Martin Hope
    Jim Windows 10 搜索未加载,显示空白窗口 2020-02-06 03:28:26 +0800 CST
  • Martin Hope
    andre_ss6 远程桌面间歇性冻结 2019-09-11 12:56:40 +0800 CST
  • Martin Hope
    Riley Carney 为什么在 URL 后面加一个点会删除登录信息? 2019-08-06 10:59:24 +0800 CST
  • Martin Hope
    zdimension 鼠标指针在 Windows 中按下的箭头键上移动? 2019-08-04 06:39:57 +0800 CST
  • Martin Hope
    jonsca 我所有的 Firefox 附加组件突然被禁用了,我该如何重新启用它们? 2019-05-04 17:58:52 +0800 CST
  • Martin Hope
    MCK 是否可以使用文本创建二维码? 2019-04-02 06:32:14 +0800 CST
  • Martin Hope
    SoniEx2 更改 git init 默认分支名称 2019-04-01 06:16:56 +0800 CST

热门标签

windows-10 linux windows microsoft-excel networking ubuntu worksheet-function bash command-line hard-drive

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve