Search Results

Search: Posts Made By: agama
32,689
Posted By agama
Use double bracket, and no quotes round wild...
Use double bracket, and no quotes round wild cards. The double brackets are interpreted by Bash (or Kshell if using ksh) and they both interpret the right hand side of the expression as a pattern:
...
3,141
Posted By agama
Don't confuse the shell variable expansion...
Don't confuse the shell variable expansion substitution syntax with regular expressions because they are (just as confusing at first) and quite different.

For the full list of possibilities have...
1,570
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...
360,717
Posted By agama
You are wise to use xargs as it's much more...
You are wise to use xargs as it's much more efficient. The "splat" (*) on your command line is expanding to all files in the directory. What you want is to search in your current directory:


find...
14,247
Posted By agama
The convert utility which is a part of...
The convert utility which is a part of imagemagick will do what you need. Basic command line is:


convert +append image1.jpg image2.jpg product.jpg


The two images are placed side by side;...
3,795
Posted By agama
I'm not familiar with the 'mtr' command, but I'll...
I'm not familiar with the 'mtr' command, but I'll guess that its sending out pings and presenting a summary that includes packet loss. Your getting tripped up because you are parsing the whole log...
12,850
Posted By agama
If you are using Kshell or bash, I'd suggest...
If you are using Kshell or bash, I'd suggest something like this:


ls | while read f
do
mv $f ${f#*__}
done


The ${f#*__} removes everything from the start of the filename through the...
16,394
Posted By agama
No, it will find the whole string apply_server=1;...
No, it will find the whole string apply_server=1; If you need it to find just the value after the equal, use this:


split( substr( $0, RSTART, RLENGTH ), a, "="); # split the token at the =...
16,394
Posted By agama
Sorry, misinterpreted your need. Maybe this...
Sorry, misinterpreted your need. Maybe this sample will give you what you need:


awk '
{
if( match( $0, "apply_server=.*[ \t]" ) ) # search the input line for the...
16,394
Posted By agama
Using the syntax $(i) will allow you to access a...
Using the syntax $(i) will allow you to access a column using the contents of a variable, in this case 'i'.


#!/usr/bin/env ksh
awk -v col=${1:-1} ' {print $(col)}'


This example accepts a...
6,145
Posted By agama
Have a go with this: #!/usr/bin/env ksh ...
Have a go with this:


#!/usr/bin/env ksh

awk -v date=${1:-nodate} '
/BEGIN:VEVENT/ { cache = 1; }

/LAST-MODIFIED:/ {
if( index( $0, date ) )
drop = 1;
...
1,759
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,029
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,029
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 );

...
11,451
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="[<>]"

...
1,965
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....
3,057
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
...
6,123
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,057
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,057
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,514
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,620
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.
2,936
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,154
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,375
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...
Showing results 1 to 25 of 473

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