How to replace ^J in unix file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to replace ^J in unix file
# 8  
Old 11-02-2010
Please post the answer to my questions from post #4 and the "od" output from post #6.
We won't get anywhere until we know what characters are in the file.
# 9  
Old 11-02-2010
Thanks for reply... below are the results that i captured in AIX box for the file inputfile.txt

Post 4 output:
-------------
sed -n l inputfile.txt.txt
1231231231$
asdafsaf$

post 6 output:
------------------
$ od -h <inputfile.txt.txt
0000000 3132 3331 3233 3132 3331 0a61 7364 6166
0000020 7361 6600
0000023
$ od -hc <inputfile.txt.txt
0000000 3132 3331 3233 3132 3331 0a61 7364 6166
1 2 3 1 2 3 1 2 3 1 \n a s d a f
0000020 7361 6600
s a f
0000023
$ od -oc <inputfile.txt.txt
0000000 030462 031461 031063 030462 031461 005141 071544 060546
1 2 3 1 2 3 1 2 3 1 \n a s d a f
0000020 071541 063000
s a f
0000023
$ od -bc <inputfile.txt.txt
0000000 061 062 063 061 062 063 061 062 063 061 012 141 163 144 141 146
1 2 3 1 2 3 1 2 3 1 \n a s d a f
0000020 163 141 146
s a f
0000023


Quote:
Originally Posted by methyl
Please post the answer to my questions from post #4 and the "od" output from post #6.
We won't get anywhere until we know what characters are in the file.
# 10  
Old 11-02-2010
What you have there is not a text format file. There is no trailing line-feed character on the last record.

If (referring to post #1) you want to remove the rest of the carriage return characters to produce a file which might be suitable for your program but is unsuitable for processing in shell or common utilities such as "sed" "tail" etc.:
Code:
cat oldfile | tr -d '\n' > newfile

# 11  
Old 11-03-2010
EDIT: already answered

Last edited by ikki; 11-03-2010 at 06:18 AM.. Reason: unnecessary post
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Views How to replace a CRLF char from a variable length file in the middle of a string in UNIX?

My sample file is variable length, with out any field delimiters. It has min of 18 chars length and the 'CRLF' is potentially between 12-14 chars. How do I replace this with a space? I still want to keep end of record, but just want to remove these new lines chars in the middle of the data. ... (7 Replies)
Discussion started by: chandrath
7 Replies

2. Emergency UNIX and Linux Support

Need to replace a column value in UNIX file

Hi All, I am having a file like below 01098546 3 56120610010377101008311121 001382 71 003 5011339 01099413 1 42120500010247081106112121 000304 46 002 2011339 I want to replace the 78 column from 3 to 4 and I need the file as below 01098546 ... (1 Reply)
Discussion started by: arunkumar_mca
1 Replies

3. Shell Programming and Scripting

Replace first 3 characters in a unix file in all lines

Replace first 3 characters in a unix file (say replace "A&B" with "C&D") in all lines of the file. Need a sed or awk script to do this. Kindly help! -Kumar (4 Replies)
Discussion started by: vasan2815
4 Replies

4. UNIX for Dummies Questions & Answers

How to replace a file on Unix server with file from my c: drive

I have a Logging.xml file located on my laptop c: drive. I want to take this file and replace the Logging.xml that is currently on my Aix 6.1 Unix server with it. Here is the where the file is located. It is the Logging.xml file ... (8 Replies)
Discussion started by: gregvc
8 Replies

5. Shell Programming and Scripting

Help needed :Search and Replace a string pattern with empty in an xml file in unix

Search and Replace a string pattern with empty in an xml file in unix: My xml file would be like this : <Accounts><Name>Harish</Name><mobile>90844444444444445999 </mobile><TRIG>srcujim-1</TRIG></Accounts><Accounts><Name>Satish</Name><mobile>908999</mobile><TRIG>ettertrtt-1</TRIG></Accounts> ... (1 Reply)
Discussion started by: harish_s_ampeo
1 Replies

6. Shell Programming and Scripting

Replace Date field in Unix File

I have a data file having first 19 characters having the date in the below format- 2010-04-29-00.00.00 I have to check this date field ( first 19 characters) against some specific dates and if date is not in 3 valid dates ( business date available to me , business date - 1 , businessdate... (10 Replies)
Discussion started by: varunrbs
10 Replies

7. UNIX for Dummies Questions & Answers

How to replace the string in unix file?

Hi Am getting "Line too long" error in opening a file using vi editor but it is opening using cat. How can i edit the file to replace some string in it. Thanks (5 Replies)
Discussion started by: param_it
5 Replies

8. Shell Programming and Scripting

replace delimiter : with '\001' in unix data file

HI can any one tell me how to replace a delimiter : with another delimiter '\001' it is a non printable octal character. thanks in adv spandu (4 Replies)
Discussion started by: spandu
4 Replies

9. UNIX for Dummies Questions & Answers

how to replace certain patterns in a file thru unix!!

Hi Friends, well what i want to do is that suppose i have a file say like .... ronaldduckdancecoolman donaldmuckdancepooltactics fonaldguckdancetoolbutcomps .... okok i agree this is a ridiculous data for a file. :-) now i want that the characters in each line fromposition 16 to say 19... (6 Replies)
Discussion started by: mexx_freedom
6 Replies
Login or Register to Ask a Question