Sponsored Content
Full Discussion: Appending to EOF using AWK
Top Forums UNIX for Dummies Questions & Answers Appending to EOF using AWK Post 302275970 by ricksj on Monday 12th of January 2009 06:02:50 PM
Old 01-12-2009
Appending to EOF using AWK

In a previous post I needed to walk through a list of files. This works fine, but when I attempt to use the nawk line (below) I can only write to first file that's found. The files I'm trying to write to (${target_dir}${product}.html) already exist and are created by another part of my script that is working correctly.

Any idea why I can't append new information to these files?

Here's the troublesome code:
Code:
 
echo '## ' $target_dir
find $target_dir -type d -print | while read products # process all directories
do
  product=`basename $products`
  testdir=$target_dir$product
  if [ -d ${testdir} ]; then
    echo ' ## '$product
    nawk -v "PRODUCTIN=${product}" -f footer.awk >> ${target_dir}${product}.html
  fi
done

########

The footer.awk files looks like this (and the functions productdesc and print_line work correctly):
Code:
#! /bin/nawk -f
BEGIN {}
{}
 
##Print the footer info to the output file
END{
print_line("</ul>")
print_line("</div>")
print_line("<div class=\"navfooter\">")
print_line("<p>")
print_line("<em>"productdesc(PRODUCTIN,PRODNAME)"</em><br>")
print_line("<span style=\"font-size:80%\">Last updated: 4 Jan 2009<br>")
print_line("Copyright &copy; SomeCorporation<br>")
print_line("All rights reserved.</span></p>")
print_line("</body>")
print_line("</html>")
}

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to remove ^Z (eof) using sub in awk

I am looking for the substitution expression to remove the eof ^Z character at the end of a file in UNIX. Can anyone help? Thank you ! (2 Replies)
Discussion started by: placroix1
2 Replies

2. Shell Programming and Scripting

AWK scripting problem - appending values

ABC:10:A1:ABCA110 ABC:10:A1:ABCA110 ABC:20:A1:ABCA120 DEF:20:D1:DEFD120 GHI:30:G1:GHIG130 GHI:40:G1:GHIG140 JKL:30:J1:JKLJ130 MNO:10:M1:MNOM110 What I'm trying to do is look through a file that consists of four columns (as above). As you can see there are duplicates in the file, i.e.... (2 Replies)
Discussion started by: rowntree
2 Replies

3. Shell Programming and Scripting

appending with AWK

Hi all, I have two files called INPUT1 and INPUT2 and i am trying to append the values of INPUT1 to INPUT2 using AWK. The INPUT1 file will always has a single field and the INPUT2 file has 3 fields but both files will have same number of records always. Following is the format of the... (5 Replies)
Discussion started by: harris2107
5 Replies

4. Shell Programming and Scripting

appending several columns with awk and paste

Hello, I am trying to solve for a couple of hours now the following problem: I have n files and would like to add the third column of each file to a new file: temp1.txt 1 2 3 1 2 3 1 2 3 temp2.txt 1 2 4 1 2 4 1 2 4 1 2 4 temp3.txt (2 Replies)
Discussion started by: creamcheese
2 Replies

5. Shell Programming and Scripting

confused with << EOF EOF

Hi friends , I am confused with << EOF EOF Most of the cases I found sqlplus $db_conn_str << EOF some sql staments EOF another exapmle is #!/bin/sh echo -n 'what is the value? ' read value sed 's/XXX/'$value'/' <<EOF The value is XXX EOF (1 Reply)
Discussion started by: imipsita.rath
1 Replies

6. Shell Programming and Scripting

appending zeros to numbers using awk

hi i want to append zeros to a given number ( varying digits). the total length of the output should be 10 digits. For example: 1)input is var=347 output should be NewVar=0000000347 2) input is var=123456 output should be NewVar=0000123456 i am able to acheive this using typeset... (1 Reply)
Discussion started by: somi2yoga
1 Replies

7. Shell Programming and Scripting

Awk/Sed - appending within file

hello all, First time post here. I have searched a bit but could not find an exact answer. I have about a week's experience of Sed and Awk, and am having fun, but am a little stuck. I am reformatting an xml file into json format. I have got this far: {"clients": ...and so on. What I want... (22 Replies)
Discussion started by: singerfc
22 Replies

8. Shell Programming and Scripting

In awk: unexpected EOF while looking for matching `"'

I am trying to get grep with awk command into variable. But facing error. Could someone pls help. $ cat test_file DEPLOYMENT="abc" # com cluster="bcn" $ grep DEPLOYMENT test_file | awk -F "\"" '{ print $2 }' abc $ a=`echo "grep DEPLOYMENT test_file | awk -F \"\\\"\" '{ print $2 }'"` ;... (6 Replies)
Discussion started by: Manasa Pradeep
6 Replies

9. Shell Programming and Scripting

awk appending values inside a for loop

Hi i have a 2 files say test1 and test2 with the following data. cat file test test1 i want to append the output from a awk one liner to both the files. for i in cat file;do awk '/ whats happening is its printing the output properly. but not appending the way it showing in print... (1 Reply)
Discussion started by: venkitesh
1 Replies

10. Shell Programming and Scripting

Appending different columns of multiple files in awk

Hello All, I have three input files cat file1 col1|col2|col3 a|1|A b|2|B cat file2 col1|col2|col3 c|3|C cat file3 col1|col2|col3 d|4|D e|5|E i want below output file4 col1|col2 a|1 (6 Replies)
Discussion started by: looney
6 Replies
ARRAY_PRODUCT(3)							 1							  ARRAY_PRODUCT(3)

array_product - Calculate the product of values in an array

SYNOPSIS
number array_product (array $array) DESCRIPTION
array_product(3) returns the product of values in an array. PARAMETERS
o $array - The array. RETURN VALUES
Returns the product as an integer or float. CHANGELOG
+--------+---------------------------------------------------+ |Version | | | | | | | Description | | | | +--------+---------------------------------------------------+ | 5.3.6 | | | | | | | The product of an empty array is now 1, when | | | before this function would return 0 for an empty | | | array. | | | | +--------+---------------------------------------------------+ EXAMPLES
Example #1 array_product(3) examples <?php $a = array(2, 4, 6, 8); echo "product(a) = " . array_product($a) . " "; echo "product(array()) = " . array_product(array()) . " "; ?> The above example will output: product(a) = 384 product(array()) = 1 PHP Documentation Group ARRAY_PRODUCT(3)
All times are GMT -4. The time now is 02:44 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy