Article 4XHWH sed - Replace numbers from one to several digits

sed - Replace numbers from one to several digits

by
undefineduser
from LinuxQuestions.org on (#4XHWH)
Hello,

I am currently learning how to use sed and want to format a sample output of smartctl.

This is the output:
Code:Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_FAILED RAW_VALUE
1 Raw_Read_Error_Rate 0x000f 099 099 051 Pre-fail Always - 2376
3 Spin_Up_Time 0x0007 091 091 011 Pre-fail Always - 3620
4 Start_Stop_Count 0x0032 100 100 000 Old_age Always - 405
5 Reallocated_Sector_Ct 0x0033 100 100 010 Pre-fail Always - 0
7 Seek_Error_Rate 0x000f 253 253 051 Pre-fail Always - 0
8 Seek_Time_Performance 0x0025 100 100 015 Pre-fail Offline - 0
9 Power_On_Hours 0x0032 100 100 000 Old_age Always - 717
10 Spin_Retry_Count 0x0033 100 100 051 Pre-fail Always - 0
11 Calibration_Retry_Count 0x0012 100 100 000 Old_age Always - 0
12 Power_Cycle_Count 0x0032 100 100 000 Old_age Always - 405
13 Read_Soft_Error_Rate 0x000e 099 099 000 Old_age Always - 2375
183 Runtime_Bad_Block 0x0032 100 100 000 Old_age Always - 0
184 End-to-End_Error 0x0033 100 100 000 Pre-fail Always - 0
187 Reported_Uncorrect 0x0032 100 100 000 Old_age Always - 2375
188 Command_Timeout 0x0032 100 100 000 Old_age Always - 0
190 Airflow_Temperature_Cel 0x0022 084 074 000 Old_age Always - 16 (Lifetime Min/Max 16/16)
194 Temperature_Celsius 0x0022 084 071 000 Old_age Always - 16 (Lifetime Min/Max 16/16)
195 Hardware_ECC_Recovered 0x001a 100 100 000 Old_age Always - 3558
196 Reallocated_Event_Count 0x0032 100 100 000 Old_age Always - 0
197 Current_Pending_Sector 0x0012 098 098 000 Old_age Always - 81
198 Offline_Uncorrectable 0x0030 100 100 000 Old_age Offline - 0
199 UDMA_CRC_Error_Count 0x003e 100 100 000 Old_age Always - 1
200 Multi_Zone_Error_Rate 0x000a 100 100 000 Old_age Always - 0
201 Soft_Read_Error_Rate 0x000a 253 253 000 Old_age Always - 0My goal is to remove the ID numbers (so 1 - 201).
At the moment my command removes just the first digit of every number:

Code:root@localhost:/var/prtg/scriptsxml# smartctl | grep -A25 'Vendor' | sed -n -E 's/(\s*)[0-9](\s*)//p'
Raw_Read_Error_Rate 0x000f 099 099 051 Pre-fail Always - 2376
Spin_Up_Time 0x0007 091 091 011 Pre-fail Always - 3620
Start_Stop_Count 0x0032 100 100 000 Old_age Always - 405
Reallocated_Sector_Ct 0x0033 100 100 010 Pre-fail Always - 0
Seek_Error_Rate 0x000f 253 253 051 Pre-fail Always - 0
Seek_Time_Performance 0x0025 100 100 015 Pre-fail Offline - 0
Power_On_Hours 0x0032 100 100 000 Old_age Always - 717
0 Spin_Retry_Count 0x0033 100 100 051 Pre-fail Always - 0
1 Calibration_Retry_Count 0x0012 100 100 000 Old_age Always - 0
2 Power_Cycle_Count 0x0032 100 100 000 Old_age Always - 405
3 Read_Soft_Error_Rate 0x000e 099 099 000 Old_age Always - 2375
83 Runtime_Bad_Block 0x0032 100 100 000 Old_age Always - 0
84 End-to-End_Error 0x0033 100 100 000 Pre-fail Always - 0
87 Reported_Uncorrect 0x0032 100 100 000 Old_age Always - 2375
88 Command_Timeout 0x0032 100 100 000 Old_age Always - 0
90 Airflow_Temperature_Cel 0x0022 084 074 000 Old_age Always - 16 (Lifetime Min/Max 16/16)
94 Temperature_Celsius 0x0022 084 071 000 Old_age Always - 16 (Lifetime Min/Max 16/16)
95 Hardware_ECC_Recovered 0x001a 100 100 000 Old_age Always - 3558
96 Reallocated_Event_Count 0x0032 100 100 000 Old_age Always - 0
97 Current_Pending_Sector 0x0012 098 098 000 Old_age Always - 81
98 Offline_Uncorrectable 0x0030 100 100 000 Old_age Offline - 0
99 UDMA_CRC_Error_Count 0x003e 100 100 000 Old_age Always - 1
00 Multi_Zone_Error_Rate 0x000a 100 100 000 Old_age Always - 0
01 Soft_Read_Error_Rate 0x000a 253 253 000 Old_age Always - 0How do I rewrite the command to remove two- and three-digit numbers?latest?d=yIl2AUoC8zA latest?i=f_2h6IbMk-M:2MA4RRW64j0:F7zBnMy latest?i=f_2h6IbMk-M:2MA4RRW64j0:V_sGLiP latest?d=qj6IDK7rITs latest?i=f_2h6IbMk-M:2MA4RRW64j0:gIN9vFwf_2h6IbMk-M
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments