Search Results

Search: Posts Made By: Homa
1,792
Posted By Akshay Hegde
$ cat file1 ...
$ cat file1
>ENSGALG00000000011|ENSGALT00000000012|57|1123|1125
AACTGTGTGTTTTTT
>ENSGALG00000000012|ENSGALT00000000013|57|1145|1155
AAAAAAGGTCCTGTGTGC...
1,792
Posted By zozoo
i think you can give a try with awk -F option to...
i think you can give a try with awk -F option to specify the filed limiter of your choice.
1,763
Posted By bartus11
Try:awk '{a[$1]+=$6}END{for (i in a) print...
Try:awk '{a[$1]+=$6}END{for (i in a) print i,a[i]}' file
1,631
Posted By Scrutinizer
Try: awk '{count[$1]++} END{for (genes in...
Try:
awk '{count[$1]++} END{for (genes in count) print genes, count[genes]}' ZGenes
888
Posted By RudiC
Waaay to complicated! Tryawk '{CNT[0]=CNT[1]=0;...
Waaay to complicated! Tryawk '{CNT[0]=CNT[1]=0; for (i=1; i<=NF; i++) CNT[$i]++; print CNT[0], CNT[1]}' file
4 0
6 0
0 6
0 6
4 2
1,075
Posted By rbatte1
What shell are you using? I'm a bit confused...
What shell are you using?

I'm a bit confused with what it is trying to do, but here goes:-

for i in $(find /file directory/ -type d | grep file name)
do
prefix=`echo $i | cut -f5 -d"/"`...
1,075
Posted By hanson44
-type d means only find directories. Go to a...
-type d means only find directories.
Go to a directory tree and experiment:


$ find . -type f -print
$ find . -type d -print
prefix is a variable here. It's holds a value.
For example, if the...
1,075
Posted By PikK45
find /file directory/ -type d => list out all...
find /file directory/ -type d => list out all the directories (-type d) in /file directory/
grep file_name => finds the file_name from the list
$(command) => pretend the result of the command to...
3,412
Posted By MadeInGermany
In general, for an efficient merge operation, you...
In general, for an efficient merge operation, you need to have two files.
If you have one file, the shell can open it twice with another file descriptor.

#!/bin/sh
sort -k4,4 infile |
(
# in...
1,716
Posted By Don Cragun
The code provided by in2nix4life is much better,...
The code provided by in2nix4life is much better, but here is a corrected version of what Homa was trying to do:
awk -F ' ' -v OFS=' ' 'FNR == NR { o[$1] = NR;next }
{ $1 = o[$1]" "$1;print }' File1...
3,412
Posted By Corona688
A moment, that doesn't look quite right. ...
A moment, that doesn't look quite right.

[edit] I was restoring four columns when I only needed three. Remove the $4=D from the code and it works.
3,412
Posted By Corona688
$ awk 'NR==FNR { ARR[$4]=$0 ; next }; $1 in ARR {...
$ awk 'NR==FNR { ARR[$4]=$0 ; next }; $1 in ARR { A=$1 ; B=$2; C=$3; D=$4 ; $0=ARR[$1]; $1=A; $2=B; $3=C } 1' datafile datafile

F0100010 A C F0100010 A C BTA-29644-no-rs 7.29827
F0100020 A G...
3,412
Posted By Corona688
Oh, I see. You don't want it sorted. You want...
Oh, I see. You don't want it sorted. You want columns 4 through n of all rows moved such that column 1 lines up with column 4.

Working on it.
1,716
Posted By in2nix4life
awk 'FNR==NR{a[$1]=$0} NR>FNR && ($1 in a) {print...
awk 'FNR==NR{a[$1]=$0} NR>FNR && ($1 in a) {print a[$1]}' file2 file1 > file3
1,054
Posted By pamu
I think you have edited your previous input....:D...
I think you have edited your previous input....:D

As per your previous input i have considered as you want only first digit of $8.

That's why i used substr()

substr($8,1,1) - Prints only...
1,054
Posted By pamu
Assuming your file structure as it is. ...
Assuming your file structure as it is.

Try....

awk '{ $1=$1+$7+$(NF-1);$2=$2+substr($8,1,1)+$NF;$7=$8="";gsub(" +"," ",$0);NF-=2;}1' file
1,459
Posted By pamu
If your all file1 entries are present in file2...
If your all file1 entries are present in file2 then my script will produce correct output as what you need.
1,459
Posted By pamu
Try awk 'NR==FNR{X[$1]=$2"...
Try

awk 'NR==FNR{X[$1]=$2" "$3;next}{if(X[$2]){split(X[$2],P," ")
if(P[1] == P[2]){if($3 != $4){print $2,$3,$4;delete X[$2]}}else{print $2,X[$2];delete X[$2]}}}' file1 file2
1,459
Posted By bartus11
Try:awk 'NR==FNR&&$3!=$4{a[$2]=$3"...
Try:awk 'NR==FNR&&$3!=$4{a[$2]=$3" "$4}NR==FNR{next}$1 in a{$2=a[$1];$3="";}1' file2 file1
1,847
Posted By only4satish
Hi Mr complex, could you please let me...
Hi Mr complex,

could you please let me know how it works ?


awk '!a[$1]++' infile
1,847
Posted By complex.invoke
awk '!a[$1]++' infile
awk '!a[$1]++' infile
3,568
Posted By cabrao
There was a typo in my previous comment, you need...
There was a typo in my previous comment, you need to add option -n (for numeric sort)

Cheers ;)
3,247
Posted By alister
Just use paste as first suggested by bipinajith....
Just use paste as first suggested by bipinajith. It was created for this specific task.

Memory consumption shouldn't be an issue since paste doesn't need to read more than one line at a time to do...
3,247
Posted By Scrutinizer
Alternative awk: awk '{getline $(NF+1)<f}1'...
Alternative awk:
awk '{getline $(NF+1)<f}1' f=file2 file1
3,247
Posted By Yoda
I'm not sure about the memory utilization. If you...
I'm not sure about the memory utilization. If you insist a solution using awk here it is:-

awk 'NR==FNR{a[FNR]=$0;next} {print a[FNR], $0 } ' file1 file2
Showing results 1 to 25 of 29

 
All times are GMT -4. The time now is 02:55 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy