Adding CR to ascii data file generated on AIX platform and will be transmitted to Windows OS


 
Thread Tools Search this Thread
Operating Systems AIX Adding CR to ascii data file generated on AIX platform and will be transmitted to Windows OS
# 1  
Old 08-06-2014
Adding CR to ascii data file generated on AIX platform and will be transmitted to Windows OS

I desperately need help converting ascii data file generated on AIX platform that contains dollar sign ($) at the end of each line in the data file as shown below.

Code:
ME570^0128237^HG278999^20140805:21:00:00^BEENZ001^$

This is the AWK command for adding CR to the new line.

Code:
awk '{sub("$","\r\n"); printf("%s",$0);}' inputfile > outputfile

When I execute this AWK command to add Carriage Return before the new line it works fine from the command line like shown below.

Code:
ME570^0128237^HG278999^20140805:21:00:00^BEENZ001^M$

but it add double CRs like CRCRLF in the ascii data file when is executed as korn shell script as shown below.

Code:
ME570^0128237^HG278999^20140805:21:00:00^BEENZ001^M^M$

Do you have a suggestion on how to resolve this issue. Any help is appreciated.

Thanks
Nnamdi

Moderator's Comments:
Mod Comment Please stop using COLOR, FONT, and SIZE tags when posting text. and use CODE tags when posting sample input, output, and code segments.

Last edited by Don Cragun; 08-06-2014 at 09:21 PM.. Reason: Add CODE and ICODE tags; remove FONT, COLOR, and SIZE tags.
# 2  
Old 08-06-2014
The script you used:
Code:
awk '{sub("$","\r\n"); printf("%s",$0);}' inputfile > outputfile

would produce double spaced lines (with a carriage return at the end of the 1st line of every pair. To get what you wanted, you could try:
Code:
awk '{sub("$","\r"); printf("%s",$0);}' inputfile > outputfile

or more simply:
Code:
awk '{print $0 "\r"}' inputfile > outputfile

Also see if your system provides a unix2dos utility.
This User Gave Thanks to Don Cragun For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

Samba 3.6 on AIX 7.1 - Windows 10 Access to AIX file shares using Active Directory authentication

I am running AIX 7.1 and currently we have samba 3.6.25 installed on the server. As it stands some AIX folders are shared that can be accessed by certain Windows users. The problem is that since Windows 10 the guest feature no longer works so users have to manually type in their Windows login/pwd... (14 Replies)
Discussion started by: linuxsnake
14 Replies

2. AIX

Error when running .sh file in AIX platform

Hi, I am trying to open Oracle Warehouse Builder (10g) Design Center in AIX platform using the command ./OWBClient.sh. When I execute, I am getting the below error. The JVM option is invalid: -XX: MaxPermSize=256M. Could not create the Java Virtual Machine. Any resolution guidance for the... (4 Replies)
Discussion started by: becky123
4 Replies

3. UNIX for Dummies Questions & Answers

SSH: What data is actually being transmitted?

Sorry, I couldn't think of how to word my question in the title field, let me try to explain: If I am on "computer1" on a school network, and I ssh using Terminal to a remote server A, then I perform an rsync operation between server A and server B (home server), what data is being sent to my... (3 Replies)
Discussion started by: WIOP33
3 Replies

4. Shell Programming and Scripting

Data is available or not in a flat file generated by Oracle

Hello, please help me an the below issue. i need to check whether data is available or not in a flat file generated by oracle (sometimes sql didn't any records) to overcome this. without opening flat file. Thanks....... (1 Reply)
Discussion started by: mahesh1987
1 Replies

5. Shell Programming and Scripting

Help in adding a data after a particular line of data in a file.

Hi.. I'm into a bump after trying to solve this prob.. i've a file with contents like below. <blankline> 'pgmId' : 'UNIX', 'pgmData' : 'textfile', 'author' : 'admin', ....... Now i'm trying to insert a new data after pgmId. so the final output will be... (7 Replies)
Discussion started by: arjun_arippa
7 Replies

6. UNIX for Dummies Questions & Answers

Sorting data in an ASCII file

Hi,,, is there anyway to sort the data that I have on an ASCII file, using unix? :confused::confused::confused: Thanks (2 Replies)
Discussion started by: cosmologist
2 Replies

7. Shell Programming and Scripting

Need help in sed command (adding a blank line btw each block generated by pattern)

Hello friends, I have a C source code containing sql statements. I use the following sed command to print all the sql blocks in the source code.... sed -n "/exec sql/,/;/p" Sample.cpp The above sed command will print the sql blocks based on the pattern "exec sql" & ";"... (2 Replies)
Discussion started by: frozensmilz
2 Replies

8. Shell Programming and Scripting

how to check the file data type(ascii or binary)

hi i am receiving a file from one system , i have to verify the format of the file data i.e whether the data is in acii format or binary format, please help thanks in advance satya (1 Reply)
Discussion started by: Satyak
1 Replies

9. Shell Programming and Scripting

Check whether a given file is in ASCII format and data is tab-delimited

Hi All, Please help me out with a script which checks whether a given file say abc.txt is in ASCII format and data is tab-delimited. If the condition doesn't satisfy then it should generate error code "100" for file not in ASCII format and "105" if it is not in tab-delimited format. If the... (9 Replies)
Discussion started by: Mandab
9 Replies

10. Programming

Core File Not Being Generated in AIX

I have created an executable using my login session in an AIX Version 5 Unix system. After to which I have change the file mode to set uid and rwsrwx--x and ownership to root:system by using the following Standard C Library functions. chmod (name, S_ISUID|S_IRWXU|S_IRWXG|S_IXOTH|S_IROTH) chown... (6 Replies)
Discussion started by: S.P.Prasad
6 Replies
Login or Register to Ask a Question