I have several strings(or filenames in a directory) and i need to group them by second most common pattern, then i will iterate over them by each group and process them. in the example below i need 2 from ACCEPT and 2 from BASIC_REGIS, bascially from string beginning to one character after hyphen (-) and it could be any character
Tag: awk
parsing ethtool command output using sed and awk
I am working on a shell script to parse the advertised mode and supported mode from the ethtool command and match them against an expected value. The idea is both expected and supported modes should have a common value to pass the condition. Data: I have currently used the below for the same. The above code is giving the correct
Convert nth column of CSV from EPOCH to human readable in bash
I’ve tried to create a single line command to convert a particular column in a CSV from EPOCH to human readable. The file contains various columns, depending on the particular file. E.g. in this file EPOCH is in column 3 of 3, in another file it is in column 5 of 9. The basic conversion works when done manually, so
How can capture args with xargs across multiple pipe in bash
I have this command Suppose that argument from first xargs is $1 and it gets subsituted in like helm list –short -n {$1} and $2 is the argument of second Xargs and its gets substituted like but i also want $1 to use like this in last comand is this possible ? output of first xargs second xargs Answer I
awk the previous and current line only if equal to string
I have the following lines in a file I want to get the previous and current line, only if it start with albi. Means, output should look like: I tried the below, but looks I’m missing something: Answer Assuming you do need to test “shush” as in your script, all you were doing wrong is trying to reference an awk
Add an index column to a csv using awk
How can I add an index to a csv file using awk? For example lets assume I have a file data.txt I would like to add another column, which is the index. Basically I would like an output of I was trying to use awk ‘{for (i=1; i<=NF; i++) print $i}’ but it does not seem to be working right.
Compare two text files line by line, finding differences but ignoring numerical values differences
I’m working on a bash script to compare two similar text files line by line and find the eventual differences between each line of the files, I should point the difference and tell in which line the difference is, but I should ignore the numerical values in this comparison. Example: In the example above, the script shouldn’t find any difference
Sorting a file using fields with specific value
Recently, I had to sort several files according to records’ ID; the catch was that there can be several types of records, and in each of those the field I had to use for sorting is on a different position. The fields, however, are easily identifiable thanks to key=value structure. To show a simple sample of the general structure: I
how to extract part of log file bash [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 11 months ago. The community reviewed whether to reopen this question 10 months ago and left it closed: Original close reason(s) were not resolved Improve this question I have a log
Print min and max with awk
Why wont this awk script work, where I want to print the min and max of an input by just reading the data once. I would also like to initialize the min and max variable with the first value of the data. Say I have a file I am using awk to print the min and max with: But I