10-29-2009
Replace matching nth occurence
Hi
for eg my file has:
val1 | val2 | val1 | val2 | val1 | val2 | val1 | val2 |
here i need to replace '|' with '|\n' where the occurence of '|' is divisble by 2
so that the output comes like this
val1 | val2 |
val1 | val2 |
val1 | val2 |
val1 | val2 |
Requesting suggestions in awk or sed
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
hi all
i want to delete a line upto a particular character. here is example.
cp cms/images/wifi-zone.png
i want to delete the line till . (cp cms/images/wifi-zone.) so the output wud be "png" only
how can i do it?
also please note down that dot (.) can also occur multiple... (12 Replies)
Discussion started by: kashifv
12 Replies
2. Shell Programming and Scripting
Hi
My input file is like this for eg:
abc abc abc abc abc abc
i would like to replace "abc" with "cba" where the occurrence is divisible by 2
of eg here 2nd, 4th and 6th occurence shud be replace
can anyone suggest in awk or sed (11 Replies)
Discussion started by: raghav288
11 Replies
3. UNIX for Dummies Questions & Answers
Hi guys,
I like to find the Line number of Nth Occurence of a Search string in a file.
If possible, if it will land the cursor to that particualar line will be great.
Cheers!! (3 Replies)
Discussion started by: mac4rfree
3 Replies
4. Shell Programming and Scripting
Hello people,
Once more I need your help with SED/AWK
I need to delete up to the Nth occurence of a char (from the beggining) and until the Mth occurence of a char (from the end)
Example:
Input:
a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z
Output:
i,j
Must delete up to the... (2 Replies)
Discussion started by: drbiloukos
2 Replies
5. Shell Programming and Scripting
Hi,
I have a requirement to search for a pattern in each line in a file and remove the in between words till the 3rd occurrence of double quote (").
Ex: CREATE TABLE "SCHEMANAME"."AMS_LTV_STATUS"
(Note: "SCHEMANAME" may changes for different schemas. Its not a fixed value)
I need to... (2 Replies)
Discussion started by: satyaatcgi
2 Replies
6. Shell Programming and Scripting
Hi ,
I have an issue where I want to parse through the output from a file and I want to grab the nth occurrence of text in between two patterns preferably using awk or sed
! TICKET NBR : 1 !GSI : 102 ! 3100.2.112.1 11/06/2013 15:56:29 ! 3100.2.22.3 98 ! 3100.2.134.2... (8 Replies)
Discussion started by: OTNA
8 Replies
7. UNIX for Dummies Questions & Answers
Hi,
I couldn't figure how to extract until last occurence of a character.
I have the string ./dir1/file1/abc.sh
The output should be /dir1/file1
So, the command should display the path until last occurence of "/".
Thanks. (3 Replies)
Discussion started by: rajivn786
3 Replies
8. Shell Programming and Scripting
Using Awk, how can I achieve the following?
I have set of record numbers, for which, I have to replace the nth field with some values, say spaces.
Eg:
Set of Records : 4,9,10,55,89,etc
I have to change the 8th field of all the above set of records to spaces (10 spaces).
Its a delimited... (1 Reply)
Discussion started by: deepakwins
1 Replies
9. Shell Programming and Scripting
I have file in which the data looks like this,
01,0000000,xxxxxxx/
02,xxxxxxxx,yyyyyy/
03,test1,41203016,,/
01,0000000,xxxxxxx/
02,xxxxxxxx,yyyyyy/ ... (16 Replies)
Discussion started by: r@v!7*7@
16 Replies
10. Shell Programming and Scripting
Hello,
Environment:
I am under Ubuntu 18.04 bionic. I have an sql file consisting of 10K lines.
Objective:
What I am trying to attain is to remove everything coming after 2nd tab in each line. While searching for the answer, I found two answers and both gave expected result just for the first... (2 Replies)
Discussion started by: baris35
2 Replies
LEARN ABOUT DEBIAN
xml::libxml::lazybuilder
XML::LibXML::LazyBuilder(3pm) User Contributed Perl Documentation XML::LibXML::LazyBuilder(3pm)
NAME
XML::LibXML::LazyBuilder - easy and lazy way to create XML document for XML::LibXML
SYNOPSIS
use XML::LibXML::LazyBuilder;
{
package XML::LibXML::LazyBuilder;
$d = DOM (E A => {at1 => "val1", at2 => "val2"},
((E B => {}, ((E "C"),
(E D => {}, "Content of D"))),
(E E => {}, ((E F => {}, "Content of F"),
(E "G")))));
}
DESCRIPTION
You can describe XML documents like simple function call instead of using createElement, appendChild, etc...
FUNCTIONS
E
E "tagname", \%attr, @children
Creats CODEREF that generates "XML::LibXML::Element" which tag name is given by first argument. Rest arguments are list of text
content or child element created by "E" (so you can nest "E").
Since the output of this function is CODEREF, the creation of actual "XML::LibXML::Element" object will be delayed until "DOM" function
is called.
DOM
DOM &docroot, $var, $enc
Generates "XML::LibXML::Document" object actually. First argument is a CODEREF created by "E" function. $var is version number of XML
docuemnt, "1.0" by default. $enc is encoding, "utf-8" by default.
EXPORT
None by default.
:all
Exports "E" and "DOM".
EXAMPLES
I recommend to use "package" statement in a small scope so that you can use short function name and avoid to pollute global name space.
my $d;
{
package XML::LibXML::LazyBuilder;
$d = DOM (E A => {at1 => "val1", at2 => "val2"},
((E B => {}, ((E "C"),
(E D => {}, "Content of D"))),
(E E => {}, ((E F => {}, "Content of F"),
(E "G")))));
}
Then, "$d->toString" will generate XML like this:
<?xml version="1.0" encoding="utf-8"?>
<A at1="val1" at2="val2"><B><C/><D>Content of D</D></B><E><F>Content of F</F><G/></E></A>
SEE ALSO
XML::LibXML
AUTHOR
Toru Hisai, <toru@torus.jp>
COPYRIGHT AND LICENSE
Copyright (C) 2008 by Toru Hisai
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.0 or,
at your option, any later version of Perl 5 you may have available.
perl v5.12.3 2008-11-10 XML::LibXML::LazyBuilder(3pm)