Search Results

Search: Posts Made By: hayreter
1,075
Posted By Scrutinizer
And the inevitable: awk ' $1!=p { ...
And the inevitable:
awk '
$1!=p {
if(NR>1 && m) printf "%s", s
s=x; p=$1; m=1
}
{
if($2==23) m=0
s=s $0 ORS
}
END {
if(m)printf "%s", s
}
' FS=, OFS=,...
1,075
Posted By vgersh99
or alternatively: awk -F, 'FNR==NR{if...
or alternatively:

awk -F, 'FNR==NR{if ($2==23) no[$1]; next} !($1 in no)' myfile myfile
1,075
Posted By RudiC
I didn't consider too many possible scenarios...
I didn't consider too many possible scenarios beyond the sample you gave above; tryawk '$1 != L {if (!D) for (i=1; i<=CNT; i++) print O[i]; delete O; CNT=D=0}
...
1,342
Posted By RavinderSingh13
Hello hayreter, Following may help you in...
Hello hayreter,

Following may help you in same.


awk '/<\/event>/ {print $0;next} /\<event\>/ {print $0;A++;next} !/^$/{print A OFS $0}' Input_file


Output will be as follows.
...
2,468
Posted By RudiC
Trysed -i "s/^set xx .*/set xx $xx/" filePls note...
Trysed -i "s/^set xx .*/set xx $xx/" filePls note that the -i option is controversially discussed in this forum.
2,825
Posted By drl
Hi. OK, I think I understand. Usually...
Hi.

OK, I think I understand. Usually scripts that manipulate and do some parameter processing are called wrappers, which is what the last script do-all-files was.

I'll work on the new...
3,622
Posted By drl
Hi. An 8-line Fortran program into which you...
Hi.

An 8-line Fortran program into which you can pipe the data to do the formatting is illustrated here, along with a driver script:
#!/usr/bin/env bash

# @(#) s1 Demonstrate Fortran...
3,622
Posted By Scrutinizer
Try putting it in function, for example: awk...
Try putting it in function, for example:

awk '
function pre( fmt, nr, ofmt, N) {
split(sprintf(fmt, nr),N,/E/) # Convert input number to scientific format and split it...
3,622
Posted By Scrutinizer
Another brew: awk '{ ...
Another brew:
awk '{
split(sprintf(fmt,$1),N,/E/) # Convert input number to scientific format and split it into array N, using "E" as field separator
ofmt=fmt ...
2,482
Posted By elixir_sinari
Try this (with assumptions about your data): ...
Try this (with assumptions about your data):
awk '/^[ \t]*<data>/{data=1;countrow=0;rec[countrow++]=$0;next}
/^[ \t]*<\/data>/{
if(output) {
print rec[0]
n=split(rec[foundat],pattline)
...
2,482
Posted By Yoda
OK fixed it. But I don't know why it didn't work...
OK fixed it. But I don't know why it didn't work in the previous code!
awk ' /<data>/ {
f = 1;
print $0
next;
} /<\/data>/ && s {
f = 0;
m = 0;
...
1,631
Posted By Yoda
ag="\"a\",\"b\",\"c\",\"d\",\"e\",\"f\",\"g\"", ...
ag="\"a\",\"b\",\"c\",\"d\",\"e\",\"f\",\"g\"",
hn="\"h\",\"i\",\"j\",\"k\",\"l\",\"m\",\"n\"",
ou="\"o\",\"p\",\"q\",\"r\",\"s\",\"t\",\"u\"",
vz="\"v\",\"w\",\"x\",\"y\",\"z\""
sed...
3,388
Posted By Chubler_XL
You can make awk readable too: awk -F, ' ...
You can make awk readable too:

awk -F, '
$2 == 6{
split($0,a,",")
getline
if ($2 == -6) {
print sqrt( \
((a[8] +$8 )^2) + \
((a[9] +$9 )^2) + \
...
3,388
Posted By Yoda
Here is the explanation of what the awk program...
Here is the explanation of what the awk program is doing:
awk -F, ' NR>1 && $1=="a" { # If current record no > 1 (for skipping header) and 1st field ==...
3,388
Posted By Don Cragun
It looks like there might be a typo in the above...
It looks like there might be a typo in the above command:
Try making the change shown in red below:
awk -F, 'NR>1&&$1=="a"{f=1;split($0,a,",");}f==1&&$1=="b"{ print...
3,388
Posted By Yoda
awk -F,...
awk -F, 'NR>1&&$1=="a"{f=1;split($0,A,",");}f==1&&$1=="b"{ print sqrt(((a[4]+$4)^2)+((a[5]+$5)^2)+((a[6]+$6)^2)+((a[7]+$7)^2));f=0;}' filename
7,109
Posted By Yoda
Try this: awk -F, ' { ...
Try this:
awk -F, ' {
for(i=1;i<=NF;i++) {
if($i~/E\+/)
$i=sprintf("%.8f",$i);
if($i=="0.00000000")
$i=0;...
1,839
Posted By Yoda
awk...
awk '/<data>/{f=1}/<\/data>/{f=0}f==1&&!/data/{printf "<data>\n%s\n</data>\n",$0;}' xml_filename
OR
awk '/<data>/{f=1;next;}/<\/data>/{f=0;next;}f==1{printf "<data>\n%s\n</data>\n",$0;}'...
Showing results 1 to 18 of 18

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