Search Results

Search: Posts Made By: agama
2,053
Posted By agama
Have you tried reading the data into an array...
Have you tried reading the data into an array which would allow you to avoid the substring overhead which I believe is costing you. Your original code ran in about 4 seconds for me using Bash and...
2,465
Posted By agama
ERK!! I made a change, and tested it, but...
ERK!!

I made a change, and tested it, but failed to see all zeros. Going blind I think.

I've fixed the bug by reverting to my original logic and it works now for me. THANKS!


awk '
...
2,465
Posted By agama
Assuming your data is in a file named t.data...
Assuming your data is in a file named t.data this is one way:


awk '
/>/ { split( $1, a, ">" ); sect=a[1]; next; }

/Start/ {
s = "";
printf( "%s ", sect );

...
12,638
Posted By agama
Ah, very good, thanks. Have a go with this: ...
Ah, very good, thanks.

Have a go with this:

awk '
/property name=/ {
gsub( ".*value=" Q, "" );
gsub( Q ".*", "" );
print;
}
' Q="'" RS="[<>]"

...
2,268
Posted By agama
First of all, you don't need to cat into a while,...
First of all, you don't need to cat into a while, you can redirect the file into the while:


while read stuff
do
echo $stuff
done <$ELOG


Further, the use of awk isn't needed either....
1,743
Posted By agama
If you have a modern Korn shell installed, ...
If you have a modern Korn shell installed, ${.sh.file} should contain the name of the file that was sourced.

Have a try with something like this:

#!/usr/bin/env ksh
echo "Running test2.sh...
3,631
Posted By agama
Have a go with these small changes: if ! ...
Have a go with these small changes:


if ! lpar-command | awk '
/^Name/ { next; }
/^---/ { next; }
{
state[$2] = state[$2] $1 " ";
if( $2 == "A" )
acount++;
else
...
7,198
Posted By agama
Assuming your system will allow 100 concurrent...
Assuming your system will allow 100 concurrent file descriptors to be open at the same time:


awk '
{
for( i = 3; i <= NF; i++ )
printf( "%s %s %s\n", $1, $2, $(i) ) >i...
3,631
Posted By agama
Not quite the way to get date in. From inside of...
Not quite the way to get date in. From inside of awk you cannot use backquotes like that. This is one way which should work with even older awks. I haven't used an AIX system since about 2001, and...
3,631
Posted By agama
Small changes to generate the total counts: ...
Small changes to generate the total counts:


awk '
/^Name/ { next; }
/^---/ { next; }
{
state[$2] = state[$2] $1 " ";
if( $2 == "A" )
acount++;
else
others++;...
1,725
Posted By agama
Agree with spacebar -- can be simplified. My...
Agree with spacebar -- can be simplified. My thoughts:


lswpar | awk '
/^Name/ { next; }
/^---/ { next; }
{ state[$2] = state[$2] $1 " "; }
END {
printf( "====...
Forum: Programming 10-20-2012
1,772
Posted By agama
Child is writing result on p3, but parent is...
Child is writing result on p3, but parent is reading, the already closed, p2.
4,997
Posted By agama
Use the man command to look at how to use the...
Use the man command to look at how to use the mesg command. man mesg

This should give you the information that you need to solve your problem/answer your question.
3,892
Posted By agama
If your input file is sorted such that the...
If your input file is sorted such that the records with the same first field are always together, then this should work:


awk -F \| '
$1 != last {
if( hold )
print...
1,519
Posted By agama
This should work if you are using Kshell or bash:...
This should work if you are using Kshell or bash:


awk ' {do-something}' "$@" >output-file


If you have more than the two file names on the command line, then:


awk '{do-something}' $1 $2...
1,858
Posted By agama
Your problem is this line: echo "This is...
Your problem is this line:


echo "This is : $(GREATER)"


should be

echo "this is $GREATER"


It's trying to execute GREATER.

You also don't need to use head if you are using awk:...
24,744
Posted By agama
You are right, the contents of the field, and...
You are right, the contents of the field, and field value are the same. What I was suggesting was passing the value to the function rather than using $1 inside of the function. It's not always...
24,744
Posted By agama
Another example you can tailor to your needs: ...
Another example you can tailor to your needs:


awk '
BEGIN {
xtab["1"]="a";
xtab["2"]="b";
xtab["3"]="c";
}
function xlate( w, xw, i, n, a ) #...
909
Posted By agama
It would help to know what the command syntax...
It would help to know what the command syntax that you are running to determine whether or not the file is spam, and more importantly if it indicates that it is spam via exit code, or message or some...
6,881
Posted By agama
Then this: awk -F = ' /^NAME/ { n =...
Then this:


awk -F = '
/^NAME/ { n = $2; next }
/^TARGET/ { t = $2; next; }
/^STATE/ {
if( t != $2 && !(t == "OFFLINE" && $2 == "ONLINE") )
print n;
}
'...
2,440
Posted By agama
I think this will do what you are wanting: ...
I think this will do what you are wanting:


awk '
$1 == "ID" {
if( fname )
close( fname );
fname = $2 ".txt";
}
{ print >fname; }
' input-file


...
1,827
Posted By agama
This should work for most awk versions: ...
This should work for most awk versions:


awk '{ p *= $1 } END{ print p }' p=1 input-file



For gnu awk, and other recent versions, an alternative:


awk -v p=1 '{ p *= $1 } END{ print p...
1,941
Posted By agama
This isn't maybe the best way, but it does work: ...
This isn't maybe the best way, but it does work:



sed -E 's/$/./; s/abc=123([^0-9])/abc=999\1/g; s/.$//;'

At least with your small example.


If you are using AT&T's AST sed, or a BSD...
2,191
Posted By agama
This makes some assumptions about the input (like...
This makes some assumptions about the input (like netbios= always being the last on the line), but might work:


awk -F '"' '
/share/ {
n = split( $0, a, "=" );
printf(...
1,400
Posted By agama
The input to for is a list of tokens separated by...
The input to for is a list of tokens separated by the characters defined in the internal field seperator (IFS) variable; usually space, tab and newline. For example:


for x in one two three
do...
Showing results 1 to 25 of 473

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