Question: awk, copy and paste single line command
1
gravatar for 3335098459
29 days ago by
333509845920
333509845920 wrote:

Hi

I am just a beginner in the command line and newly introduced to Linux.

I am using software that suggested the following command to convert all the coordinates to plot.

cat <(echo "#CHR SNP BP minLOG10(P) log10(p) r^2") \\ <(paste <(sed '1d' penicillin_SNPs.txt | cut -d "_" -f 2) \\ <(sed '1d' penicillin_SNPs.txt | cut -f 4) | \\ awk '{p = -log($2)/log(10); print "26",".",$1,p,p,"0"}' ) | \\ tr ' ' '\t' > penicillin_snps.plot

Whenever I run this command, I am getting multiple errors

Cat: / dev / FD / 63: no file or directory

Cat: '\': no file or directory

Cat: / dev / FD / 62: no file or directory

Paste: / dev / FD / 62: no file or directory

\: command not found

\: command not found

I don't know the cause of this problem.

Thanks

software error • 246 views
ADD COMMENTlink modified 5 days ago by Biostar ♦♦ 20 • written 29 days ago by 333509845920
1

Just remove all these \\ in your command line should fix it.

ADD REPLYlink written 29 days ago by finswimmer12k

Thanks but removing these \ solved the last two errors but the errors related to cat and paste are still there

Cat: / dev / FD / 63: no file or directory

Cat: / dev / FD / 62: no file or directory

Paste: / dev / FD / 62: no file or directory

how can I solve these?

ADD REPLYlink modified 29 days ago • written 29 days ago by 333509845920
1

can you post the output of head penicillin_SNPs.txt , so that we can have a look what is in this file?

ADD REPLYlink written 29 days ago by lieven.sterck6.3k

Run the command in the directory where you actually have the files referred by the command?

ADD REPLYlink written 29 days ago by 5heikki8.6k
3
gravatar for michael.ante
29 days ago by
michael.ante3.5k
Austria/Vienna
michael.ante3.5k wrote:

Edit ( Kevin Blighe ): scroll down to see answer by OP

--------------------

In one cut call, you use "_" as delim char, in the other you don't.

If you get errors like this, dissect your one-liner in the single steps. Try first, what your sed .. | cut steps result in , maybe using .. | head to control the first lines. Then test the paste call.

Personally, I would try to solve the whole issue with one awk call.

ADD COMMENTlink modified 4 days ago by Kevin Blighe51k • written 29 days ago by michael.ante3.5k

Yes you are right. This is the complete command divided into different sections by \ I guess.

cat <(echo "#CHR SNP BP minLOG10(P) log10(p) r^2") \\\

<(paste <(sed '1d' penicillin_SNPs.txt | cut -d "_" -f 2) \\\

<(sed '1d' penicillin_SNPs.txt | cut -f 4) | \\\

awk '{p = -log($2)/log(10); print "26",".",$1,p,p,"0"}' ) | \\\

tr ' ' '\t' > penicillin_snps.plot

From which point I should start if I am going to do it one by one?

ADD REPLYlink modified 29 days ago by genomax74k • written 29 days ago by 333509845920

From the most inner steps (the sed '1d' penicillin_SNPs.txt | cut -d "_" -f 2 and sed '1d' penicillin_SNPs.txt | cut -f 4 ) .

Looking at your code: you have <(paste <(sed ...) <(sed ..) | awk '{}') should the awk command not be used after the paste output?

ADD REPLYlink written 29 days ago by michael.ante3.5k

Thanks for pointing out the possible solution. I have used the following command to solve this problem.

(sed '1d' penicilin_SNPs.txt | cut -d "_" -f 2, 4) | awk '{}' > example.txt

I also did some manual changes and it worked.

ADD REPLYlink modified 4 days ago by Kevin Blighe51k • written 27 days ago by 333509845920

correct linux cmdline syntax it should only be a single \ (so not a double!), but that is indeed used as a separator to be able to write a cmdline on several lines in your terminal

ADD REPLYlink written 29 days ago by lieven.sterck6.3k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1164 users visited in the last hour