LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Closed Thread
  Search this Thread
Old 03-13-2019, 01:22 AM   #1
mechvijays
LQ Newbie
 
Registered: Mar 2019
Posts: 3

Rep: Reputation: Disabled
increment the sequence only when a specific string appears in line


I will rephrase the question

input :

AAAcjjjef
BBBifhfh
CCoiwfji
CCCifhifei
YYYjhcjh
ZZZjiddi
AAAcjjjeffdd
BBBifhdcdfh
CCoiwfdji
CCCifhdifei
YYYjhdcjh
ZZZjidddi

whenever the line starts with AAA, rest the counter

output :

1:AAAcjjjef
1:BBBifhfh
1:CCoiwfji
1:CCCifhifei
1:YYYjhcjh
1:ZZZjiddi
2:AAAcjjjeffdd
2:BBBifhdcdfh
2:CCoiwfdji
2:CCCifhdifei
2:YYYjhdcjh
2:ZZZjidddi
 
Old 03-13-2019, 01:17 PM   #2
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,264
Blog Entries: 24

Rep: Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194
Please post your thread in only one forum. Posting a single thread in the most relevant forum will make it easier for members to help you and will keep the discussion in one place. This thread is being closed because it is a duplicate.

Please continue the discussion here.
 
  


Closed Thread

Tags
awk regex, lines, sequence



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to capture 1000 lines before a string match and 1000 line a string match including line of string match ? sysmicuser Linux - Newbie 12 11-14-2017 05:21 AM
In if test the list contains only one specific string or multiple same specific string Mike_Brown Linux - Newbie 1 01-27-2016 10:52 PM
How to replace a string if another specific string exists in the line victorcheung Programming 3 06-26-2015 07:20 PM
How to find a specific string sequence in files puntino Linux - Newbie 2 11-12-2012 03:16 PM
[Bash] increment number in a string czezz Programming 4 07-01-2009 11:34 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:24 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration