how to use multiple command in one line with using the output of last command to the next
0
0
Entering edit mode
11 months ago
sata72 • 0

I want to use several command in linux, and for second command I want to use the output of first and etc. I have tried this but im not sure that use the out put of first command for the second!

Thanks in advance!

bed file:

2       1376    1477    4
2       1477    1516    2
2       1516    1520    4
2       1520    1521    2

Command:

awk '$4 >=20 {print}' *.bed bedtools multiinter -i *.bed > output.bed
bedtools linux bed • 1.1k views
ADD COMMENT
0
Entering edit mode

I think pipes (symbol |) is what you're looking for.

See the following bash tutorial on pipes: https://linuxhint.com/bash_pipe_tutorial/

ADD REPLY
0
Entering edit mode

... > file.ext - this syntax means you explicitly want to gather the information in to a file.

Instead, you want to pipe (|) the output to the next program.

Important to note:

  1. This directs the STDOUT, so ensure the information you want is in the STDOUT (it usually is)
  2. The program that comes next must accept STDOUT as input. If it expects a file, you need to do extra work.
ADD REPLY
0
Entering edit mode

I dont know using the "file.ext", is the good idea. There are several files *.bed. so this files at first shoud be filtered and then would use for the beedtools. the output of bedtools would be one file: out.bed. I used this command but it not work, it needs to be modified.

awk '$4 >=20  {print$0}'  *.bed  | bedtools multiinter -i  echo > output.bed
ADD REPLY
0
Entering edit mode

You don't need to use echo. The content will be printed to STDOUT anyway.

Suggest you spend some time learning the basics of Bash piping.

As it stands this question isn't really bioinformatics related and may be considered off-topic.

ADD REPLY
0
Entering edit mode

please, explain what you're trying to do with this/those(?) bed files.

ADD REPLY
0
Entering edit mode

At first i want to have a filter with column 4 and keep the data that (4 >=20), at second I want to use this files that filters for input of bedtools to finding overlapped sections.

ADD REPLY
0
Entering edit mode

something like ?

 bedtools multiinter -i *.bed | bedtools intersect -a - -b <( awk '$4 >=20' *.bed | cut -f1-3 | sort -t $'\t' -k1,1 -k2,2n | bedtools merge) 
ADD REPLY
0
Entering edit mode

Thanks so much dear Pierre I seems it works, I have a ouput as I expected, First can you tell me why you use both "multiinter and intersect"?

ADD REPLY
0
Entering edit mode

First can you tell me why you use both "multiinter and intersect"

please, read the manuals to understand the difference.

ADD REPLY

Login before adding your answer.

Traffic: 2357 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