当前位置:网站首页>用grep awk提取字符串
用grep awk提取字符串
2022-06-12 18:01:00 【断问天】
如下日志文本,想要从中提取 androidboot.serialno= 后面的字符串
Feb 19 03:20:15 firefly kernel: [ 0.000000] Booting Linux on physical CPU 0x0
Feb 19 03:20:15 firefly kernel: [ 0.000000] Initializing cgroup subsys cpuset
Feb 19 03:20:15 firefly kernel: [ 0.000000] Initializing cgroup subsys cpu
Feb 19 03:20:15 firefly kernel: [ 0.000000] Initializing cgroup subsys cpuacct
Feb 19 03:20:15 firefly kernel: [ 0.000000] Linux version 4.4.194 ([email protected]) (gcc version 6.3.1 20170404 (Linaro GCC 6.3-2017.05) ) #15 SMP Thu Dec 30 14:52:16 CST 2021
Feb 19 03:20:15 firefly kernel: [ 0.000000] Boot CPU: AArch64 Processor [410fd034]
Feb 19 03:20:15 firefly kernel: [ 0.000000] earlycon: Early serial console at MMIO32 0xff1a0000 (options '')
Feb 19 03:20:15 firefly kernel: [ 0.000000] bootconsole [uart0] enabled
Feb 19 03:20:15 firefly kernel: [ 0.000000] On node 0 totalpages: 516096
Feb 19 03:20:15 firefly kernel: [ 0.000000] DMA zone: 8184 pages used for memmap
Feb 19 03:20:15 firefly kernel: [ 0.000000] DMA zone: 0 pages reserved
Feb 19 03:20:15 firefly kernel: [ 0.000000] DMA zone: 516096 pages, LIFO batch:31
Feb 19 03:20:15 firefly kernel: [ 0.000000] psci: probing for conduit method from DT.
Feb 19 03:20:15 firefly kernel: [ 0.000000] psci: PSCIv1.0 detected in firmware.
Feb 19 03:20:15 firefly kernel: [ 0.000000] psci: Using standard PSCI v0.2 function IDs
Feb 19 03:20:15 firefly kernel: [ 0.000000] psci: Trusted OS migration not required
Feb 19 03:20:15 firefly kernel: [ 0.000000] PERCPU: Embedded 21 pages/cpu @ffffffc07fede000 s46312 r8192 d31512 u86016
Feb 19 03:20:15 firefly kernel: [ 0.000000] pcpu-alloc: s46312 r8192 d31512 u86016 alloc=21*4096
Feb 19 03:20:15 firefly kernel: [ 0.000000] pcpu-alloc: [0] 0 [0] 1 [0] 2 [0] 3 [0] 4 [0] 5
Feb 19 03:20:15 firefly kernel: [ 0.000000] Detected VIPT I-cache on CPU0
Feb 19 03:20:15 firefly kernel: [ 0.000000] CPU features: enabling workaround for ARM erratum 845719
Feb 19 03:20:15 firefly kernel: [ 0.000000] Built 1 zonelists in Zone order, mobility grouping on. Total pages: 507912
Feb 19 03:20:15 firefly kernel: [ 0.000000] Kernel command line: storagemedia=emmc androidboot.storagemedia=emmc androidboot.mode=normal androidboot.verifiedbootstate=orange androidboot.slot_suffix= androidboot.serialno=0QLQUXNZHZ ro rootwait earlycon=uart8250,mmio32,0xff1a0000 swiotlb=1 console=ttyFIQ0 root=PARTLABEL=rootfs rootfstype=ext4 overlayroot=device:dev=PARTLABEL=userdata,fstype=ext4,mkfs=1 coherent_pool=1m systemd.gpt_auto=0 cgroup_enable=memory swapaccount=1可以使用如下方法:
1. 管道方式处理
grep "androidboot.serialno" /var/log/kern.log | xargs -n 1 | grep "androidboot.serialno" | xargs -d = | awk '{print $2}'2. grep的-P参数使用perl正则语法
grep -oP 'androidboot.serialno=\K.*?(?= )' /var/log/kern.loggrep -oP 'androidboot.serialno=\K[^ ]+' /var/log/kern.log3. awk查找
awk -F'androidboot.serialno=' '{for(i=2; i<=NF;i++){split($i, a, " "); print a[1]}}' /var/log/kern.log边栏推荐
- 用好IDE,研发效能提速100%
- Use of split method of string
- PHP implementation of infinite classification tree (recursion and Optimization)
- 在同花顺开户证券安全吗
- Byte flybook Human Resources Kit three sides
- leetcode 647. Palindrome substring
- grpc-swift入门
- Changes in the third generation dri
- es7不使用父子和嵌套关系来实现一对多功能
- An easy-to-use IDE for small programs
猜你喜欢

High speed layout guidelines incomplete

Esp32-c3 esp-idf configuring smartconfig and SNTP to obtain network time

Small program +app, a low-cost and active technology combination idea

利用小程序快速生成App,只需七步
![Vulnhub[DC3]](/img/3a/1aa03e804d447d38e85807928fdb8f.png)
Vulnhub[DC3]

Tutoriel de démarrage rapide JDBC

C#简单介绍

SSM integrates FreeMarker and common syntax
![Vulnhub[DC3]](/img/3a/1aa03e804d447d38e85807928fdb8f.png)
Vulnhub[DC3]

小程序+App,低成本获客及活跃的一种技术组合思路
随机推荐
Vant3+ts dropdownmenu drop-down menu, multi data can be scrolled
LCD parameter interpretation and calculation
SSM集成FreeMarker以及常用语法
使用MongoDB官方go库操作MongoDB原创
低代码平台调研结果
grpc-swift入门
App中快速复用微信登录授权的一种方法
字节飞书人力资源套件三面
1.5 what is an architect (serialization)
Applet and app are owned at the same time? A technical scheme with both
续2 asp.net core 路由程序基础使用演示0.2 默认控制器数据的获取到
重构--梳理并分解继承体系
566. 重塑矩阵
[csp]202012-2 optimal threshold for period end forecast
Vant3+ts encapsulates uploader upload image component
小程序+App,低成本获客及活跃的一种技术组合思路
机器学习系列(3):Logistic回归
Leetcode 674 longest incrementing substring
leetcode 647. Palindrome substring
PHP implementation of infinite classification tree (recursion and Optimization)