Computing.Net > Forums > Solaris > Printing with AWK Utility

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Printing with AWK Utility

Reply to Message Icon

Name: camin
Date: May 4, 2004 at 14:10:23 Pacific
OS: SunOS 5.6 Generic_105181
CPU/Ram: sun4u sparc SUNW,Ultra-60
Comment:

Hi,

I am trying to use the printf with awk to send some data to print.

Here is the statement in my script:

echo "$i $state $q_date $project $title" | awk '{ printf "%-11s%-2s%-7s%-17s%-60s\n", $1, $2, $3, $4, $5 }' >>$tempdir/$Manager.msg

The problem is that I am trying align the fields - which is OK up to $4, but because the variable $title is several words so the utility only sees the first word in $title and prints it. I tried everything like \"$title\" '$title' ${title} nothing works...
can someone help! Please!! My script is overdue.



Sponsored Link
Ads by Google

Response Number 1
Name: Danny Larouche
Date: May 6, 2004 at 12:03:15 Pacific
Reply:

You can use different field separator instead of the default one. Also you can do something like:

Set A=`"$i $state $q_date $project" | awk '{ printf "%-11s%-2s%-7s%-17s%-60s\n", $1, $2, $3, $4}'`
echo $A $title >>$tempdir/$Manager.msg


Danny


0

Response Number 2
Name: camin
Date: May 7, 2004 at 14:42:35 Pacific
Reply:

Thanks Danny, I will try that.

camin


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Solaris Forum Home


Sponsored links

Ads by Google


Results for: Printing with AWK Utility

HELP!!!! Network Printing www.computing.net/answers/solaris/help-network-printing/2618.html

Solaris on disk with oter OS www.computing.net/answers/solaris/solaris-on-disk-with-oter-os/2807.html

Buffer problem executing script www.computing.net/answers/solaris/buffer-problem-executing-script/4838.html