I want to evaluate the expression and display the output correct to 3 decimal places i tried with below code but it is not working help me how to do that in bash. Answer With bc: Output: 17.928
Tag: awk
Increment variable when matched awk from tail
I’m monitoring from an actively written to file: My current solution is: However when attempting to do this with AWK I don’t get the output – the $ws_trans and $sc_trans remains 0 Attempting to do this to reduce load. I understand that AWK doesn’t deal with bash variables, and it can g…
Insert text if column contains a number
I have a tab-delim file that looks like this It should be three columns but some rows are missing the second column (bacterial taxonomy). For these rows I want to move the number to a third column and insert some text (such as Unclassified). I have been attempting to modify some commands I found online to ins…
How to do parsing of Elapsed time in seconds in linux
I want to do parsing of Elapsed time in seconds .Time formats given below: i’m getting values from systemctl status cassandra | awk ‘/(Active: active)/{print $9, $10,$11}’ Now storing it’s value in variable A,like now A has input as 3 day 18h or 3 day etc. More examples- A=3 day 18h or…
redirect and print script output using for loop and awk in linux
I have a script which give out put like this : my_script <variables> output like this : now I want to redirect the output and print like this print “some_text col_3@col_4 some_more_text col_4” ans will be like this: some_text textext3@texxt6 some_more_text texxt6 some_text textext1@text4 som…
Print the two matched variables of awk in same line
This is the script which i wrote. The logs.txt consists of : In this the expected output is : But the output i am getting is : Can anyone rectify what is the error ? Answer I thinks this problem should be separated multiple problems. How do you think about below code? You can see what these code actually do
How to find which column has special characters in a file
I would like to find out which column has special characters in a file For example, I have the data below: Desired output: I want the record number along with the column numbers that have special characters. Answer You didn’t define special character. I will assume that you mean anything outside of the …
Remove lines are between two line numbers (or patterns) with sed [no duplicate]
I saw and read many topics about my problem, but they didn’t help me. a close topic to my problem but it didn’t help me: removing lines between two patterns (not inclusive) with sed Question: I have a text file and I want to remove lines are between two patterns. note1: between these patterns, i d…
Delete certain columns and add horizontally in AW. So many columns that I cannot type each one
I have been struggling more than a day and I cannot make my script work. Please help. My txt file extends to 500 columns. I need to delete columns 5,9,13,21,…, always delete n=4 column. Then, after removing the columns I mentioned above, I need to add all the columns remaining, BUT NOT taking into accou…
Convert column to matrix format using awk
I have a gridded data file in column format as: I would like to convert it to matrix format as: Where top 20.5 21.5 22.5 indicate y and side values indicate x and the inside values indicate the corresponding grid values. I found a similar question here Convert a 3 column file to matrix format but the script i…