Search Results

Search: Posts Made By: saint2006
1,471
Posted By Tytalus
something along the lines of: (rewriting...
something along the lines of:


(rewriting your equation to isolate an iteration:

x=y/ln(3.455613x)
)

# y=1;x=1;for i in {1..100}; do x=$(calc "$y/(log(3.455613*$x))"); echo $x;done...
1,168
Posted By alister
Then you can probably just use join. join...
Then you can probably just use join.
join input_file pattern_file

Regards,
Alister
1,168
Posted By alister
Is there a typo in the last line of "Pattern...
Is there a typo in the last line of "Pattern file"? Is it supposed to begin with Student3? If so, are both files sorted by their common key (the first column)?
4,305
Posted By vgersh99
then follow mirni's suggestion with the...
then follow mirni's suggestion with the wild-carded file names:
awk '{print a[FNR]+=$1}END{for(i=1;i in a;i++) print a[i]}' myFiles*
4,305
Posted By vgersh99
paste -d + file1.out file2.out|bc
paste -d + file1.out file2.out|bc
4,305
Posted By mirni
awk 'NR==FNR{a[NR]=$1; next}{print a[FNR]+$1}'...
awk 'NR==FNR{a[NR]=$1; next}{print a[FNR]+$1}' file1.out file2.out
2,897
Posted By vgersh99
Please search the forums (including the 'hints'...
Please search the forums (including the 'hints' at the bottom of this thread) - similar questions have been asked/answer multiple times!
1,586
Posted By rdcwayx
awk 'NR==1{start=$NF;next} {print...
awk 'NR==1{start=$NF;next} {print ++i,start"-"$2;start=$NF}' infile
3,354
Posted By yinyuemi
try: awk -v x=1 'NR==1{n=$0} ...
try:

awk -v x=1 'NR==1{n=$0}
$0==n+1{length(a[x])>0?a[x]=a[x]"\n"$0:a[x]=n"\n"$0;n=$0}$0>n+1{n=$0;x++;}
END{for(i=1;i<=x;i++) {if(a[i])print a[i]"\n--">"file"++j}}' file
3,354
Posted By yinyuemi
try: awk -v x=1 'NR==1{n=$0} ...
try:
awk -v x=1 'NR==1{n=$0}
$0==n+1{length(a[x])>0?a[x]=a[x]"\n"$0:a[x]=n"\n"$0;n=$0}$0>n+1{n=$0;x++;}
END{for(i=1;i<=x;i++) {if(a[i])print a[i]"\n--"}}' file
3,354
Posted By yinyuemi
try: |awk -v x=1 'NR==1{n=$0} ...
try:

|awk -v x=1 'NR==1{n=$0}
$0==n+1{length(a[x])>0?a[x]=a[x]"\n"$0:a[x]=n"\n"$0;n=$0}$0>n+1{n=$0;x++;}
END{for(i=1;i<=x;i++) print (a[i]?a[i]:"--")}' urfile
1,586
Posted By yinyuemi
awk '{print $2,$3"-"$4}' FS="nt|...
awk '{print $2,$3"-"$4}' FS="nt| "
1,586
Posted By 47shailesh
>:cat Stud Student1 10 20 Student2 30 40 ...
>:cat Stud
Student1 10 20
Student2 30 40
Student3 50 60
Student4 70 80

>:more Stud | nawk '{print substr($0,8) $2"-"$3}'
1 10-20
2 30-40
3 50-60
4 70-80
>:
3,354
Posted By guruprasadpr
Hi Try this: $ awk...
Hi
Try this:


$ awk '{a[j++]=$0;}END{for (i=0;i<j;i++){ if (a[i]==a[i+1]-1 || a[i]==a[i-1]+1)print a[i]; else print "--";}}' file
1
2
3
--
44
45
46
--
79
80
81


Guru
7,635
Posted By DGPickett
Make the patterns file into a sed or awk script. ...
Make the patterns file into a sed or awk script. In sed, to have the line before is a bit inconvenient, a looping sed:
sed -n '
:loop
$q
N
/\nPATTERN_1/b p
/\nPATTERN_2/b p
. . ....
7,635
Posted By pravin27
You can use grep with option -f and -B grep...
You can use grep with option -f and -B

grep -B 1 -f pattern_file search_file
3,597
Posted By m.d.ludwig
<smacks onhead="hard">D'oh</smacks> ...
<smacks onhead="hard">D'oh</smacks>

Sometimes you get caught up with the tool you are using, when you should look at all your tools.
3,597
Posted By binlib
A simple invocation of uniq may be sufficient for...
A simple invocation of uniq may be sufficient for your need:
uniq -f1 -c
3,597
Posted By m.d.ludwig
Again, not to cause trouble :-) as TMTOWTDI, but...
Again, not to cause trouble :-) as TMTOWTDI, but while your code (post #5) works for the example file, it also has two errors -- nothing is printed if the line is unique or the last line is unique....
3,597
Posted By summer_cherry
try perl below
while(<DATA>){
my @tmp = split;
if($.==1){
$pre=$tmp[1];
$cnt=1;
next;
}
else{
if($tmp[1] eq $pre){
$cnt++;
}
else{
$hash{$pre}->{$cnt}=1;
$cnt=1;...
3,597
Posted By m.d.ludwig
Not to cause trouble :-) but while the example...
Not to cause trouble :-) but while the example code works for the example file, it has four errors -- nothing is printed if $2 is "0", if the line is unique, or the last line is unique; nor is the...
3,597
Posted By Franklin52
Try: awk ' $2==p{c++;next} p && c>1{ print...
Try:
awk '
$2==p{c++;next}
p && c>1{ print p, c}
{p=$2;c=1}
END{if(c>1)print p, c}' file
1,918
Posted By danmero
awk 'x{$0=$0FS ($2-x)}{x=$3}1' file
awk 'x{$0=$0FS ($2-x)}{x=$3}1' file
1,918
Posted By pravin27
try this, awk '{if(NR==1){a=$3;print}else...
try this,

awk '{if(NR==1){a=$3;print}else {print $0,$2-a;a=$3}}' inputfile
1,452
Posted By steadyonabix
nawk ' NF==3{ id=$1;printf("%s\t\t%d\t%s\n",...
nawk ' NF==3{ id=$1;printf("%s\t\t%d\t%s\n", id,$2,$3);next } {printf("%s\t\t%d\t%s\n", id, $1, $2)}' file
Showing results 1 to 25 of 31

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