Sponsored Content
Top Forums UNIX for Advanced & Expert Users Issue with Removing Carriage Return (^M) in delimited file Post 302177191 by joeyg on Thursday 20th of March 2008 08:55:28 AM
Old 03-20-2008
Question Without a sample file, I am just thinking...

How about something like:

Code:
infile="original.dat"
outfile="revised.dat"
while read zf
  do
    printf "$zf\n" >>$outfile
done < $infile

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Removing carriage return characters from file

Hello there, I need to remove carriage return characters (\n and \r) from any input file specified. This is what I am doing right now: - dumping the file to octal format using the command 'od -c file_name - removing and \s and \n characters using sed commands What I need to do now is... (3 Replies)
Discussion started by: b1saini
3 Replies

2. Shell Programming and Scripting

Removing Carriage return to create one record

I have a file with multiple records in it and want to create a single record by removing all the carriage returns, is there a sed command or another command that will easily allow this to happen. current layout 813209A 813273C 812272B expected result 813209A813273C812272B previously I... (3 Replies)
Discussion started by: r1500
3 Replies

3. Shell Programming and Scripting

sed removing carriage return and newline

Hi, I'm not very familiar with unix shell. I want to replace the combination of two carriage returns and one newline with one carriage return and one newline. I think the best way to do this is to use sed. I tried something like this: sed -e "s#\#\#g" file.txt but it doesn't work. Thanx... (2 Replies)
Discussion started by: mored
2 Replies

4. Shell Programming and Scripting

Removing Carriage Return and or line feed from a file

Hello I'm trying to write a shell script which can remove a carriage return and/or line feed from a file, so the resulting file all ends up on one line. So, I begin with a file like this text in file!<CR> line two!<CR> line three!<CR> END!<CR> And I want to end up with a file... (1 Reply)
Discussion started by: tbone231
1 Replies

5. Shell Programming and Scripting

Carriage Return at end of file

Hi, I have a script that outputs a file that contains the dates from the previous month, which is then used by our application to run processes on each date contained in the file. My problem is is that my script created a blank line at the bottom of the file which causes issues for our... (14 Replies)
Discussion started by: bd_joy
14 Replies

6. UNIX for Dummies Questions & Answers

removing spaces after carriage return

I have a file that I have to place a carriage return at the end of each line for another program to process it. I also need to remove all spaces after the carriage return. I searched the forums and found this command, but it removes all spaces: sed "s/*//g" ic527.txt > ic527.new The... (9 Replies)
Discussion started by: jyoung
9 Replies

7. Shell Programming and Scripting

Removing Carriage return and merging data

Hi, I am trying to remove the carriage return on the record which starts with ADD, MODIFY, or DELETE keyword as the first value in the record. If the records does not start with anyone of these keywords then combine the records with the previous record (line). Input File name xyz.txt... (6 Replies)
Discussion started by: naveed
6 Replies

8. Shell Programming and Scripting

Removal of carriage returns from a comma delimited file

Hi, I have a file which is having some carriage return in one of the field for which single line is coming in multiple lines. I want to combine all those multiple lines of that field into one line. Eg: Input: Id, Name, Location, Comments, Dept 2, John, US, I am from US. I... (5 Replies)
Discussion started by: mahish20
5 Replies

9. Shell Programming and Scripting

Removing Carriage return in a file after particular string

Hi All, I want to remove carriage return in a file using some unix command without writing a script my file is as follows abc1 abc2 abc3 abc4 abc5 bac6 abc1 abc2 abc3 abc4 abc5 bac6 I want the output as follows: abc1 abc2 abc3 abc4 abc5 bac6 abc1 abc2 abc3 abc4 abc5 bac6 , Please... (7 Replies)
Discussion started by: manish8484
7 Replies

10. Shell Programming and Scripting

Removing carriage return/line feeds on multiple lines

I would like to remove carriage returns/line feeds in a text file, but in a specific cadence: Read first line (Header Line 1), remove cr/lf at the end (replace it with a space ideally); Read the next line (Line of Text 2), leave the cr/lf intact; Read the next line, remove the cr/lf; Read... (14 Replies)
Discussion started by: tomr2012
14 Replies
ici::doc::pod3::sdrstring(3)				       ICI library functions				      ici::doc::pod3::sdrstring(3)

NAME
sdrstring - Simple Data Recorder string functions SYNOPSIS
#include "sdr.h" Object sdr_string_create (Sdr sdr, char *from); Object sdr_string_dup (Sdr sdr, Object from); int sdr_string_length (Sdr sdr, Object string); int sdr_string_read (Sdr sdr, char *into, Object string); DESCRIPTION
SDR strings are used to record strings of up to 255 ASCII characters in the heap space of an SDR. Unlike standard C strings, which are terminated by a zero byte, SDR strings record the length of the string as part of the string object. To store strings longer than 255 characters, use sdr_malloc() and sdr_write() instead of these functions. Object sdr_string_create(Sdr sdr, char *from) Creates a "self-delimited string" in the heap of the indicated SDR, allocating the required space and copying the indicated content. from must be a standard C string for which strlen() must not exceed 255; if it does, or if insufficient SDR space is available, 0 is returned. Otherwise the address of the newly created SDR string object is returned. To destroy, just use sdr_free(). Object sdr_string_dup(Sdr sdr, Object from) Creates a duplicate of the SDR string whose address is from, allocating the required space and copying the original string's content. If insufficient SDR space is available, 0 is returned. Otherwise the address of the newly created copy of the original SDR string object is returned. To destroy, use sdr_free(). int sdr_string_length(Sdr sdr, Object string) Returns the length of the indicated self-delimited string (as would be returned by strlen()), or -1 on any error. int sdr_string_read(Sdr sdr, char *into, Object string) Retrieves the content of the indicated self-delimited string into memory as a standard C string (NULL terminated). Length of into should normally be SDRSTRING_BUFSZ (i.e., 256) to allow for the largest possible SDR string (255 characters) plus the terminating NULL. Returns length of string (as would be returned by strlen()), or -1 on any error. SEE ALSO
sdr(3), sdrlist(3), sdrtable(3), string(3) perl v5.14.2 2012-05-25 ici::doc::pod3::sdrstring(3)
All times are GMT -4. The time now is 02:26 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy