Search Results

Search: Posts Made By: origamisven
1,251
Posted By Yoda
Sure. awk ' # Look for pattern VEL in...
Sure.
awk '
# Look for pattern VEL in each record
/VEL/ {
# if found set variable c value to 3
c = 3
}
# For each subsequent...
1,251
Posted By Yoda
awk '/VEL/{c=3}c-->=1{sub("SOL","VEL")}1'...
awk '/VEL/{c=3}c-->=1{sub("SOL","VEL")}1' file
1,776
Posted By elixir_sinari
If it is not desired, a slight tweak will do the...
If it is not desired, a slight tweak will do the trick.
awk '{atom[NR]=$3;xi[NR]=$6;yi[NR]=$7;zi[NR]=$8}
END{
for(i=1;i<=NR;i++)
for(j=i+1;j<=NR;j++)
{
dist=sqrt((xi[i]-xi[j])^2 +...
1,776
Posted By RudiC
Yes: e.g.C3 C4 1.53222 C4 C3 1.53222 But maybe...
Yes: e.g.C3 C4 1.53222
C4 C3 1.53222 But maybe that's desired?
1,776
Posted By elixir_sinari
Is it? But, then that's a "faithful" conversion...
Is it? But, then that's a "faithful" conversion of that loop to an awk script. :)
C3 C4 1.53222
C3 O5 2.40508
C3 O6 2.56728
C4 C3 1.53222
C4 O5 1.23535
C4 O6 1.43856
O5 C3 2.40508
O5 C4...
1,776
Posted By RudiC
awk '{for (i=3;i<=NF;i++) TMP[NR,i]=$i} ...
awk '{for (i=3;i<=NF;i++) TMP[NR,i]=$i}
END {for (i=1;i<=NR;i++)
{for (j=NR;j>i;j--)
{dist = sqrt ( (TMP[i,6]-TMP[j,6])^2 + (TMP[i,7]-TMP[j,7])^2 +...
1,776
Posted By elixir_sinari
And what's the value of DISTCUT for the output...
And what's the value of DISTCUT for the output posted?

Try:
awk '{atom[NR]=$3;xi[NR]=$6;yi[NR]=$7;zi[NR]=$8}
END{
for(i=1;i<=NR;i++)
for(j=1;j<=NR;j++)
{
if(j==i) continue
...
1,464
Posted By bartus11
Try: paste file1 file2 | awk -v cut1="$var1" -v...
Try: paste file1 file2 | awk -v cut1="$var1" -v cut2="$var2" '{for (i=1;i<=3;i++){if($i<cut1&&$(i+3)>cut2){print "value1:",$(i+3),"| value2:",$i,"| line:",NR,"| column:",i}}}'
2,929
Posted By Corona688
You're supposed to use [code] tags. Formatting...
You're supposed to use [code] tags. Formatting works fine inside them.

---------- Post updated at 09:50 AM ---------- Previous update was at 09:47 AM ----------

Try %8s instead of %s for...
1,707
Posted By vgersh99
here's one place...
here's one place (https://www.unix.com/answers-frequently-asked-questions/16576-some-sites-recommended-our-users.html).
Here's another (http://awk.info/).
1,707
Posted By vgersh99
I'm not sure if your desired output jives with...
I'm not sure if your desired output jives with your description, but...

nawk '$2>s{print $0;s*=2}' s=0.05 myFile
1,807
Posted By Franklin52
awk 'NR==1{s=$2;next}{print $2-s;s=$2}' file
awk 'NR==1{s=$2;next}{print $2-s;s=$2}' file
1,466
Posted By bartus11
perl -F"" -alne 'print @F[0..$#F-3],"...
perl -F"" -alne 'print @F[0..$#F-3]," ",@F[$#F-2..$#F]' file
1,466
Posted By rangarasan
sed
Hi,
Try this one,


sed 's/\([0-9]*\)\(.*\)/\1 \2/g' Input_File


Cheers,
Ranga:)
2,040
Posted By Corona688
Using awk to process individual lines is...
Using awk to process individual lines is extremely wasteful. It's efficient at batch data but takes time to load and quit. You're loading an entire programming language, putting 20 bytes into it,...
2,040
Posted By birei
Hi, My changes. Test it: $ cat...
Hi,

My changes. Test it:

$ cat origamisven.sh
#!/bin/bash

count=1
while read line
do
if (($count > 3)); then
num_line=$((++num_line))
echo "$line" | awk -v...
3,248
Posted By yazu
s (undefined by default or equal "") concatenated...
s (undefined by default or equal "") concatenated with the current line
and newline char. Then getline reads the next line from input and makes it
the current line ($0). This lasts until we have...
3,248
Posted By yazu
% VAR=SOL; awk '/'$VAR'/ { while (match($0,...
% VAR=SOL; awk '/'$VAR'/ { while (match($0, "'$VAR'"))
{ s = s $0 "\n"; getline } printf s; exit}' testfile | wc -l
3
3,248
Posted By panyam
so the output you are expecting is ABC ->...
so the output you are expecting is

ABC -> 3 times,

SOL -> 3 times ?

In straight way , count only the first occurance of SOL ( keeping in mind column1 should be unique)
4,034
Posted By vgersh99
nawk 'FNR==NR {if($1<3) f1[$3];next} !($5 in f1)'...
nawk 'FNR==NR {if($1<3) f1[$3];next} !($5 in f1)' file1 file2
14,937
Posted By gary_w
For the sake of argument...
You could change:
mCurr=${mCurr}+1to:
((mCurr+=1))to have the korn shell perform integer math inline and speed things up even more. It's actually quite surprising the difference it makes. ...
14,937
Posted By Shell_Life
See if this will improve your script: ...
See if this will improve your script:
#!/usr/bin/ksh
typeset -i mPrev=7777
typeset -i mCurr=-1
while read mFld1 mFld2 mFld3 mFld4 mFld5 mOther
do
if [[ ${mFld5} -ne ${mPrev} ]]; then
...
14,937
Posted By Corona688
It's not the read that's slow, it's "echo stuff |...
It's not the read that's slow, it's "echo stuff | awk". You do that twice, so for a file with a million lines, you're running two million separate instances of awk! awk is a full-fledged language...
1,991
Posted By zaxxon
Nietzsche said that about god, not sed! :D ...
Nietzsche said that about god, not sed! :D

The variable is enclose by singe quotes so it will never be evaluated by the shell and sowith sed will never find a match - so no change to the file:
...
Showing results 1 to 24 of 24

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