04-26-2018
Search and incremental replace
Dears,
Can you help me with the below concern, I need one liner for this.
Input_file.txt
dn: asdf=yyyyyyyyyyyyy426019001711473,ou=multiSCs,dc=btc
asdf: yyyyyyyyyyyyy426019001711473
DSUnitGroup: 1
objectClass: CUDBMultiServiceConsumer
dn: asdf=yyyyyyyyyyyyy426019001711351,ou=multiSCs,dc=btc
asdf: yyyyyyyyyyyyy426019001711351
DSUnitGroup: 3
objectClass: CUDBMultiServiceConsumer
dn: asdf=yyyyyyyyyyyyy426019001711436,ou=multiSCs,dc=btc
asdf: yyyyyyyyyyyyy426019001711436
DSUnitGroup: 8
objectClass: CUDBMultiServiceConsumer
dn: asdf=yyyyyyyyyyyyy426019001711326,ou=multiSCs,dc=btc
asdf: yyyyyyyyyyyyy426019001711326
DSUnitGroup: 16
objectClass: CUDBMultiServiceConsumer
dn: asdf=yyyyyyyyyyyyy426019001710223,ou=multiSCs,dc=btc
asdf: yyyyyyyyyyyyy426019001710223
DSUnitGroup: 6
objectClass: CUDBMultiServiceConsumer
The output should be like below, the should start from DSUnitGroup: 1 and incremented sequentially till it reach a particular count here let us say DSUnitGroup: 8, and once it is reached again it should start from DSUnitGroup: 1.
Output_file.txt
dn: asdf=yyyyyyyyyyyyy426019001711473,ou=multiSCs,dc=btc
asdf: yyyyyyyyyyyyy426019001711473
DSUnitGroup: 1
objectClass: CUDBMultiServiceConsumer
dn: asdf=yyyyyyyyyyyyy426019001711351,ou=multiSCs,dc=btc
asdf: yyyyyyyyyyyyy426019001711351
DSUnitGroup: 2
objectClass: CUDBMultiServiceConsumer
dn: asdf=yyyyyyyyyyyyy426019001711436,ou=multiSCs,dc=btc
asdf: yyyyyyyyyyyyy426019001711436
DSUnitGroup: 3
objectClass: CUDBMultiServiceConsumer
dn: asdf=yyyyyyyyyyyyy426019001711326,ou=multiSCs,dc=btc
asdf: yyyyyyyyyyyyy426019001711326
DSUnitGroup: 4
objectClass: CUDBMultiServiceConsumer
dn: asdf=yyyyyyyyyyyyy426019001710223,ou=multiSCs,dc=btc
asdf: yyyyyyyyyyyyy426019001710223
DSUnitGroup: 5
objectClass: CUDBMultiServiceConsumer
dn: asdf=yyyyyyyyyyyyy426019001710223,ou=multiSCs,dc=btc
asdf: yyyyyyyyyyyyy426019001710223
DSUnitGroup: 6
objectClass: CUDBMultiServiceConsumer
dn: asdf=yyyyyyyyyyyyy426019001710223,ou=multiSCs,dc=btc
asdf: yyyyyyyyyyyyy426019001710223
DSUnitGroup: 7
objectClass: CUDBMultiServiceConsumer
dn: asdf=yyyyyyyyyyyyy426019001710223,ou=multiSCs,dc=btc
asdf: yyyyyyyyyyyyy426019001710223
DSUnitGroup: 8
objectClass: CUDBMultiServiceConsumer
dn: asdf=yyyyyyyyyyyyy426019001710223,ou=multiSCs,dc=btc
asdf: yyyyyyyyyyyyy426019001710223
DSUnitGroup: 1
objectClass: CUDBMultiServiceConsumer
dn: asdf=yyyyyyyyyyyyy426019001710223,ou=multiSCs,dc=btc
asdf: yyyyyyyyyyyyy426019001710223
DSUnitGroup: 2
objectClass: CUDBMultiServiceConsumer
can you help me with the one liner string. to achieve this.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi All,
I have a file that I need to be able to find a pattern match on a line, search that line for a text pattern, and replace that text.
An example of 4 lines in my file is:
1. MatchText_randomNumberOfText moreData ReplaceMe moreData
2. MatchText_randomNumberOfText moreData moreData... (4 Replies)
Discussion started by: Crypto
4 Replies
2. Shell Programming and Scripting
Hi,
I have a file that looks like the following:
M00071.null T
12 13 1 0 0
SMALL
M00074.null T 1
15 14 0 0 0
SMALL
M14870.null T 2 15431
15 17 0 1 0
SMALL
I want to edit it such that it looks like the following:
M00071
12 13 1 0 0
SMALL
M00074 (5 Replies)
Discussion started by: mjoshi
5 Replies
3. Shell Programming and Scripting
Hi All,
Suppose I have a file "a.doc"
It's contents are :
mos44.0 )
.....
......
.....
export TKTS_RELEASE=tkts44.0b7
......
.......
Now , I need to first search for the pattern "mos44.0 )" and then TKTS_RELEASE will... (8 Replies)
Discussion started by: sanyerra
8 Replies
4. Shell Programming and Scripting
Looking for a way using sed/awk/perl to replace port numbers in a file with an incrementing number. The original file looks like...
Host cmg-iqdrw3p4
LocalForward *:9043 localhost:9043
Host cmg-iqdro3p3a
LocalForward *:10000 localhost:10000
Host cmg-iqdro3p3b
LocalForward... (2 Replies)
Discussion started by: treadwm
2 Replies
5. Shell Programming and Scripting
Hello,
I really would appreciate some help with a bash script for some string manipulation on an SQL dump:
I'd like to be able to rename "sites/WHATEVER/files" to "sites/SOMETHINGELSE/files" within the sql dump.
This is quite easy with sed:
sed -e... (1 Reply)
Discussion started by: otrotipo
1 Replies
6. Shell Programming and Scripting
Hi,
I am having trouble with searching for a name and replacing it. The file is tab deliminated.
Basically I want to replace >ref|NC_001147| and >ref|NC_001148| with chr1 and chr2 respectively.
Here is what my file looks like:
>1_1_120_317 S OXTGHFKDK ... (2 Replies)
Discussion started by: phil_heath
2 Replies
7. Shell Programming and Scripting
Dear All,
i want to search particular string and want to replance next line value.
following is the test file.
search string is
tmp,???
,10:1 "???" may contain any 3 character it should remain the same and next line replace with ,10:50
tmp,123 --- if match tmp,??? then... (3 Replies)
Discussion started by: arvindng
3 Replies
8. Shell Programming and Scripting
Hello!
I have the following lines in a file:
1|0|HEADER|
2|1|HEADER|
3|1|MAIN|
4|1|INFO|
5|1|INFO|
6|1|INFO|
7|2|INFO|
8|4|INFO|
9|55|FOOTER|
10|1|HEADER|
11|22|MAIN|
12|9|MAIN|
and I want to convert it into: (7 Replies)
Discussion started by: TasosARISFC
7 Replies
9. UNIX for Dummies Questions & Answers
Hi all,
I am editing a config file in vi that has a / on it.
At the moment, search and replace looks alright as am able to use a # as a temporary separator, i.e. :,$s#/u01/app#/u02/app#g
For doing a search, I have to escape the / do. So if I want to search for /u01/app, I am having to do... (2 Replies)
Discussion started by: newbie_01
2 Replies
10. Shell Programming and Scripting
Hi Team,
I am new to unix, please help me in this.
I have a file named properties.
The content of the file is :
##Mobile props
east.url=https://qa.east.corp.com/prop/end
west.url=https://qa.west.corp.com/prop/end
south.url=https://qa.south.corp.com/prop/end... (2 Replies)
Discussion started by: tolearn
2 Replies
LEARN ABOUT CENTOS
bashbug
BASHBUG(1) General Commands Manual BASHBUG(1)
NAME
bashbug - report a bug in bash
SYNOPSIS
bashbug [--version] [--help] [email-address]
DESCRIPTION
bashbug is a shell script to help the user compose and mail bug reports concerning bash in a standard format. bashbug invokes the editor
specified by the environment variable EDITOR on a temporary copy of the bug report format outline. The user must fill in the appropriate
fields and exit the editor. bashbug then mails the completed report to bug-bash@gnu.org, or email-address. If the report cannot be
mailed, it is saved in the file dead.bashbug in the invoking user's home directory.
The bug report format outline consists of several sections. The first section provides information about the machine, operating system,
the bash version, and the compilation environment. The second section should be filled in with a description of the bug. The third sec-
tion should be a description of how to reproduce the bug. The optional fourth section is for a proposed fix. Fixes are encouraged.
ENVIRONMENT
bashbug will utilize the following environment variables if they exist:
EDITOR Specifies the preferred editor. If EDITOR is not set, bashbug defaults to emacs.
HOME Directory in which the failed bug report is saved if the mail fails.
TMPDIR Directory in which to create temporary files and directories.
SEE ALSO
bash(1)
AUTHORS
Brian Fox, Free Software Foundation
bfox@gnu.org
Chet Ramey, Case Western Reserve University
chet@po.cwru.edu
GNU Bash-4.0 1998 July 30 BASHBUG(1)