Skip to content
Advertisement

Tag: awk

awk combine sequence with substring key

I have two files for combining with tab delimited file. That two files key might be different only for “Reads” number. I want to compare that two files and combined based on substring key and match. Forexample, This case I want to combine that two column with File1 Key name. Please check below example case. File 1. File 2. Result.

how to calculate percentage in shell

I would like to calculate percentage in shell. But I can’t do it. My script is It is neither showing any value nor terminating when executing this script. Answer awk will give you an n1 illegal field name if you do that, as it’s inside single quotes. Also, to avoid awk keep reading stdin you should pass /dev/null as file.

Subtract a constant number from a column

I have two large files (~10GB) as follows: file1.csv file2.csv I want to subtract 1 from the “id” columns of these files: file1_updated.csv file2_updated.csv I have tried awk ‘{print ($1 – 1) “,” $0}’ file2.csv, but did not get the correct result: Answer You’ve added an extra column in your attempt. Instead set your first field $1 to $1-1: That

partial merging 2 text file in linux

I have 2 text file which I want to merge them in a new file. my first file is look like and second file = and my expected output like, I mean mapping part of 9th column string from first line with 1st column of second file, should be like : Also, I wanted to keep line from first file

Bash: transform key-value lines to CSV format [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 6 years ago. Improve this question Editor’s note: I’ve clarified the problem definition, because I think the problem is an interesting one, and this question deserves to be reopened. I’ve got

Pass argument to awk inside do loop

I have a large number of tab-separated text files containing a score I’m interested in in the second column: test_score_1.txt test_score_2.txt I want to check if I have Titles with a score smaller than a number I define. The following code defines my score in the script and works: check_score_1 If I try to pass an argument to awk like

printf in awk with Umlauts doesn’t work

Can somebody please give me an alternative to the following awk statement. As soon as I give a “n” for string, it skips after Umlaut. I don’t want to use gsub because I have many special characters and don’t want to write a script for this. Also if not in awk, can somebody help me in other languages? Answer The

Compare columns from two files and print not match

I want to compare the first 4 columns of file1 and file2. I want to print all lines from file1 + the lines from file2 that are not in file1. I don’t understand how to print things that don’t match. Answer You can do it with an awk script like this: script.awk And run it like this: awk -f script.awk

move single string up into previous row

I have been trying to solve a problem for hours and haven’t found a solution. I am trying to reformat a text file that has been incorrectly parsed. The file format contains a list of names, starting with the last name first, and has a troublesome sole first name on one of the rows as below: I have tried dumping

Advertisement