![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Issue with Removing Carriage Return (^M) in delimited file | sirahc | UNIX for Advanced & Expert Users | 7 | 03-25-2008 05:08 AM |
| Carriage Return at end of file | bd_joy | Shell Programming and Scripting | 14 | 10-20-2006 01:20 PM |
| Removing Carriage Return and or line feed from a file | tbone231 | Shell Programming and Scripting | 1 | 02-18-2005 04:37 PM |
| sed removing carriage return and newline | mored | Shell Programming and Scripting | 2 | 05-06-2004 12:28 PM |
| Removing Carriage return to create one record | r1500 | Shell Programming and Scripting | 3 | 02-06-2004 03:45 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
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, |
|
||||
|
try this C
$vi nonewlines.c
Code:
#include <stdio.h>
/*nonewlines.c - remove nl and cr */
main()
{
int ch;
while((ch = getchar()) != EOF) if ((ch!='\n')&&(ch!='\r')) putchar(ch);
}
./nonewlines < filetochange |
|
|||||
|
Please use the search function before posting. We get this question several times a month. Here are a few threads...
there was a strange character(^M) been added automatically in UNIX ^m getting rid of control characters Porting of Windows written unix scripts to unix platform |
|
||||
|
Thanks for the input guys. I ended up using
cat filename | tr -d "\r \n" > filename2 Worked great. |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|