Sponsored Content
Full Discussion: Chemist Needs Help
Top Forums UNIX for Dummies Questions & Answers Chemist Needs Help Post 302251622 by jim mcnamara on Monday 27th of October 2008 02:15:38 PM
Old 10-27-2008
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

# 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

sample run:
Quote:
csadev:/home/jmcnama> chmod +x chem.awk
csadev:/home/jmcnama> chem.awk Ar_b3lyp.in Cl_b3lyp.out ArCl_b3lyp.out testoutfile

parameters
Ar_b3lyp.in
Cl_b3lyp.out
ArCl_b3lyp.out
testoutfile
lines in outputfile: 105 testoutfile created
contents of testoutfile:
Code:
comment
x y x
101
4 7
1.5 -987.240232155 -527.566333244 -460.316564467
1.6 -987.378613978 -527.566333244 -460.316564467
1.7 -987.487844944 -527.566333244 -460.316564467
1.8 -987.576209346 -527.566333244 -460.316564467
1.9 -987.648115849 -527.566333244 -460.316564467
2.0 -987.705862095 -527.566333244 -460.316564467
2.1 -987.751166930 -527.566333244 -460.316564467
2.2 -987.785959917 -527.566333244 -460.316564467
2.3 -987.812247576 -527.566333244 -460.316564467
2.4 -987.831921303 -527.566333244 -460.316564467
2.5 -987.846536754 -527.566333244 -460.316564467
2.6 -987.857308288 -527.566333244 -460.316564467
2.7 -987.865185276 -527.566333244 -460.316564467
2.8 -987.870904590 -527.566333244 -460.316564467
2.9 -987.875028391 -527.566333244 -460.316564467
3.0 -987.877975343 -527.566333244 -460.316564467
3.1 -987.880062544 -527.566333244 -460.316564467
3.2 -987.881523538 -527.566333244 -460.316564467
3.3 -987.882526772 -527.566333244 -460.316564467
3.4 -987.883205057 -527.566333244 -460.316564467
3.5 -987.883655405 -527.566333244 -460.316564467
3.6 -987.883934862 -527.566333244 -460.316564467
3.7 -987.884085930 -527.566333244 -460.316564467
3.8 -987.884156857 -527.566333244 -460.316564467
3.9 -987.884181120 -527.566333244 -460.316564467
4.0 -987.884165804 -527.566333244 -460.316564467
4.1 -987.884118398 -527.566333244 -460.316564467
4.2 -987.884055803 -527.566333244 -460.316564467
4.3 -987.883991158 -527.566333244 -460.316564467
4.4 -987.883924918 -527.566333244 -460.316564467
4.5 -987.883855232 -527.566333244 -460.316564467
4.6 -987.883784527 -527.566333244 -460.316564467
4.7 -987.883718868 -527.566333244 -460.316564467
4.8 -987.883658530 -527.566333244 -460.316564467
4.9 -987.883601613 -527.566333244 -460.316564467
5.0 -987.883548439 -527.566333244 -460.316564467
5.1 -987.883499264 -527.566333244 -460.316564467
5.2 -987.883455190 -527.566333244 -460.316564467
5.3 -987.883415341 -527.566333244 -460.316564467
5.4 -987.883378082 -527.566333244 -460.316564467
5.5 -987.883343308 -527.566333244 -460.316564467
5.6 -987.883311536 -527.566333244 -460.316564467
5.7 -987.883283425 -527.566333244 -460.316564467
5.8 -987.883258813 -527.566333244 -460.316564467
5.9 -987.883235960 -527.566333244 -460.316564467
6.0 -987.883213988 -527.566333244 -460.316564467
6.1 -987.883193153 -527.566333244 -460.316564467
6.2 -987.883173892 -527.566333244 -460.316564467
6.3 -987.883156467 -527.566333244 -460.316564467
6.4 -987.883141143 -527.566333244 -460.316564467
6.5 -987.883127703 -527.566333244 -460.316564467
6.6 -987.883115029 -527.566333244 -460.316564467
6.7 -987.883102516 -527.566333244 -460.316564467
6.8 -987.883090229 -527.566333244 -460.316564467
6.9 -987.883078556 -527.566333244 -460.316564467
7.0 -987.883067832 -527.566333244 -460.316564467
7.1 -987.883058250 -527.566333244 -460.316564467
7.2 -987.883049895 -527.566333244 -460.316564467
7.3 -987.883042444 -527.566333244 -460.316564467
7.4 -987.883035500 -527.566333244 -460.316564467
7.5 -987.883028833 -527.566333244 -460.316564467
7.6 -987.883022252 -527.566333244 -460.316564467
7.7 -987.883015730 -527.566333244 -460.316564467
7.8 -987.883009380 -527.566333244 -460.316564467
7.9 -987.883003396 -527.566333244 -460.316564467
8.0 -987.882997987 -527.566333244 -460.316564467
8.1 -987.882993214 -527.566333244 -460.316564467
8.2 -987.882988946 -527.566333244 -460.316564467
8.3 -987.882985074 -527.566333244 -460.316564467
8.4 -987.882981482 -527.566333244 -460.316564467
8.5 -987.882978055 -527.566333244 -460.316564467
8.6 -987.882974716 -527.566333244 -460.316564467
8.7 -987.882971411 -527.566333244 -460.316564467
8.8 -987.882968124 -527.566333244 -460.316564467
8.9 -987.882964890 -527.566333244 -460.316564467
9.0 -987.882961789 -527.566333244 -460.316564467
9.1 -987.882958870 -527.566333244 -460.316564467
9.2 -987.882956162 -527.566333244 -460.316564467
9.3 -987.882953681 -527.566333244 -460.316564467
9.4 -987.882951415 -527.566333244 -460.316564467
9.5 -987.882949340 -527.566333244 -460.316564467
9.6 -987.882947423 -527.566333244 -460.316564467
9.7 -987.882945624 -527.566333244 -460.316564467
9.8 -987.882943900 -527.566333244 -460.316564467
9.9 -987.882942219 -527.566333244 -460.316564467
10.0 -987.882940565 -527.566333244 -460.316564467
10.1 -987.882938937 -527.566333244 -460.316564467
10.2 -987.882937332 -527.566333244 -460.316564467
10.3 -987.882935754 -527.566333244 -460.316564467
10.4 -987.882934216 -527.566333244 -460.316564467
10.5 -987.882932741 -527.566333244 -460.316564467
10.6 -987.882931344 -527.566333244 -460.316564467
10.7 -987.882930032 -527.566333244 -460.316564467
10.8 -987.882928802 -527.566333244 -460.316564467
10.9 -987.882927649 -527.566333244 -460.316564467
11.0 -987.882926572 -527.566333244 -460.316564467
11.1 -987.882925570 -527.566333244 -460.316564467
11.2 -987.882924639 -527.566333244 -460.316564467
11.3 -987.882923771 -527.566333244 -460.316564467
11.4 -987.882922956 -527.566333244 -460.316564467
11.5 -987.882922180 -527.566333244 -460.316564467

 

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
All times are GMT -4. The time now is 05:57 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy