The UNIX and Linux Forums  

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




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 01-03-2009
mustaine85 mustaine85 is offline
Registered User
  
 

Join Date: Dec 2008
Posts: 5
Using variables within awk/sed commands

Can I use my own variables within awk and sed for example:
I've written a while loop with a counter $i and I want to use the value of $i within sed and awk to edit certain lines of text within a data file.

I want to use :
sed '1s/$/texthere/g' data.csv
Like this:
sed '$is/$/$age/g' data.csv
but it only displays the name of the variable not the value it contains.

$age is the result of a calculation created within the while loop that I would like to append to the end of each line.
Any help is greatly appreciated