Search Results

Search: Posts Made By: vinus
1,500
Posted By Corona688
Using my yanx.awk library...
Using my yanx.awk library (https://www.unix.com/tips-and-tutorials/266171-general-purpose-xml-processing.html) I can substitute into appropriate tag names:

$ cat template.sh
#!/bin/bash

if [ -z...
1,500
Posted By RudiC
Not too sophisticated, but may pass for a zeroth...
Not too sophisticated, but may pass for a zeroth approach:
awk '
NR==FNR {T[NR] = $0
MX = NR
next
}

{X = T[2]
...
1,273
Posted By RudiC
I've got this for you, but it doesn't yield the...
I've got this for you, but it doesn't yield the correct seconds nor decimals:awk -vTS=-10 -vTA=+15 '
function GTM(T,D) {cmd = "date +\"%d/%m/%Y %H:%M:%S.000\" -d\"" T D "min\""
...
2,678
Posted By Scrutinizer
You are welcome.. One more note: grep...
You are welcome..

One more note: grep "[\*]*.Message Completed*" should be:
grep " Message Completed "
or
grep " .*Message Completed.* "
Depending on what you need to test:


grep...
2,678
Posted By MadeInGermany
The | awk '{print $0}' has no effect. You can...
The | awk '{print $0}' has no effect. You can omit it.
2,678
Posted By Scrutinizer
You need to use double quotes around the...
You need to use double quotes around the expansion of variable LINE. Try:
tail -F file.log | while read LINE
do
echo "$LINE" | awk '{print $0}' | grep "[\*]*.Message Completed*" >>$TestFile...
1,172
Posted By RudiC
Did you consider doing ALL (or most, at least) of...
Did you consider doing ALL (or most, at least) of above in one go?
1,172
Posted By Don Cragun
Just out of curiosity, why use kill $ID instead...
Just out of curiosity, why use kill $ID instead of exit?

Is the problem that you think the script is killing itself too soon? Note that you seem to be using the same log file on every run...
9,038
Posted By RudiC
It's a bit difficult to remove chars from a line...
It's a bit difficult to remove chars from a line already printed, so I'd propose to do the whole thing in one single line. Would this do?
awk -F, -v SQ="'" '
FNR == NR {if (!/^#/) C[NR] = $0...
9,038
Posted By RudiC
How aboutawk -F, -v SQ="'" ' FNR == NR ...
How aboutawk -F, -v SQ="'" '
FNR == NR {if (!/^#/) C[NR] = $0
next
}
{print "UPDATE EMP SET "
for (c in C) print "\t" C[c]...
1,196
Posted By Scrutinizer
Ok, adjusted to any field: awk '{for(i=1;...
Ok, adjusted to any field:
awk '{for(i=1; i<=NF; i++) if($i~/^F509=/){split($i,F,/=/); if(n=="")n=F[2]; $i=F[1]"="n++}}1' FS=^ OFS=^ file

---

This will fail if there is a line that happens to...
1,196
Posted By RudiC
Try awk 'match ($0, /\^F509[^^]*/) && !L {L=1;...
Try awk 'match ($0, /\^F509[^^]*/) && !L {L=1; m=n=substr ($0, RSTART+6, RLENGTH-6)} {sub (m, n++)}1' /tmp/inputfile.txt
DATAk(jdkfjk)09335"mk"8789eetet8766^F509=204657^F321=khfjfd^F870=76547854...
1,156
Posted By Don Cragun
Unless I'm missing something, the code: FNR==NR...
Unless I'm missing something, the code:
FNR==NR {TMP=$0; next}
in the above needs to be changed to:
NR == 1 {TMP=$0; next}
to keep from overwriting the template read from inputfile1.txt with the...
1,156
Posted By RudiC
Try alsoawk 'FNR==NR {TMP=$0; next} {sub...
Try alsoawk 'FNR==NR {TMP=$0; next} {sub (/\^A107=[^^]*\^A/, "^A107=" $0 "^A", TMP); print TMP}' /tmp/inputfile1.txt /tmp/inputfile2.txt
If your files contain DOS line terminators, add a sub...
2,844
Posted By MadeInGermany
Most awk versions treat "04" as a string rather...
Most awk versions treat "04" as a string rather than a number!
This seems to fix it:
startd=substr(s[n],2); endd=substr(s[n+1],2)+0By adding a zero, endd changes from 04 to 4, and the d<=endd...
2,844
Posted By RudiC
After having removed ALL the <CR>s from both...
After having removed ALL the <CR>s from both files, this seemed to work:. /tmp/propertyfile.txt
while read KW
do eval echo "$KW${TMINRECORD:0:1}{${TMINRECORD:1}..${TMAXRECORD:1}}...
2,844
Posted By MadeInGermany
You can abbreviate that: TMINRECORD=`sed -n...
You can abbreviate that:
TMINRECORD=`sed -n "s/TMINRECORD=//p" $PROPERTY_FILE`
...
If you trust the file, you can even do
eval `cat $PROPERTY_FILE`
because it is in shell syntax.
2,336
Posted By Scrutinizer
There is also the sed / regex route: sed...
There is also the sed / regex route:
sed 's/-[0-9]\{14\}\( *[0-9]\{1,\} *\)$/000000000000000\1/' file

==> Note that the file is still in DOS format, which means there is a CR character before the...
2,336
Posted By SriniShoo
awk '{f1=substr($0,0,97); f2=substr($0,98,15);...
awk '{f1=substr($0,0,97); f2=substr($0,98,15); f3=substr($0,113); f2 = (f2 ~ /-/) ? "000000000000000" : f2; print f1 f2 f3}' InputFile
2,336
Posted By Corona688
You are one infraction away from being set...
You are one infraction away from being set read-only. Please start using code tags.

awk doesn't work like that, it's for delimited files, not fixed-width ones. You can assign text to column...
1,274
Posted By Corona688
awk -F"." -v OFS="." '($11 ~ /-/) { $11="0000000"...
awk -F"." -v OFS="." '($11 ~ /-/) { $11="0000000" } 1' infile > outfile
1,982
Posted By Don Cragun
This seems to do what you want: awk ' ...
This seems to do what you want:
awk '
{ if((rec_type = substr($0,134,1)) == "X") {
# Increment count of X records for this key.
xc[substr($0,2,13),substr($0,114,14),substr($0,136,16)]++
}...
2,168
Posted By Don Cragun
Good idea, but this still only prints 2 decimal...
Good idea, but this still only prints 2 decimal places in the field 5 output. Perhaps one more tweak (fixing the number of decimal places printed for field and reducing the number of divisions from...
2,168
Posted By Chubler_XL
Perhaps fields 2 and 3 should also be summed...
Perhaps fields 2 and 3 should also be summed rather than assuming they are all 0.00 and 1.00 respectively:

awk '
{
t2[$1] += $2
t3[$1] += $3
t4[$1] += $4 / 100;
t5[$1] += $5 /...
1,478
Posted By vgersh99
this should be a bit prettier: #!/bin/awk -f...
this should be a bit prettier:

#!/bin/awk -f
BEGIN {
FS=OFS=","
sc="8,9,10"
sn=split(sc,scA,FS)
}
{
w6=length($6)
idx=($1 SUBSEP $5)
block[idx]=(idx in block)?block[idx] ORS...
Showing results 1 to 25 of 25

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