Sponsored Content
Full Discussion: Deleting [CR][LF] using sed
Top Forums Shell Programming and Scripting Deleting [CR][LF] using sed Post 302992612 by dae on Monday 27th of February 2017 05:57:45 PM
Old 02-27-2017
Deleting [CR][LF] using sed

Dear all,

I face a problem I can not solve: I have different lines in a file and some of them are ending with [CR][LF] ie "\r\n" and the others are ending with [LF] "\n".

My aim is to supress the string "\r\n" and concatenate that line with the following one.

For example:

Saying I have a file 4_test.csv with the 4 following lines:

Code:
[x004191a@xsnl11p370p tmp]$ cat -v 4_test.csv
123^M
456
789^M
0AB
[x004191a@xsnl11p370p tmp]$ od -c 4_test.csv
0000000   1   2   3  \r  \n   4   5   6  \n   7   8   9  \r  \n   0   A
0000020   B  \n
0000022
[x004191a@xsnl11p370p tmp]$

My aim is to get as a result a file with only the two following lines:

Code:
[x004191a@xsnl11p370p tmp]$ cat -v 4_test_target.csv
123456
7890AB
[x004191a@xsnl11p370p tmp]$ od -c 4_test_target.csv
0000000   1   2   3   4   5   6  \n   7   8   9   0   A   B  \n
0000016
[x004191a@xsnl11p370p tmp]$

I tried different syntax using sed but I was not able to suppress the two consecutive characters '\r\n' !

Any kind of idea would be greatly appreciated ... Thanks a lot,

Didier.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Deleting Multiple Lines with sed

I am trying to use sed to delete multiple lines in a file. The problem is that I need to search for a certain line and then once found delete it plus the next 4 lines. For instance if I had a file that consisted of the following lines: #Data1.start ( (Database= data1) (Name = IPC)... (1 Reply)
Discussion started by: rambo15
1 Replies

2. Shell Programming and Scripting

Help deleting lines with SED.

I take the /etc/passwd file and print it out, but I only want the lines that end with sh. I have cat /etc/passwd | sed '/sh/!d' Which prints out all lines that have sh somewhere in it. So I added $, which I thought matches the ends on lines, but its not working, like for example I have have... (5 Replies)
Discussion started by: Bandit390
5 Replies

3. Shell Programming and Scripting

sed logic before deleting

FileA NAME STATE CITY ---- ---- ----- abc ca ca bcc ny ny def nj nj (3 rows affected) Q1) I want to delete the second row with is ---- ---- -----. Can delete 2nd row using following sed '2d' FileA >FileB but incase the second record is not ---- ---- -----. then data will... (3 Replies)
Discussion started by: pinnacle
3 Replies

4. Shell Programming and Scripting

Deleting lines using Sed

Hi All, Please can anyone help me as am deleting a line in a file with the below script: sed '/"$value"/d' redirects.virgin-atlantic.com.conf > olist where $value is a variable where the pattern to be matched is stored. I am not getting any error also but the line containing the pattern... (2 Replies)
Discussion started by: Shazin
2 Replies

5. Shell Programming and Scripting

deleting text records with sed (sed paragraphs)

Hi all, First off, Thank you all for the knowledge I have gleaned from this site! Deleting Records from a text file... sed paragraphs The following code works nearly perfect, however each time it is run on the log file it adds a newline at the head of the file, run it 5 times, it'll have 5... (1 Reply)
Discussion started by: Festus Hagen
1 Replies

6. UNIX for Dummies Questions & Answers

deleting text with sed

Hi There! I've got a tab delimited text file (output from a software) to which I would like to delete specific strings from one of the columns. I have tried several sed codes, but they do not seem to work for me. I can manage to delete a specific word, but this is of no use, as I what I want to... (3 Replies)
Discussion started by: alfredman
3 Replies

7. Shell Programming and Scripting

sed - deleting each line up to a word

Hi there, I'd like to delete the beginning of a line up until it finds a certain word or character string: in this case, I'd like to delete each line up to the word "mounting". Thanks ;) Susan (12 Replies)
Discussion started by: kitykity
12 Replies

8. UNIX for Dummies Questions & Answers

Deleting all but a regex using sed, tr, cut etc

Hi guys, this is my first post, though I've been looking around the forums for a while trying to find a solution to my problem. I want to be able to take a several lines of text (an out put from get-iplayer and ls to be precise) and only keep the crazy alphanumerical code in each line. For example:... (6 Replies)
Discussion started by: Pureferret
6 Replies

9. UNIX for Dummies Questions & Answers

Deleting last 3 lines from a file via sed

Hi Anybody can help me to delete the last 3 lines from a text file via sed under SunOS 5.8? Thanks Aldar (4 Replies)
Discussion started by: aldar
4 Replies

10. Shell Programming and Scripting

Using sed for deleting the first word of each line?

sed /'1-2'/&^/ filename suppose there is a file containing three lines , how do we do delete the word from each line? hyter efr frf rerfer efe ewd cdcf evrfgf erfv the output has to look like frf ewd erfv (2 Replies)
Discussion started by: Rajeev Nukala
2 Replies
OCR4GAMERA(1)															     OCR4GAMERA(1)

NAME
ocr4gamera - OCR system using the Gamera framework USAGE
ocr4gamera -x <traindata> [options] <imagefile> OPTIONS
-v <int>, --verbosity=<int> Set verbosity level to <int>. Possible values are 0 (default): silent operation; 1: information on progress; >2: segmentation info is written to PNG files with prefix debug_. -h, --help Display help and exit. -d, --deskew Do a skew correction (recommended). -f, --filter Filter out very large (images) and very small components (noise). -a, --automatic-group Autogroup glyphs with classifier. -x <file>, --xmlfile=<file> Read training data from <file>. -o <xml>, --output=<xml> Write recognized text to file <xml> (otherwise it is written to stdout). -c <csv>, --extra_chars_csvfile=<csv> Read additional class name conversions from file <csv>. <csv> must contain one conversion per line. -R <rules>, --heuristic_rules=<rules> Apply heuristic rules <rules> for disambiguation of some chars. <rules> can be roman (default) or none (for no rules). -D, --dictionary-correction Correct words using a dictionary (requires aspell or ispell). -L <lang>, --dictionary-language=<lang> Use <lang> as language for aspell (when option -D is set). -e <int>, --edit-distance=<int> Correct words only when edit distance not more than <int>. OCR4GAMERA(1)
All times are GMT -4. The time now is 07:12 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy