Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

UPPER CASE Transformation 2

Status
Not open for further replies.

christiniaroelin

Programmer
Sep 15, 2004
26
US
Hi,
iam trying to make the following transformation on the file:
print first line as it is!
from second line thru end -2 lines change from the SECOND FIELD ONWARD TOUPPER CASE (FIRST FIELD REMAINS IN LOWER CASE).
print the last two lines unmodified.
for eg:

input file:

record
string(") in1 null(" "),
decimal:)) in2 null(" "),
....
...
string ("\n")
end

expected output file:

record
string(") IN1 NULL(" "),
decimal:)) IN2 NULL(" "),
....
...
string ("\n")
end


Thank you!
 
a brute force:

nawk -v tot="$(wc -l < chris.txt)" -f chris.awk chris.txt

here's chris.awk:
Code:
NR < (tot-2) && NR != 1 {
   for(i=2;i<=NF;i++)
      $i=toupper($i);
}
1

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
HI vgersh,
I tried the code that you had sent..but it resulted in a 0byte output file.
Thanks for your time!!
roelin
 
what shell are you using?
do you have 'nawk'?

if not ksh/bash, try this:
nawk -v tot="`wc -l < chris.txt`" -f chris.awk chris.txt

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
it resulted in a 0byte output file
I hope you don't tried <file.txt >file.txt
vlad, I'd replace NR < (tot-2) by NR < (tot-1)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
good catch, PHV - thanks!

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top