Sponsored Content
Full Discussion: Chemist Needs Help
Top Forums UNIX for Dummies Questions & Answers Chemist Needs Help Post 302251953 by jim mcnamara on Tuesday 28th of October 2008 12:15:20 PM
Old 10-28-2008
I think you probably have Bourne shell - lets' try this (changes in red)
Code:
#!/bin/sh
# FILE: chem.awk  requires execute permission
# usage: ./chem.awk infile infile2 infile3 outfile

# where parms are:
#   $1 = infile1  $2 = infile2   $3 = infile3  $4 = outfile
# do not forget to change "comment" to something menaingful if needed
echo "
parameters
$1
$2
$3
$4"


# start the FILE
printf "%s\n%s\n%s\n%s\n" "comment" "x y x" "101" "4 7" > ./newfile

# read in two constants
awk '/Done/ {print $5; exit}' "$1" | read col3
awk '/Done/ {print $5; exit}' "$2" | read col4
export col3
export col4

# loop thru the big input FILE writing 101 rows
awk '/Done/ {print $5}' "$3" | \
awk -v col4="$col4" -v col3="$col3" ' BEGIN { cnt =1.5 }
              {printf("%.1f %s %s %s\n", cnt, $0, col3, col4) 
              cnt+=.1 }'>> ./newfile
# rename the output FILE to what was required
mv ./newfile "$4"            
echo "lines in outputfile: $(wc -l "$4") created"
exit 0
# EOF: chem.awk

 

We Also Found This Discussion For You

1. UNIX for Dummies Questions & Answers

Chemist Needs Help part II

Hello friends, I was wondering if you can help me with probably a simple function to you all: the sample looks and has this format. I was wondering how I could extract the first and second column starting including the line 'E/N and Ko' and not stop until there are no more lines. Thank you for... (5 Replies)
Discussion started by: gingburg
5 Replies
IGAWK(1)							 Utility Commands							  IGAWK(1)

NAME
igawk - gawk with include files SYNOPSIS
igawk [ all gawk options ] -f program-file [ -- ] file ... igawk [ all gawk options ] [ -- ] program-text file ... DESCRIPTION
Igawk is a simple shell script that adds the ability to have ``include files'' to gawk(1). AWK programs for igawk are the same as for gawk, except that, in addition, you may have lines like @include getopt.awk in your program to include the file getopt.awk from either the current directory or one of the other directories in the search path. OPTIONS
See gawk(1) for a full description of the AWK language and the options that gawk supports. EXAMPLES
cat << EOF > test.awk @include getopt.awk BEGIN { while (getopt(ARGC, ARGV, "am:q") != -1) ... } EOF igawk -f test.awk SEE ALSO
gawk(1) Effective AWK Programming, Edition 1.0, published by the Free Software Foundation, 1995. AUTHOR
Arnold Robbins (arnold@skeeve.com). Free Software Foundation Nov 3 1999 IGAWK(1)
All times are GMT -4. The time now is 06:34 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy