Hot answers tagged

12 votes

Replace new lines with spaces using awk

Assuming that the lines are ordered in the manner that you show in the question, then the paste command can do that: $ paste - - < input_file A1_R1.fastq.gz A1_R2.fastq.gz A2_R1.fastq.gz A2_R2....
user9101329's user avatar
9 votes

Replace new lines with spaces using awk

For the input you show where all the paired lines are next to each other all you need with any awk is: $ awk '{ORS=(NR%2 ? "\t" : RS)} 1' file A1_R1.fastq.gz A1_R2.fastq.gz A2_R1.fastq.gz ...
Ed Morton's user avatar
  • 31.3k
7 votes

Remove lines from a csv file based on column value

TL;DR Redirecting your gawk's stdout to /dev/null or piping it to cat will greatly accelerate it and reduce the runtime significantly. gawk -i inplace [...] myfile.csv >/dev/null Or: gawk -i ...
aviro's user avatar
  • 5,062
6 votes

Remove lines from a csv file based on column value

One possible way (via rewriting your command) is: gawk -F, -v s="$start_marker" -v e="$end_marker" '$6 > e || $6 < s' myfile.csv >/tmp/newfile In awk, it is not ...
Romeo Ninov's user avatar
  • 17.4k
3 votes

Replace new lines with spaces using awk

Using Raku (formerly known as Perl_6) If it's always paired reads, and they're always in the correct order: ~$ raku -e '.put for lines.rotor(2);' file If it's always paired reads, but filenames ...
jubilatious1's user avatar
  • 3,050
2 votes

Replace new lines with spaces using awk

I would probably start out with the simplest approach: $ fmt -w30 < files.csv | tr ' ' '\t' A1_R1.fastq.gz A1_R2.fastq.gz A2_R1.fastq.gz A2_R2.fastq.gz A3_R1.fastq.gz A3_R2.fastq.gz But if your ...
J_H's user avatar
  • 866
1 vote

Remove lines from a csv file based on column value

if you can use tools other than awk, duckdb is very quick and convenient. If your input is mcu_i,INIT,200,iFlash, 11593925, 88347,,0x00092684,r,0x4606b570, ok,, 32,single,op-c,0,, ...
aborruso's user avatar
  • 2,855
1 vote

Remove lines from a csv file based on column value

If it does not have to be awk, then you might try Perl instead: #!/usr/bin/perl use 5.18.2; use warnings; use strict; my ($X, $Y) = (88347, 88347); while (<>) { next if (/(?:^[^,]*,)...
U. Windl's user avatar
  • 1,397
1 vote

compare two files on the basis of first columns of two file and get matching and non-matching rows

You can use the first column of file1 as search patterns for a grep command. This will filter out those items in file2 that have no pairing second column. $ cp file1.txt outfile $ awk '{print $1}' ...
user9101329's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible