Visit The New, Modern Unix Linux Community


Remove <CR><LF> from the dat file in unix


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Remove <CR><LF> from the dat file in unix
# 1  
Remove <CR><LF> from the dat file in unix

Hi,

The source system has created the file in the dat format and put into the linux directory as mentioned below. I want to do foloowing things.

a) Delete the Line started with <CR><LF> in the record
b)Also line
...........................................................<CR><LF>


Source file

PCEXT.DAT P<CR><LF>
BATCH HRIS<CR><LF>
<CR>LF>
E 0003547-620-955 55FTM SHHC 520601810914 2<CR><LF>
F1 0003001Gordon_Davan 243 Consumers Road<CR><LF>
H 0003999 1 D 10 9042 0648639<CR><LF>
...........................................................<CR><LF> J 0003 1 763400 0<CR><LF>
J 0003 2ONN 6 00050001<CR><LF>
J 0003 6ONN 3 12100100<CR><LF>
LA 0003###-####<CR><LF>
LB 0003810914 13<CR><LF>
<CR>LF>
E 0003547-620-955 55FTM SHHC 520601810914 2<CR><LF>
F1 0003001Gordon_Davan 243 Consumers Road<CR><LF>
H 0003999 1 D 10 9042 0648639<CR><LF>
...........................................................<CR><LF> J 0003 1 763400 0<CR><LF>
J 0003 2ONN 6 00050001<CR><LF>
J 0003 6ONN 3 12100100<CR><LF>
LA 0003###-####<CR><LF>
LB 0003810914 13<CR><LF>
<CR>LF>




Output file should be like this .
PCEXT.DAT P<CR><LF>
BATCH HRIS<CR><LF>

E 0003547-620-955 55FTM SHHC 520601810914 2<CR><LF>
F1 0003001Gordon_Davan 243 Consumers Road<CR><LF>
H 0003999 1 D 10 9042 0648639<CR><LF>
J 0003 1 763400 0<CR><LF>
J 0003 2ONN 6 00050001<CR><LF>
J 0003 6ONN 3 12100100<CR><LF>
LA 0003###-####<CR><LF>
LB 0003810914 13<CR><LF>

E 0003547-620-955 55FTM SHHC 520601810914 2<CR><LF>
F1 0003001Gordon_Davan 243 Consumers Road<CR><LF>
H 0003999 1 D 10 9042 0648639<CR><LF>
J 0003 1 763400 0<CR><LF>
J 0003 2ONN 6 00050001<CR><LF>
J 0003 6ONN 3 12100100<CR><LF>
LA 0003###-####<CR><LF>
LB 0003810914 13<CR><LF>

# 2  
OK you probably need:
This
Code:
grep -v '^\.*$' infile

or this
Code:
sed -e 's/^\.*<CR><LF>//' -e '/^$/d' infile

Depending if "<CR><LF>" represents the CR and LF control characters or the literal strings.

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #794
Difficulty: Medium
1/10 has a finite binary representation.
True or False?

10 More Discussions You Might Find Interesting

1. Answers to Frequently Asked Questions

How to split a dat file based on another file ni UNIX?

i have two files , one is var.txt and another res.dat file var.txt contains informaton like below date,request,sales,item 20171015,1,123456,216 20171015,1,123456,217 20171015,2,345678,214 20171015,3,456789,218 and res.dat contains is a one huge file contains information like... (1 Reply)
Discussion started by: pogo
1 Replies

2. Shell Programming and Scripting

Date format change in UNIX .dat file

Hi, I need help to convert the date format in .DAT file in unix. I want to convert 10@@|SWIFT MT568 Extract@@|Apr 14 2014 5:47:52:563PM@@|Apr 14 2014 4:33:47:663PM@@||##| into 10@@|SWIFT MT568 Extract@@|04/14/2014/ 5:47:52:563PM@@|04/14/2014 4:33:47:663PM@@||##| Appreciate... (18 Replies)
Discussion started by: karthikengox
18 Replies

3. Shell Programming and Scripting

Remove interspersed headers in .dat file with AWK

Heya there, A small selection of my data is shown below. DATE TIME FRAC_DAYS_SINCE_JAN1 2011-06-25 08:03:20.000 175.33564815 2011-06-25 08:03:25.000 175.33570602 2011-06-25 ... (4 Replies)
Discussion started by: gd9629
4 Replies

4. Shell Programming and Scripting

How to remove duplicates from the .dat file

All, I have a file 1181CUSTOMER-L061411_003500.dat.Z having duplicate records in it. bash-2.05$ zcat 1181CUSTOMER-L061411_003500.dat.Z|grep "90876251S" 90876251S|ABG, AN ADAYANA COMPANY|3550 DEPAUW BLVD|||US|IN|INDIANAPOLIS||DAL|46268||||||GEN|||||||USD|||ABG, AN ADAYANA... (3 Replies)
Discussion started by: Oracle_User
3 Replies

5. Shell Programming and Scripting

Filter/remove duplicate .dat file with certain criteria

I am a beginner in Unix. Though have been asked to write a script to filter(remove duplicates) data from a .dat file. File is very huge containig billions of records. contents of file looks like 30002157,40342424,OTC,mart_rec,100, ,0 30002157,40343369,OTC,mart_rec,95, ,0... (6 Replies)
Discussion started by: mukeshguliao
6 Replies

6. Shell Programming and Scripting

How to add spaces to test.dat file in unix??

Hi I have a test.dat file in UNIX which has a data.I am informatica developer i get data in those files.I need to add 50 spaces to those data in test.dat file.I am new to unix So can any one help how can i do that. I have some 2088 rows in that test.dat file. Can anyone help me please its... (11 Replies)
Discussion started by: karingulanagara
11 Replies

7. Shell Programming and Scripting

Performance issue in UNIX while generating .dat file from large text file

Hello Gurus, We are facing some performance issue in UNIX. If someone had faced such kind of issue in past please provide your suggestions on this . Problem Definition: /Few of load processes of our Finance Application are facing issue in UNIX when they uses a shell script having below... (19 Replies)
Discussion started by: KRAMA
19 Replies

8. UNIX for Dummies Questions & Answers

How do I delete a data string from a .dat file in unix

I have a .dat file in unix and it keeps failing file validation on line x. How do I delete a data string from a .dat file in UNIX? I tried the following: sed -e 'data string' -e file name and it telling me unrecognized command (4 Replies)
Discussion started by: supergirl3954
4 Replies

9. Shell Programming and Scripting

How to read from a .dat file in Unix

Hi All, I have a .dat file named test.dat where I have stored some process IDs. Now I need to pick a process ID, one by one and then fire kill -9 for each of those. The logic should be: 1. open file <filename.dat> 2. read until last line of file 3. if process ID is found fire kill -9... (5 Replies)
Discussion started by: Sibasish
5 Replies

10. Shell Programming and Scripting

How to attach an excel file/ dat file thru unix mails

Hi. I want to attach a .xls or .dat file while sending mail thru unix. I have come across diff attachments sending options, but allthose embeds the content in the mail. I want the attachement to be send as such. Please help me out. regards Diwakar (1 Reply)
Discussion started by: diwakar82
1 Replies

Featured Tech Videos