![]() |
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 Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Remove last character of a term | Raynon | Shell Programming and Scripting | 6 | 03-20-2008 06:04 AM |
| How to remove extraneous character | vsmurali | UNIX for Dummies Questions & Answers | 7 | 03-18-2008 12:57 PM |
| Need to serach if a new line character exists on the last line in a file | sunilbm78 | UNIX for Dummies Questions & Answers | 10 | 02-29-2008 02:15 PM |
| Trying to remove single character from a line | Iz3k34l | UNIX for Dummies Questions & Answers | 5 | 07-07-2007 01:29 PM |
| Remove Last Character of Line | danhodges99 | Shell Programming and Scripting | 4 | 05-21-2003 09:30 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
To remove new line character
Hi,
I am facing one interesting problem : I have a file which contains data like this 459,|1998-11-047|a |b |c \n efg | d|e | \n 459,|1998-11-047|a \n c|b |c \n efg | d|e | \n Basically what I have to do is , I have to remove all \n which is coming ( enclosed ) in between two pipes ( | ).. The red coloured only... The problem I am facing is , when i try to do it using sed .. because of this \n , sed takes the entries after it as next record. Could you please help me Shihab |
|
||||
|
Thanks for your help vgersh99
But it is not working I will explain my problem with an example Here is the input file $cat input.dat |a|b c|d| |e|f|i| |h|i|j| and out put should be like this $cat output.dat |a|bc|d| |e|f|i| |h|i|j| Here the first two lines have been joined since new line is not in between | Thanks in advance Shihab |
|
||||
|
perl -e 'while (<>) { if (! /\|$/ ) { chomp; } print ;}' input.dat > output.dat
should work assuming the correct end of line is always preceeded with a '|' character. If you have trailing spaces or suchlike on the lines then it needs a little modification. |
|
||||
|
Thanks a loooooot!!!!!
My problem have been solved.... The Solution Suggested by Unbeliever is working fine.... When I tried with the solution by jerardfjay , it gives me the following error : Segmentation fault(coredump) .. Could you please tell me why ? I am using AIX 5. The solution with sed by reborg is also working fine.. but it fails , if more that one \n is there in a single line. It appends the first with second..and so on... any way could you please explain the code.. if you don't mind Thanks once again Shihab |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|