Skip to content
Advertisement

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.

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

Advertisement