$3 !~/^[A-Z]$/ { printf "Select %s %s\nAssign %s\n", $1, $2, ENVIRON["BCKDRIVE"] }
Main Topics
Browse All TopicsI have the following code in a AWK programfile
$3 !~/^[A-Z]$/ { print "Select " $1, $2 ; print "Assign " ENVIRON["BCKDRIVE"] }
What this outputs is the following:
Select Volume 0 Assign L:
What I need it to do is print in the following manner:
Select Volume
Assign L:
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Neither worked. let me explain further.
In my script I have the following:
%AWKEXE% -f awkprog3 <bckvol1.tmp >diskpart2.tmp (%AWKEXE% is just a variable for the patch of my CYGWIN installation.
The awkprog3 is the code from my original post.
The bckvol.tmp is as follows:
Volume 0 C NTFS Partition 21 GB Healthy System
Volume 1 D Data1 NTFS Partition 115 GB Healthy
Volume 2 Z DVD-ROM 0 B Healthy
Volume 3 Data NTFS Partition 400 GB Healthy
The code then outputs this to a file: (diskpart2.tmp)
Select Volume 3 Assign L:
Between the Select Volume 3 and the Assign L: there appears to be a carriage return. If I copy an paste into another file then I can see the output I want.
Select Volume 3
Assign L:
Following on from Tintin's reply, which is probably correct, you could avoid having to modify your awk script's print statements, by adding a unix2dos statement after you run the AWK program. This will correct any CRLF problems between unix and dos platforms.
%AWKEXE% -f awkprog3 <bckvol1.tmp >diskpart2.tmp
unix2dos diskpart2.tmp diskpart2.tmp
Note that you can also put the unix2dos statment into a pipe:
%AWKEXE% -f awkprog3 <bckvol1.tmp | unix2dos >diskpart2.tmp
If you don't know much about the unix2dos command - please note that you might get /dev/kbd errors reported if you are logged into a keyboardless server. You can safely ignore thes errors or send them to /dev/null:
%AWKEXE% -f awkprog3 <bckvol1.tmp | unix2dos >diskpart2.tmp 2>dev/null
Business Accounts
Answer for Membership
by: ravenplPosted on 2008-02-17 at 12:33:03ID: 20915471
$3 !~/^[A-Z]$/ { print "Select " $1; print "Assign " ENVIRON["BCKDRIVE"] }
works for me. No newline?
$3 !~/^[A-Z]$/ { print "Select " $1; print "\nAssign " ENVIRON["BCKDRIVE"] }