Search Results

Search: Posts Made By: newbie83
5,880
Posted By Don Cragun
OK. It looks like inp1.txt was created on a...
OK. It looks like inp1.txt was created on a Windows box. Your matching fields defined in inp2.txt are strings of numbers, but in inp1.txt they are strings of numbers followed by a <carriage-return>...
5,880
Posted By Akshay Hegde
Now I am confused, what do you expect from your...
Now I am confused, what do you expect from your new input ? can you show output sample
5,880
Posted By Don Cragun
Your specification said that field5 had subfields...
Your specification said that field5 had subfields separated by a colon; your real data seems to contain subfields you want to match in fields 5 and 6 separated by a colon and a space. None of the...
5,880
Posted By Don Cragun
Yoda's code will find a match if any subpart of...
Yoda's code will find a match if any subpart of field 4 in file2 is matched by field 2 in file1. Akshay's code will find a match only if the 2nd subpart of field 4 in file 2 is matched by field 2 in...
5,880
Posted By Yoda
Try this: awk ' NR == FNR { ...
Try this:
awk '
NR == FNR {
A[$0] = $NF
next
}
{
for ( k in A )
{
n = split (...
5,880
Posted By Akshay Hegde
Another approach : $ awk ...
Another approach :
$ awk 'FNR==NR{A[$4]=$0;next}{x=0;for(i in A){split(A[i],X,":");if($2==X[2]){x=1;print $0,A[i]}}if(x==0)print}' file2 file1
A B C D L E:B:C
E F
G H G H R H:H:I:J
1,544
Posted By Yoda
Not sure why! This is what I get. Sample...
Not sure why! This is what I get.

Sample input datas:
$ cat file1.txt
[OR] KOG0001 Ubiquitin and ubiquitin-like proteins
ath: At1g31340
ath: At1g53930
ath: At1g53950
[J] KOG0002 60s...
1,544
Posted By Yoda
Did you make any modifications in the awk program...
Did you make any modifications in the awk program that I posted?

Another suggestion: If you are on SunOS / Solaris try using nawk or /usr/xpg4/bin/awk
1,544
Posted By Yoda
Here is something that you can start working...
Here is something that you can start working with:
awk '
NR == FNR {
A[$1] = $1
next
}
!/\[/ && FILENAME == "file2.txt" {
...
1,227
Posted By alister
You can leverage pathname expansion to further...
You can leverage pathname expansion to further simplify:
for dir in *cuff/
do
awk '{...}' "${dir}/xyz.gtf"
done
Regards,
Alister
1,227
Posted By Yoda
for dir in *cuff do [ -d "$dir" ] &&...
for dir in *cuff
do
[ -d "$dir" ] && awk '{...}' "${dir}/xyz.gtf"
done
2,054
Posted By ripat
Is it this that you are after? sort file...
Is it this that you are after?

sort file -k1,1 -k2,2n | awk '
{nbr[$1]++; a[$1]= a[$1] ? a[$1]"@"$2 : $2; sum[$1]+=$2}

END {
for (key in a) {
split(a[key], b, "@")
len =...
2,697
Posted By Corona688
* will match directory and file names alike, so...
* will match directory and file names alike, so you can handle it exactly the same way.

30,000 files may easily be too many to fit into *, however. You could use ls with a read loop instead. ...
1,457
Posted By Scrutinizer
@ newbie83: I get: $ awk ' $1=="collect" {...
@ newbie83: I get:
$ awk '
$1=="collect" {
sub(/.*tbc\</,"");
sub(/;.*/,"");
print FILENAME, $0
} ' file1 file2
file1 A,B,C
file1 D,B,C,A
file2 A
file2 C,A
file2 B,A...
1,457
Posted By Scrutinizer
Hi, I just corrected a number of things in what...
Hi, I just corrected a number of things in what you were trying to do, to give you an idea:
awk '
$1=="collect" {
sub(/.*tbc\</,"");
sub(/;.*/,"");
print FILENAME, $0
}
'...
1,457
Posted By krishmaths
Might need some performance tuning, but works. ...
Might need some performance tuning, but works.

awk -F";" '/collect/ {sub(/tbc</,"");print $2}' File1 | paste -sd , - | awk -F, '{for(i=1;i<=NF;i++) print $i}' |sort -u | tr "\n" "\t"
2,137
Posted By balajesuri
One way to do this: for f1 in bam_*.bam do...
One way to do this:

for f1 in bam_*.bam
do
mid=${f1#*_}
mid=${mid%.*}
f2=bed_${mid}.bed
awk 'NR==FNR { commands }' $f1 $f2 > out_${mid}.txt
done
2,703
Posted By in2nix4life
That was just an example to set you on your way. ...
That was just an example to set you on your way. Since you didn't display an example of your file, this is just a guess, but it works when applied to a file:


cat file

1.1 . . 2.2 3.3 . ....
2,703
Posted By RudiC
FIRST: your file is a DOS file, CR LF (0x0D 0x0A)...
FIRST: your file is a DOS file, CR LF (0x0D 0x0A) terminated. To correctly work upon it, remove the CR chars from it (copiously covered in these fora).
Then try: awk '{for (i=1; i<=NF; i++) if...
2,703
Posted By MadeInGermany
Now I see that gsub() does not support \1...
Now I see that gsub() does not support \1 references.
Also I see one needs 3 cycles to replace a row of dots.
With perl this becomes:
perl -pe 'for ($i=1;$i<=3;$i++) { s/(^|\D)\.(\D|$)/$1 $2/g...
2,703
Posted By MadeInGermany
awk '{for (i=1;i<=2;i++) gsub(...
awk '{for (i=1;i<=2;i++) gsub( /(^|[^0-9])\.([^0-9]|$)/ , "\1 \2")} 1'
2,703
Posted By weddy
i would suggest to use a "cut" you can use a loop...
i would suggest to use a "cut" you can use a loop to move the cut N times across the columns check for a value, then loop through the rows in a loop. The use of a nested loops. I have an example of...
2,703
Posted By in2nix4life
echo "1.1 . . 2.2" | sed 's/ \. \. / /g' ...
echo "1.1 . . 2.2" | sed 's/ \. \. / /g'

1.1 2.2
1,846
Posted By zozoo
for i in `cat file1` do grep $i file2...
for i in `cat file1`
do
grep $i file2 >>output
done
1,846
Posted By Yoda
I would highly recommend to avoid using this...
I would highly recommend to avoid using this syntax: for i in `cat file1`

You can find the reason here (http://partmaps.org/era/unix/award.html#backticks)
Showing results 1 to 25 of 56

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