The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
X trouble izua UNIX for Dummies Questions & Answers 0 01-03-2007 06:19 PM
Trouble with tr Mike@Work SUN Solaris 8 08-10-2006 03:04 PM
The trouble about SU ... nulnul7 UNIX for Dummies Questions & Answers 4 10-05-2005 11:39 AM
The trouble with... zazzybob What's on Your Mind? 6 01-18-2005 06:01 AM
trouble awk UNIX Desktop for Dummies Questions & Answers 1 11-22-2002 10:51 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 01-17-2008
RichieFondel RichieFondel is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 7
Trouble with awk

This is probably a fairly simple question but I cant seem to get it to work.

Im trying to multiply an entire column in a file by a variable in my bash script but just cant seem to get it to work with awk.

Here is what I'm trying

$varr is some value
$line is my file


awk '{print $1,$2*$varr}' $varr "$line"

It seems to print the $2*$varr 'th column instead of multiplying the $2 column by $varr


I've also tried such things as awk -v $varr the the rest of the stuff above, nothing seems to work.?
  #2 (permalink)  
Old 01-17-2008
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,119
Code:
awk '{print $1,$2*varr}' varr="$varr" "$line"
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 08:54 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0