Sponsored Content
Top Forums Shell Programming and Scripting Delete until Nth occurence (sed, awk) Post 302753687 by Scrutinizer on Wednesday 9th of January 2013 07:51:25 AM
Old 01-09-2013
Try:
Code:
sed 's/\([^,]*,\)\{8\}//; s/\(,[^,]*\)\{16\}$//' file


Last edited by Scrutinizer; 01-09-2013 at 09:14 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

delete line upto the nth occurence of a particular charachter.

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

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... (1 Reply)
Discussion started by: raghav288
1 Replies

3. Shell Programming and Scripting

Replacing nth occurence

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

4. UNIX for Dummies Questions & Answers

To find the Nth Occurence of Search String

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

5. Shell Programming and Scripting

Using tr, sed or awk to delete text from nth column only

Hi everyone, this is my first post here, I hope someone can help me. I have a file which I need to delete characters '_F3' from the end of the text in the first column. The problem is that the characters may also occur elsewhere in the file (i.e. second columns onwards). I tried sed (thinking I... (6 Replies)
Discussion started by: hlwright
6 Replies

6. Shell Programming and Scripting

[Solved] Find and replace till nth occurence of a special character

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

7. Shell Programming and Scripting

Grab nth occurence in between two patterns using awk or sed

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

8. UNIX for Dummies Questions & Answers

Extract until nth occurence

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

9. Shell Programming and Scripting

Get nth occurence of string from a file

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

Delete after nth occurence of string in each line

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
Set::Infinite::_recurrence(3pm) 			User Contributed Perl Documentation			   Set::Infinite::_recurrence(3pm)

NAME
Set::Infinite::_recurrence - Extends Set::Infinite with recurrence functions SYNOPSIS
$recurrence = $base_set->_recurrence ( &next, &previous ); DESCRIPTION
This is an internal class used by the DateTime::Set module. The API is subject to change. It provides all functionality provided by Set::Infinite, plus the ability to define recurrences with arbitrary objects, such as dates. METHODS
o _recurrence ( &next, &previous ) Creates a recurrence set. The set is defined inside a 'base set'. $recurrence = $base_set->_recurrence ( &next, &previous ); The recurrence functions take one argument, and return the 'next' or the 'previous' occurence. Example: defines the set of all 'integer numbers': use strict; use Set::Infinite::_recurrence; use POSIX qw(floor); # define the recurrence span my $forever = Set::Infinite::_recurrence->new( Set::Infinite::_recurrence::NEG_INFINITY, Set::Infinite::_recurrence::INFINITY ); my $recurrence = $forever->_recurrence( sub { # next floor( $_[0] + 1 ) }, sub { # previous my $tmp = floor( $_[0] ); $tmp < $_[0] ? $tmp : $_[0] - 1 }, ); print "sample recurrence ", $recurrence->intersection( -5, 5 ), " "; # sample recurrence -5,-4,-3,-2,-1,0,1,2,3,4,5 { my $x = 234.567; print "next occurence after $x = ", $recurrence->{param}[0]->( $x ), " "; # 235 print "previous occurence before $x = ", $recurrence->{param}[2]->( $x ), " "; # 234 } { my $x = 234; print "next occurence after $x = ", $recurrence->{param}[0]->( $x ), " "; # 235 print "previous occurence before $x = ", $recurrence->{param}[2]->( $x ), " "; # 233 } o is_forever Returns true if the set is a single span, ranging from -Infinity to Infinity. o _is_recurrence Returns true if the set is an unbounded recurrence, ranging from -Infinity to Infinity. CONSTANTS
o INFINITY The "Infinity" value. o NEG_INFINITY The "-Infinity" value. SUPPORT
Support is offered through the "datetime@perl.org" mailing list. Please report bugs using rt.cpan.org AUTHOR
Flavio Soibelmann Glock <fglock@gmail.com> The recurrence generation algorithm is based on an idea from Dave Rolsky. COPYRIGHT
Copyright (c) 2003 Flavio Soibelmann Glock. All rights reserved. This program is free software; you can distribute it and/or modify it under the same terms as Perl itself. The full text of the license can be found in the LICENSE file included with this module. SEE ALSO
Set::Infinite DateTime::Set For details on the Perl DateTime Suite project please see <http://datetime.perl.org>. perl v5.12.4 2011-08-22 Set::Infinite::_recurrence(3pm)
All times are GMT -4. The time now is 09:56 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy