Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I grep lines involving tabs?
    primarykey
    data
    text
    <p>I came across some problem with playing with 'grep'; and probably about grepping a tab. I have two files shown as below, both of which are tab-delimited.</p> <pre><code>FM_DEL_50r.bed chr1 3392391 3658426 DEL chr1 3392364 3658425 DEL chr1 4011952 4392064 DEL chr1 4011953 4392062 DEL chr1 4468526 4665322 DEL chr1 4468523 4665322 DEL FC_DEL_50r.bed chr1 2612264 2613324 DEL chr1 2612205 2613007 DEL chr1 3392391 3658426 DEL chr1 3392391 3658426 DEL chr1 4011952 4392064 DEL chr1 4011953 4392060 DEL </code></pre> <p>I hope to grep some lines which appear in both files:</p> <pre><code>cat FC_DEL_50r.bed |grep `cat FM_DEL_50r.bed |head -2|tail -1|awk '{print $2"\t"$3}'` </code></pre> <p>However there's error: </p> <pre><code>grep: 4392064: No such file or directory </code></pre> <p>I tried <code>cat FM_DEL_50r.bed |head -2|tail -1|awk '{print $2"\t"$3}'</code>, it actually works and outputs <code>4011952 4392064</code></p> <p>So maybe we cannot grep format like 'number"\t"number"? thx</p> <p>edit: how stupid I am. I should use double-quotes..........(I first used single-quote and didn't work...)</p> <pre><code>cat FC_DEL_50r.bed |grep "`cat FM_DEL_50r.bed |head -2|tail -1|awk '{print $2"\t"$3}'`" </code></pre> <p>Follow-up questions: I wrote a bash script, based on the questions above:</p> <pre><code>#!/bin/bash for((c=1;c&lt;=542;c++)) do LINE=`head -$c FM_DEL_50r.bed|tail -1` P1=`cat $LINE|awk '{print $1"\\t"$2"\\t"$3}'` GREP1=`cat FC_DEL_50r.bed |grep "$P1"` X1=`cat $GREP1 |awk '{print $5"\\t"$6"\\t"$7}'` P2=`cat $LINE|awk '{print $5"\\t"$6"\\t"$7}'` GREP2=`cat MC_DEL_50r.bed |grep "$P2"` X2=`cat $GREP2 |awk '{print $5"\\t"$6"\\t"$7}'` if [ $X1 -eq $X2 ] then echo "$LINE"\t"$X1" fi done </code></pre> <p>However it produces </p> <pre><code>cat: chr1: No such file or directory cat: 27122653: No such file or directory cat: 27446984: No such file or directory cat: DEL: No such file or directory cat: chr1: No such file or directory cat: 27880115: No such file or directory cat: 28225069: No such file or directory cat: DEL: No such file or directory </code></pre> <p>Seems it splits all columns of one line and cannot recognize them. What's the problem this time? thx</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload