For Programmers: Free Programming Magazines  


Home > Archive > AWK > October 2006 > Simple awk print









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Simple awk print
Uniman

2006-10-12, 6:57 pm

I'm running crazy on a awk problem. The code looks like:

#!/bin/sh
echo "STR: $STR"
CERTSOURCE=`echo $STR | awk '/.++/{print $1}'`
PATTERN=`echo $P | awk '/.++/{printf("%s", $2)}'`
FORMAT=`echo $STR | awk '/.++/{print $3}'`
if [ -d $CERTSOURCE ]; then
echo "--> $CERTSOURCE $PATTERN $FORMAT"
fi

The result will be
STR: /some_directory *.p12 PKCS12 pwd
--> /some_directory *.p12 PKCS12

However, if the current directory contains a p12 file, i.e. alice.p12,
the result will be:
STR: /some_directory *.p12 PKCS12 pwd
--> /some_directory alice.p12 PKCS12
Observe that current directory is another directory than
/some_directory in my example.

Why is the current directory files searched for? What I really want is
to go through every p12 file in some_directory instead. The string STR
is read from a file with the format:
some_directory pattern file_coding <pwd>

Thanks

Ed Morton

2006-10-12, 6:57 pm

Uniman wrote:
> I'm running crazy on a awk problem.


It's not an awk problem, it's a shell problem. Followups set to
comp.unix.shell.

Ed.

The code looks like:
>
> #!/bin/sh
> echo "STR: $STR"
> CERTSOURCE=`echo $STR | awk '/.++/{print $1}'`
> PATTERN=`echo $P | awk '/.++/{printf("%s", $2)}'`
> FORMAT=`echo $STR | awk '/.++/{print $3}'`
> if [ -d $CERTSOURCE ]; then
> echo "--> $CERTSOURCE $PATTERN $FORMAT"
> fi
>
> The result will be
> STR: /some_directory *.p12 PKCS12 pwd
> --> /some_directory *.p12 PKCS12
>
> However, if the current directory contains a p12 file, i.e. alice.p12,
> the result will be:
> STR: /some_directory *.p12 PKCS12 pwd
> --> /some_directory alice.p12 PKCS12
> Observe that current directory is another directory than
> /some_directory in my example.
>
> Why is the current directory files searched for? What I really want is
> to go through every p12 file in some_directory instead. The string STR
> is read from a file with the format:
> some_directory pattern file_coding <pwd>
>
> Thanks
>

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com