Sponsored Content
Operating Systems AIX Pattern to replace ^M and ^Y in a 4.2 AIX text file Post 302316785 by Browser_ice on Saturday 16th of May 2009 03:14:41 PM
Old 05-16-2009
Question Pattern to replace ^M and ^Y in a 4.2 AIX text file

I have files on my AIX 4.2 client system where I need to do the following replacements below but have no clue how ? They are control characters (linefeed, chariage return, ...).


First, replace "^M^Y^M" with ^char_for_end_of_line
Then replace "^M" with " "
Trim all left spaces

In VI, my files contents look like this :

aaaa zzzzzzzzzzzzzzzzzzzzzz^M
zzzzzzzzzzzzzzzzzzzzzz^M
zzzzzzzzzzzzzzzzzzzz^M
^M
^Y^M
aaaa zzzzzzzzzzzzzzzzzzzzzz^M
zzzzzzzzzzzzzzzzzzzzzz^M
zzzzzzzzzzzzzzzzzzzz^M
^M
^Y^M
aaaa zzzzzzzzzzzzzzzzzzzzzz^M
zzzzzzzzzzzzzzzzzzzzzz^M
zzzzzzzzzzzzzzzzzzzz^M
^M
^Y^M
...

I want it to be:
aaaa zzzzzzzzzzzzzzzzzzzzzz zzzzzzzzzzzzzzzzzzzzzz zzzzzzzzzzzzzzzzzzzzzz
aaaa zzzzzzzzzzzzzzzzzzzzzz zzzzzzzzzzzzzzzzzzzzzz zzzzzzzzzzzzzzzzzzzzzz
aaaa zzzzzzzzzzzzzzzzzzzzzz zzzzzzzzzzzzzzzzzzzzzz zzzzzzzzzzzzzzzzzzzzzz
aaaa zzzzzzzzzzzzzzzzzzzzzz zzzzzzzzzzzzzzzzzzzzzz zzzzzzzzzzzzzzzzzzzzzz
aaaa zzzzzzzzzzzzzzzzzzzzzz zzzzzzzzzzzzzzzzzzzzzz zzzzzzzzzzzzzzzzzzzzzz
...

Nb of records is unknown.
'zzzzzz' can have any combinations of "(", ")", "'", """, ",", "[", "]", ".", ";" (in other words anything with printable characters)
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

pattern replace inside text file using sed

Hi, I have a situation where I want to replace some occurrences of ".jsp" into ".html" inside a text file. For Example: If a pattern found like <a href="http://www.mysite.com/mypage.jsp"> it should be retained. But if a pattern found like <a href="../mypage.jsp"> it should be changed to... (4 Replies)
Discussion started by: meharo
4 Replies

2. Shell Programming and Scripting

Replace Text Based On Pattern

Hi I'm trying to replace text in a file based upon a pattern. The pattern I'm looking for is: <styleURL>#style0002</styleURL> <name>#######6105#######</name>The # are seven alphanumeric characters before and after 6105. I need it to replace that with this recursively: ... (4 Replies)
Discussion started by: Grizzly
4 Replies

3. Shell Programming and Scripting

Create multiple text file from a single text file on AIX

Hi I need to create multiple text files from onc text file on AIX. The data of text files is as below: ********************************************** ********************************************** DBVERIFY: Release 10.2.0.4.0 - Production on Tue Nov 10 13:45:42 2009 Copyright (c) 1982,... (11 Replies)
Discussion started by: lodhi1978
11 Replies

4. Shell Programming and Scripting

find pattern and replace the text before it

i am editing a big log file with the following pattern: Date: xxxx Updated: name Some log file text here Date: eee Updated: ny Some log file text here Basically i want to remove all the text in a line before the "Updated" pattern. I sill want to print the other... (4 Replies)
Discussion started by: balan1983a
4 Replies

5. Shell Programming and Scripting

Sed command to replace with pattern except for text and closing parentheses

Can someone help me with a sed command: There will be multiple occurences in a file that look like this: MyFunction(12c34r5) and I need to replace that with just the 12c34r5 for every occurrence. The text between the parentheses will be different on each occurrence, so I can't search for that.... (4 Replies)
Discussion started by: missb
4 Replies

6. Shell Programming and Scripting

sed help, Find a pattern, replace it with same text minus leading 0

HI Folks, I'm looking for a solution for this issue. I want to find the Pattern 0/ and replace it with /. I'm just removing the leading zero. I can find the Pattern but it always puts literal value as a replacement. What am I missing?? sed -e s/0\//\//g File1 > File2 edit by... (3 Replies)
Discussion started by: SirHenry1
3 Replies

7. Shell Programming and Scripting

Search and Replace a text if the line contains a pattern

My text file looks like below . . . abcdefghi jklmnop $Bad_ptrq_GTS=rcrd_ip.txt $Bad_abcd_REJ=rcrd_op.txt ghijklm $Bad_abcd_TYHS=rcrd_op.txt abcgd abcdefghi jklmnop $Bad_ptrq_GTS=rcrd_ip.txt (2 Replies)
Discussion started by: machomaddy
2 Replies

8. Shell Programming and Scripting

Pattern replace from a text file using sed

I have a sample text format as given below <Text Text_ID="10155645315851111_10155645333076543" From="460350337461111" Created="2011-03-16T17:05:37+0000" use_count="123">This is the first text</Text> <Text Text_ID="10155645315851111_10155645317023456" From="1626711840902323"... (3 Replies)
Discussion started by: my_Perl
3 Replies

9. Shell Programming and Scripting

Grab text after pattern and replace

i have a file which contains data seperated by comma. i want to replace text after 3rd occurrence of a comma. the input file looks like this abcdef,11/02/2015 11:55:47,1001,1234567812345678,12364,,abc abcdefg,11/02/2015 11:55:47,01,1234567812345678,123,,abc abcdefhih,11/02/2015... (4 Replies)
Discussion started by: gpk_newbie
4 Replies

10. UNIX for Beginners Questions & Answers

Replace pattern in text

hi unix expert is there any command in linux to repace a pattern in the text to another pattern? many thanks samad (2 Replies)
Discussion started by: abdossamad2003
2 Replies
srec_signetics(5)						File Formats Manual						 srec_signetics(5)

NAME
srec_signetics - Signetics file format DESCRIPTION
The Signetics file format is not often used. The major disadvantage in modern applications is that the addressing range is limited to only 64kb. Records All data lines are called records, and each record contains the following 5 fields: +--+------+----+----+----+----+ |: | aaaa | cc | as | dd | ss | The field are defined as follows: +--+------+----+----+----+----+ : Every record starts with this identifier. aaaa The address field. A four digit (2 byte) number representing the first address to be used by this record. cc The byte-count. A two digit value (1 byte), counting the actual data bytes in the record. as Address checksum. Covers 2 address bytes and the byte count. dd The actual data of this record. There can be 1 to 255 data bytes per record (see cc) ss Data Checksum. Covers only all the data bytes of this record. Record Begin Every record begins with a colon ":[rq] character. Records contain only ASCII characters. No spaces or tabs are allowed in a record. In fact, apart from the 1st colon, no other characters than 0..9 and A..F are allowed in a record. Interpretation of a record should be case less, it does not matter if you use a..f or A..F. Unfortunately the colon was chosen for the Signetics file format, similar to the Intel format (see srec_intel(5) for more information). However, SRecord is able to automatically detect the dofference between the two format, when you use the -Guess format specifier. Address Field This is the address where the first data byte of the record should be stored. After storing that data byte, the address is incremented by 1 to point to the address for the next data byte of the record. And so on, until all data bytes are stored. The address is represented by a 4 digit hex number (2 bytes), with the MSD first. The order of addresses in the records of a file is not important. The file may also contain address gaps, to skip a portion of unused memory. Byte Count The byte count cc counts the actual data bytes in the current record. Usually records have 32 data bytes, but any number between 1 and 255 is possible. A value of 0x00 for cc indicates the end of the file. In this case not even the address checksum will follow! The record (and file) are terminated immediately. It is not recommended to send too many data bytes in a record for that may increase the transmission time in case of errors. Also avoid sending only a few data bytes per record, because the address overhead will be too heavy in comparison to the payload. Address Checksum This is not really a checksum anymore, it looks more like a CRC. The checksum can not only detect errors in the values of the bytes, but also bytes out of order can be detected. The checksum is calculated by this algorithm: checksum = 0 for i = 1 to 3 checksum = checkum XOR byte ROL checksum next i For the Address Checksum we only need 2 Address bytes and 1 Byte Count byte to be added. That's why we count to 3 in the loop. Every byte is XORed with the previous result. Then the intermediate result is rolled left (carry rolls back into b0). This results in a very reliable checksum, and that for only 3 bytes! The last record of the file does not contain any checksums! So the file ends right after the Byte Count of 0. Data Field The payload of the record is formed by the Data field. The number of data bytes expected is given by the Byte Count field. The last record of the file may not contain a Data field. Data Checksum This checksum uses the same algorithm as used for the Address Checksum. This time we calculate the checksum with only the data bytes of this record. checksum = 0 for i = 1 to cc checksum = checksum XOR byte ROL checksum next i Note that we count to the Byte Count cc this time. Size Multiplier In general, binary data will expand in sized by approximately 2.4 times when represented with this format. EXAMPLE
Here is an example Signetics file :B00010A5576F77212044696420796F75207265617B :B01010E56C6C7920676F207468726F756768206136 :B02010256C6C20746861742074726F75626C652068 :B0300D5F746F207265616420746869733FD1 :B03D00 In the example above you can see a piece of code in Signetics format. The first 3 lines have 16 bytes of data each, which can be seen by the byte count. The 4th line has only 13 bytes, because the program is at it's end there. Notice that the last record of the file contains no data bytes, and not even an Address Checksum. SEE ALSO
http://sbprojects.fol.nl/knowledge/fileformats/signetics.htm AUTHOR
This man page was taken from the above Web page. It was written by San Bergmans <sanmail@bigfoot.com> Reference Manual SRecord srec_signetics(5)
All times are GMT -4. The time now is 12:19 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy