How to remove a break line \n in awk when print the result
2
0
Entering edit mode
4.3 years ago
xatabadich • 0

Dear all,

I have an inputfile.txt which contains the following:

ftp://ftp.ncbi.nlm.nih.gov/genomes/all/GCF/000/248/415/GCF_000248415.2_ASM24841v2
ftp://ftp.ncbi.nlm.nih.gov/genomes/all/GCF/001/011/135/GCF_001011135.1_ASM101113v1
..
..
..

I used the command which purpose is to download genome assemblies from NCBI website

awk 'BEGIN{FS=OFS="/";filesuffix="genomic.fna.gz"}{ftpdir=$0;asm=$10;file=asm"_"filesuffix;print "wget "ftpdir,file}' inputfile.txt > outputfile.sh

The problem is that it generates a string with break lines like this:

wget ftp://ftp.ncbi.nlm.nih.gov/genomes/all/GCF/000/248/415/GCF_000248415.2_ASM24841v2

/GCF_000248415.2_ASM24841v2

_genomic.fna.gz

And I want it to be one line like this:

wget_ftp://ftp.ncbi.nlm.nih.gov/genomes/all/GCF/000/248/415/GCF_000248415.2_ASM24841v2/GCF_000248415.2_ASM24841v2_genomic.fna.gz

How can I achieve it?

Thanks!

bash linux awk • 784 views
ADD COMMENT
0
Entering edit mode
4.3 years ago
awk -F '/' '{printf("%s/%s_genomic.fna.gz\n",$0,$NF);}'  input.txt > urls.txt

and then

wget --input-file=urls.txt

ADD COMMENT
0
Entering edit mode
4.3 years ago
$ perl -pe 's/\n/, /' inputfile.txt
$ tr '\n' ',' < inputfile.txt
ADD COMMENT

Login before adding your answer.

Traffic: 1970 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6