Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Removing carriage return characters from file Post 40115 by b1saini on Tuesday 9th of September 2003 12:19:42 PM
Old 09-09-2003
Question 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 convert the file_name from octal format back to a normal format. By normal I mean without octal numbers everywhere.

Please advise on how to undo a conversion done by using the 'od' command.

OR - if you have a better way of removing carriage return characters then please let me know.

Regards,
 

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. UNIX for Advanced & Expert Users

Issue with Removing Carriage Return (^M) in delimited file

Hi - I tried to remove ^M in a delimited file using "tr -d "\r" and "sed 's/^M//g'", but it does not work quite well. While the ^M is removed, the format of the record is still cut in half, like a,b, c c,d,e The delimited file is generated using sh script by outputing a SQL query result to... (7 Replies)
Discussion started by: sirahc
7 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

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

9. Shell Programming and Scripting

line carriage return characters

Hi, I would like to insert the line carriage retrun characters on each line. (2 Replies)
Discussion started by: koti_rama
2 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
OD(1)							    BSD General Commands Manual 						     OD(1)

NAME
od -- octal, decimal, hex, ASCII dump SYNOPSIS
od [-aBbcDdeFfHhIiLlOosvXx] [-A base] [-j skip] [-N length] [-t type] [[+]offset[.][Bb]] [file ...] DESCRIPTION
The od utility is a filter which displays the specified files, or standard input if no files are specified, in a user specified format. The options are as follows: -A base Specify the input address base. base may be one of d, o, x or n, which specify decimal, octal, hexadecimal addresses or no address, respectively. -a Output named characters. Equivalent to -t a. -B, -o Output octal shorts. Equivalent to -t o2. -b Output octal bytes. Equivalent to -t o1. -c Output C-style escaped characters. Equivalent to -t c. -D Output unsigned decimal ints. Equivalent to -t u4. -e, -F Output double-precision floating point numbers. Equivalent to -t fD. -f Output single-precision floating point numbers. Equivalent to -t fF. -H, -X Output hexadecimal ints. Equivalent to -t x4. -h, -x Output hexadecimal shorts. Equivalent to -t x2. -I, -L, -l Output signed decimal longs. Equivalent to -t dL. -i Output signed decimal ints. Equivalent to -t dI. -j skip Skip skip bytes of the combined input before dumping. The number may be followed by one of b, k or m which specify the units of the number as blocks (512 bytes), kilobytes and megabytes, respectively. -N length Dump at most length bytes of input. -O Output octal ints. Equivalent to -t o4. -s Output signed decimal shorts. Equivalent to -t d2. -t type Specify the output format. type is a string containing one or more of the following kinds of type specifiers: a Named characters (ASCII). Control characters are displayed using the following names: 000 NUL 001 SOH 002 STX 003 ETX 004 EOT 005 ENQ 006 ACK 007 BEL 008 BS 009 HT 00a NL 00b VT 00c FF 00d CR 00e SO 00f SI 010 DLE 011 DC1 012 DC2 013 DC3 014 DC4 015 NAK 016 SYN 017 ETB 018 CAN 019 EM 01a SUB 01b ESC 01c FS 01d GS 01e RS 01f US 020 SP 0ff DEL c Characters in the default character set. Non-printing characters are represented as 3-digit octal character codes, except the following characters, which are represented as C escapes: NUL alert a backspace  newline carriage-return tab vertical tab v Multi-byte characters are displayed in the area corresponding to the first byte of the character. The remaining bytes are shown as '**'. [d|o|u|x][C|S|I|L|n] Signed decimal (d), octal (o), unsigned decimal (u) or hexadecimal (x). Followed by an optional size specifier, which may be either C (char), S (short), I (int), L (long), or a byte count as a decimal integer. f[F|D|L|n] Floating-point number. Followed by an optional size specifier, which may be either F (float), D (double) or L (long double). -v Write all input data, instead of replacing lines of duplicate values with a '*'. Multiple options that specify output format may be used; the output will contain one line for each format. If no output format is specified, -t oS is assumed. ENVIRONMENT
The LANG, LC_ALL and LC_CTYPE environment variables affect the execution of od as described in environ(7). DIAGNOSTICS
The od utility exits 0 on success, and >0 if an error occurs. COMPATIBILITY
The traditional -s option to extract string constants is not supported; consider using strings(1) instead. SEE ALSO
hexdump(1), strings(1) STANDARDS
The od utility conforms to IEEE Std 1003.1-2001 (``POSIX.1''). HISTORY
An od command appeared in Version 1 AT&T UNIX. BSD
July 11, 2004 BSD
All times are GMT -4. The time now is 07:47 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy