Why command gives the error: extra operand 23243?
1
0
Entering edit mode
6.1 years ago
salamandra ▴ 550

Why does following command:

gene1=$(cat FOS_3TF_day2/anngene_FOS_3TF_day2 | tail -n+2 | cut -f12 | sort -u)
gene2=$(cat FOS_3TF_day20/anngene_FOS_3TF_day20 | tail -n+2 | cut -f12 | sort -u)
comm -12 $gene1 $gene2 > common.gene.FOS3TFD2.FOS3TFD20

give the error:

comm: extra operand ā€˜23243ā€™
Try 'comm --help' for more information.

?

commandline Bash comm • 5.2k views
ADD COMMENT
0
Entering edit mode
6.1 years ago

replace

'comm -12 $gene1 $gene2'

with a test

'echo $gene1 $gene2'

I'm pretty sure, you'll get more than two files/arguments.

e.g:

$ comm A B C
comm: extra operand ā€˜Cā€™
Try 'comm --help' for more information.

hence, the way you're computing gene1 and gene2 is wrong.

ADD COMMENT
0
Entering edit mode

it printed both with echo. I'm not understanding what you mean

ADD REPLY
1
Entering edit mode

and what's the result of the 'echo' statement? Can you post that for inspection?

ADD REPLY
0
Entering edit mode
echo $gene1 | head

100033819 100500862 10381 105375972 10579 23243 2495 283120 3012 3043 3320 378938 4811 619552 6235 647121 79007 8328 8358 9147

echo $gene2 | head

10 100 1000 10000 100008586 100009613 100009667 100009676 10001 10002 10003 100033417 100033450 100033460 100033805 100033810 100033820 100034743 100038246 100048912 100049076 100049587 100049716 10006 10007 100073347 10008 100093630 100093631 100093698 1001 10010 100101121 100101266 100101478 100101629 100101938 100113378 100113379 100113384 100113403 100113404 100113407 100124534 100124535 100124536 100124537 100124538 100124539 100124541 100125288 100126270 100126299 100129836 100129842 100129858 100129924 100129940 100129969 10013 100130015 100130017 100130148 100130172 100130231 100130238 100130264 100130275 100130298 100130301 100130302 100130331 100130342 100130348 100130357 106635546 106635547 106635548 106635615 106635682 106635683 10664 10665 10666 106660609 106660612 10667 10671 10673 10675 10678 1068 10681 10687 10690 10691 10693 107 1070 107001062 107075116 1071 107133515 10714 10715 10716 107161151 107161159 107178918 10718 107181291 10720 10721 10723 10725 10728 1073 10730 10733 10734 10735 10736 10738 10739 107397392 107399301 107399303 10740 10742 10743 10744 10745 10746 10748 1075 10752 10753 10758 10761 10762 10765 10766 10767 10769 10771 10775 10777 10780 10781 10782 10783 10787 10788 10793 10794 10795 10797 10798 107984640 107985781 108 1080 10800 10801 10802 10804 10806 10807 10808 1081 10810 10813 10814 10815 10818 10819 10821 10824 10825 10827 10838 10840 10841 10842 10846 10857 108570035 10859 10863 10865 10867 1087 10871 10873 10874 10875 10876 10877 10878 1088 10880 10881 10882 10884 10885 10886 108868751 10887 10888 1089 10890 10891 10893 10894 108949267 109 10900 10901 10902 10904 10905 10907 10910 10911 10912 10913 10914 10915 10917 10919 10920 10923 10924 10926 10927 10928 10929 10930 10933 10939 10941 10942 10943 10944 10949 10950 10951 10952 10954 10955 10956 10957 10960 10964 10965 10969 10970 10971 10972 10973 10979 10981 10982 10983 10984 10987 10988 10990 10993 10994 10999 11000 11001 11004 11005 11011 11016 11017 11020 11022 11030 11031 11033 11036 11037 11039 11040 11042 11043 11044 11047 1105 11052 11055 11056 11057 11059 11060 11061 11062 11063 11064 11065 11068 11069 11072 11073 11074 11075 11076 11077 11078 11080 11081 11082 11085 11086 1109 11091 11092 11093 11095 11096 11097 11098 11099 111 11101 11102 11103 11104 11105 11107 11108 1111 11113 11116 11118 11119 1112 11122 11123 11124 11126 11127 11128 1113 11130 11131 11132 11136 11137 11138 1114 11140 11141 11143 11145 11146 11148 11152 11153 11154 11155 11157 11159 1116 11162 11164 11165 11167 11168 11169 11170 11171 11172 11173 11174 11176 11177 11178 11179 1118 11181 11182 11183 11185 11189 1119 11190 11193 11196 11197 11199 112 11200 11201 1121 11211 11213 11214 11215 11216 11217 1122 11221 11222 11226 11227 1123 11235 11236 11237 11238 112399 1124 11240 11243 11245 11247 112479 11248 112487 11249 112495 11250 11252 11254 11257 112574 11259 112597 112609 11261 112616 112714 11272 112724 112744 11275 112752 112755 11276 11278 11279 1128 11280 112802 11281 11283 112840 11285 112885 1129 112937 112942 112970 113 1130 11309 113091 1131 11311 113115 11314 113146 113174 113177 113189 11319 1132 11320 113201 11321 11325 113251 11326 113263 113278 11328 11329 1133 11332 11333 11335 11339 1134 11340 113402 11341 11342 11343 113444 11345 113451 11346 113510 1136 113622 1137 113791 113802 113828 113835 113878 1139 114 114036 114041 114042 114044 114049 114088 114112 114131 114134 1142 114299 1143 114327 114548 114569 114571 114599 114614 114625 114659 1147 114760 114780 114781 114784 114786 114787 114788 114789 114790 114791 114792 114793 114794 114795 114796 114798 114799 114800 114801 114803 114804 114805 114815 114818 114821 114824 114825 114827 114836 114876 114879 114880 114882 114883 114885 114898 1149 114905 114907 114926 114971 114984 114987 114991 115 115004 115019 115111 115123 115196 1152 115201 115207 115209 115265 115286 115294 115330 115350 115352 115353 ...

ADD REPLY
1
Entering edit mode

you're doing things wrong. The 'comm' command expects only two filenames. You're giving it a bunch of numbers.

I think you want:

comm -12 <(cat FOS_3TF_day2/anngene_FOS_3TF_day2 | tail -n+2 | cut -f12 | sort -u)  <(cat FOS_3TF_day20/anngene_FOS_3TF_day20 | tail -n+2 | cut -f12 | sort -u) > common.gene.FOS3TFD2.FOS3TFD20
ADD REPLY
0
Entering edit mode

It works your way, but I would like to know how can we then store the value of

cat FOS_3TF_day2/anngene_FOS_3TF_day2 | tail -n+2 | cut -f12 | sort -u

in a temporary variable and of

cat FOS_3TF_day20/anngene_FOS_3TF_day20 | tail -n+2 | cut -f12 | sort -u

in another, so that we could use in commands such this or others:

comm -12 variable1 variable2 > output

Is it possible?

ADD REPLY
1
Entering edit mode

not really.

unless you capture the output in 2 files and then use those.

What you might be able to do is to store the filename in a variable and work with that (but you can't circumvent creating the files)

ADD REPLY

Login before adding your answer.

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