Sponsored Content
Special Forums UNIX Desktop Questions & Answers Remove new line characters from a file Post 302627527 by birei on Friday 20th of April 2012 05:06:53 PM
Old 04-20-2012
Hi saini,

Try:
Code:
$ cat infile 
26,<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE EmployeeDetails SYSTEM  "EmpDetails.dtd">
<Employee>
 <Address>
  <Street>1234 64th Ave</Street>
   </Address>
</Employee>,<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE Success SYSTEM "Succ.dtd"><Employee><Success>inserted</Success></Employee>
47,<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE EmployeeDetails SYSTEM  "EmpDetails.dtd">
<Employee>
 <Address>
  <Street>PO BOX 56</Street>
   </Address>
</Employee>,<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE Success SYSTEM "Succ.dtd"><Employee><Success>updated</Success></Employee>
$ perl -pe 'tr/,/|/; chomp unless m|(?i)</Success></Employee>\s*\Z|' infile
26|<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE EmployeeDetails SYSTEM  "EmpDetails.dtd"><Employee> <Address>  <Street>1234 64th Ave</Street>   </Address></Employee>|<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE Success SYSTEM "Succ.dtd"><Employee><Success>inserted</Success></Employee>
47|<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE EmployeeDetails SYSTEM  "EmpDetails.dtd"><Employee> <Address>  <Street>PO BOX 56</Street>   </Address></Employee>|<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE Success SYSTEM "Succ.dtd"><Employee><Success>updated</Success></Employee>

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed remove last 10 characters of a line start from 3rd line

hello experts, I need a sed command that remove last 10 characters of a line start from 3rd line. any suggestions? Thanks you (7 Replies)
Discussion started by: minifish
7 Replies

2. Shell Programming and Scripting

sed to remove 1st two characters every line of text file

what is the sed command to remove the first two characters of every line of a text file? each line of the text file has the same amount of characters, and they are ALL NUMERIC. there are hundreds of lines though. for example, >cat file1.txt 10081551 10081599 10082234 10082259 20081134... (20 Replies)
Discussion started by: ajp7701
20 Replies

3. UNIX for Dummies Questions & Answers

remove characters from line

Hello, I have multiple lines in a file, each of which will have data that looks like this: xxxxxyyyyzzzz4abcdXYZXYZXYZ pqrstPQRST2cdPQRSTPQRST lmnopqr6abcdefgRST.3abc I want to be able to remove the number 4 + the following 4 characters (abcd) in the first line. For the second line,... (1 Reply)
Discussion started by: Gussifinknottle
1 Replies

4. Shell Programming and Scripting

How to remove special characters from each line?

Hello, Is there a simpler way to remove special characters (color codes) from each lines in a log file? I use sed like in the example below but I think there should be a more simple way to achieve the same result: $ cat -vet file1 ^, , , , Maybe to convert the file somehow? ... (5 Replies)
Discussion started by: majormark
5 Replies

5. Shell Programming and Scripting

remove first few characters from each line

Hi, I have a file with lines like below. I need to remove first few characters from each line until a date format is found. 05/06/12 20:47:02 GUMGUY@98.192.174.74{42B42A72AC955F5926621273E3A15059.tomcat2}TP-Processor15 LogExchUsage: ERROR: 05/06/12 20:47:02... (8 Replies)
Discussion started by: ratheeshjulk
8 Replies

6. Shell Programming and Scripting

Remove characters from line

I have a the following line 22.152.25.36 - K##### "GET /DGGKE/GetMail.do;jwebsphere=FADFFFGSFGSFGSDGFSDFGSDFGSDF HTTP/1.1" 200 44948 Need a cut command which should give me the below output 22.152.25.36 - K##### "GET /DGGKE/GetMail.do HTTP/1.1" 200 44948 Note: The value of jwebsphere can... (6 Replies)
Discussion started by: suindar1982
6 Replies

7. Shell Programming and Scripting

I want to remove 1st and last two characters of each line of the file

I want to remove 1st and last two characters of each line of the file Ex: file1 zzfile1ee @xfile2:y qfile3>> @ file4yy and redirect to the file called new Basically file will have any charcter including space, spical character... Please help.... (7 Replies)
Discussion started by: shell1509
7 Replies

8. Shell Programming and Scripting

Ksh: Read line parse characters into variable and remove the line if the date is older than 50 days

I have a test file with the following format, It contains the username_date when the user was locked from the database. $ cat lockedusers.txt TEST1_21062016 TEST2_02122015 TEST3_01032016 TEST4_01042016 I'm writing a ksh script and faced with this difficult scenario for my... (11 Replies)
Discussion started by: humble_learner
11 Replies

9. Shell Programming and Scripting

Remove first 2 characters and last two characters of each line

here's what im trying to do. i have a file containing lines similar to this: data.txt: 1hsRmRsbHRiSFZNTTA1dlEyMWFkbU5wUW5CSlIyeDFTVU5SYjJOSFRuWmpia0ZuWXpKV2FHTnRU 1lKUnpWMldrZFZaMG95V25oYQpSelEyWTBka2QyRklhSHBrUjA1b1kwUkJkd3BOVXpWM1lVaG5k... (5 Replies)
Discussion started by: SkySmart
5 Replies

10. Shell Programming and Scripting

How to remove new line characters from data rows in a Pipe delimited file?

I have a file as below Emp1|FirstName|MiddleName|LastName|Address|Pincode|PhoneNumber 1234|FirstName1|MiddleName2|LastName3| Add1 || ADD2|123|000000000 2345|FirstName2|MiddleName3|LastName4| Add1 || ADD2| 234|000000000 OUTPUT : ... (1 Reply)
Discussion started by: styris
1 Replies
Math::Polygon::Clip(3pm)				User Contributed Perl Documentation				  Math::Polygon::Clip(3pm)

NAME
Math::Polygon::Clip - frame a polygon in a square INHERITANCE
Math::Polygon::Clip is a Exporter SYNOPSIS
my @poly = ( [1,2], [2,4], [5,7], [1, 2] ); my @box = ( $xmin, $ymin, $xmax, $ymax ); my $boxed = polygon_clip @box, @poly; DESCRIPTION
Cut-off all parts of the polygon which are outside the box FUNCTIONS
polygon_fill_clip1(ARRAY-BOX, LIST-OF-POINTS) Clipping a polygon into rectangles can be done in various ways. With this algorithm (which I designed myself, but may not be new), the parts of the polygon which are outside the BOX are mapped on the borders. The polygon stays in one piece. Returned is one list of points, which is cleaned from double points, spikes and superfluous intermediate points. polygon_fill_clip2(ARRAY-BOX, LIST-OF-POINTS) To be implemented. The polygon falls apart in fragments, which are not connected: paths which are followed in two directions are removed. This is required by some applications, like polygons used in geographical context (country contours and such). polygon_fill_clip3(ARRAY-BOX, OUT-POLY, [IN-POLYS]) To be implemented. A surrounding polygon, with possible inclussions. polygon_line_clip(ARRAY-BOX, LIST-OF-POINTS) Returned is a list of ARRAYS (possibly 0 long) containing line pieces from the input polygon (or line). example: my @points = ( [1,2], [2,3], [2,0], [1,-1], [1,2] ); my @bbox = ( 0, -2, 2, 2 ); my @l = polygon_line_clip @bbox, @points; print scalar @l; # 1, only one piece found my @first = @{$l[0]}; # first is [2,0], [1,-1], [1,2] SEE ALSO
This module is part of Math-Polygon distribution version 1.02, built on September 19, 2011. Website: http://perl.overmeer.net/geo/ LICENSE
Copyrights 2004,2006-2011 by Mark Overmeer. For other contributors see ChangeLog. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See http://www.perl.com/perl/misc/Artistic.html perl v5.12.4 2011-09-19 Math::Polygon::Clip(3pm)
All times are GMT -4. The time now is 08:45 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy