Parsing data from bash table with empty fields

Advertisements I am currently trying to parse some data from bash tables, and I found strange behavior in parsing data if some columns is empty for example i have data like this containerName ipAddress memoryMB name numberOfCpus status ————— ————— ———- ——- ————– ———- TEST_VM 192.168.150.111 8192 TEST_VM 4 POWERED_ON and sometimes like this containerName… Read More Parsing data from bash table with empty fields

Awk how to print the next line of a specific expression but only of it contains a number

Advertisements Here is a test.txt file sometext someothertext … lol 74 hhhhh lol 789AA I want a bash command that only displays: 74 For this I have tried: awk ‘$0 == "lol" {i=1;next};i && i++ <= 1’ test.txt which for now displays 74 789AA So, how can I augment this command so that it only… Read More Awk how to print the next line of a specific expression but only of it contains a number

Matching a regex metacharacter literally

Advertisements My understanding of Regex’s in AWK is that in order to match a Regex metacharacter literally (For example: +,$,^,*,etc) You must escape them, like so: awk -F ‘\\+’ ‘program here’ However I’ve noticed that you don’t actually need to do this with certain metacharacters, such as the "+" Input file: this|is|a|line this+is+a+line this?is?a?line this*is*a*line… Read More Matching a regex metacharacter literally

AWK script to print a single next word following a pattern match from Description field

Advertisements I have below CSV file: CreateDate, First Name, Last Name, Description 2023/03/25, Makvala, Anima, Your orders are 6157 and total value is 854257 2023/03/26, Leobwin, Saturnus, Your orders are 72 and total value is 1575675 2023/03/25, Boadicea, Pradip, Your orders are 52116 and total value is 29344357 I want below output Orders: 6157, Total… Read More AWK script to print a single next word following a pattern match from Description field