Visit Our UNIX and Linux User Community

Search Results

Search: Posts Made By: johnkim0806
4,465
Posted By alister
In my opinion, you both are trying to be too...
In my opinion, you both are trying to be too clever. Throw away the unnecessary hardcoded maximum (9 in post #2) and the pointless ternary operators in favor of more readable code:
awk '{m=$1; for...
4,465
Posted By Yoda
awk...
awk 'BEGIN{min=9}{for(i=1;i<=NF;i++){min=(min<$i)?min:$i}print min;min=9}' file
1,251
Posted By Chubler_XL
Try this: awk ' { k[NR]=$1" "$2 ...
Try this:

awk '
{
k[NR]=$1" "$2
for(i=3;i<=NF;i++) C[NR,i]=$i
m=i>m?i:m
}
END {
srand();
for(i=2;i<=NR;i++) {
for(j=3;j<m;j++) {
L=2+int(rand()*(NR-1))
...
4,672
Posted By Chubler_XL
You could try shuf filename or sort --random-sort...
You could try shuf filename or sort --random-sort filename
624
Posted By michaelrozar17
Replace with the below sed in the loop and try.. ...
Replace with the below sed in the loop and try..
sed 's/k/'$i'/g' inputfile
1,028
Posted By rwuerth
quick and dirty... echo 121231212 | sed -e...
quick and dirty...

echo 121231212 | sed -e 's/\(.\)/\1 /g'


This will put a space after your last number however.
1,014
Posted By elixir_sinari
Like this? n=$(wc -l < data.txt)
Like this?
n=$(wc -l < data.txt)
865
Posted By rdrtx1
Try: gawk '{if ($2 < 0.05) print $1, $2,...
Try:

gawk '{if ($2 < 0.05) print $1, $2, FILENAME}' > ${i}
1,447
Posted By rdrtx1
awk...
awk 'NR==FNR{a[$1]=$2;next;}{a[$1]=(a[$1]==""?"NA":a[$1]) " " $2;}END{for (i in a) print i,a}' [I]file1 file2
743
Posted By rdrtx1
Just setting a very high value to start with....
Just setting a very high value to start with. There are probably other ways to accomplish the same.
743
Posted By rdrtx1
awk ' BEGIN { FS="[()]";} NR==1 {print;} ...
awk '
BEGIN { FS="[()]";}
NR==1 {print;}
NR>1 {
fl=$1;
sub(" *$","",fl);
sub(" *[^ ]*$","",fl);
la=10000000;
of="";
for (f=2; f<=NF; f+=2) {
pf=$(f-1);
sub(" *$","",pf);
...
834
Posted By Corona688
1) While still in the first file(the total number...
1) While still in the first file(the total number of lines and file line-number agree) load into array A.
2) Whenever the third column matches anything in A, print the line.
$ awk 'NR==FNR {...
834
Posted By alister
What's the point of those sorts if the sorted...
What's the point of those sorts if the sorted results are never used?

The only thing you need is that awk statement with the relevant files in the correct order piped into a single sort with the...
869
Posted By itkamaraj
$ awk '{print "("$1"-"$2")"}' input.txt (1-2) ...
$ awk '{print "("$1"-"$2")"}' input.txt
(1-2)
(3-4)
(5-6)
(7-8)
869
Posted By zaxxon
$ while read LINE; do echo "($(echo ${LINE}| tr...
$ while read LINE; do echo "($(echo ${LINE}| tr -s ' ' '-'))"; done < input.txt
(1-2)
(3-4)
(5-6)
(7-8)
1,468
Posted By raj_saini20
try this awk 'BEGIN{i=1; while (getline <...
try this

awk 'BEGIN{i=1; while (getline < "bimfile")
{
if(match($5,$6))
{
ind=i":"$5;
a[ind]=0;
ind=i":"$6;
a[ind]=0;
i++
}
else
{...
1,468
Posted By Chubler_XL
Should the highlight value below be 0 1 (not 0...
Should the highlight value below be 0 1 (not 0 0)?
id1 id1 G A A C G G T C T T NA T -> id1 id1 0 0 A C G G T C T T NA T


On line 2 why does T T go to 1 1 for 2nd last allele and 0 0 on last...
802
Posted By Ygor
This should work for any size...$ cat file1.txt ...
This should work for any size...$ cat file1.txt
var1 var2 var3 var4 var5 var6
A G A T G T
G A A A A A
A A A A A A
G A G T A T

$ awk 'NR == 1 {
split($0, var, FS)
...
804
Posted By gary_w
Is the minus always the last character on a line?...
Is the minus always the last character on a line?

grep '\-$' x.dat >> minus.txt
804
Posted By tukuyomi
If you only want to catch '-' in field 6, you'll...
If you only want to catch '-' in field 6, you'll want this:
awk -F'[ :]' '$6=="-"' file1.txt
804
Posted By jtollefson
Maybe it's not this simple, but, couldn't you...
Maybe it's not this simple, but, couldn't you just grep it out?


grep - file1.txt >> minus.txt
616
Posted By alister
cut -d' ' -f $(paste -sd, file1) file2 ...
cut -d' ' -f $(paste -sd, file1) file2

Regards,
Alister
616
Posted By itkamaraj
$ awk 'BEGIN{while(getline<...
$ awk 'BEGIN{while(getline< "file1"){a[i++]=$0;}}{for(j in a){printf("%s ",$a[j])}print ""}' file2
1 3 8 9
1 1 0 1
1 1 0 0
0 0 1 1
616
Posted By Corona688
awk 'NR==FNR { C[++L]=$1; next } { printf("%s",...
awk 'NR==FNR { C[++L]=$1; next } { printf("%s", $(C[1]) ); for(N=2; N<=L; N++) printf("\t%s", $(C[N]) ); printf("\n"); }' columns data
684
Posted By itkamaraj
$ for i in $(cat file1.txt); do echo $i; done 1...
$ for i in $(cat file1.txt); do echo $i; done
1
2
4
5
10
11



---------- Post updated at 09:29 PM ---------- Previous update was at 09:28 PM ----------

$ tr ' ' '\n' < file1.txt
1
2...
Showing results 1 to 25 of 30

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