Sponsored Content
Full Discussion: Find and replace increament
Top Forums Shell Programming and Scripting Find and replace increament Post 303016419 by Kamesh G on Thursday 26th of April 2018 11:27:34 AM
Old 04-26-2018
Linux Find and replace increament

Dears,

Can you help me with the below concern, I need one liner for this.

Input_file.txt
Code:
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
Code:
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.

Last edited by rbatte1; 04-26-2018 at 02:23 PM.. Reason: Added CODE tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

find and replace

Hi, Iam new to shell script.How to write bourn shell script for find and replace. My requirement is: variable: name="abcd & co" i wanted to replace '&' with amp; plz suggest with out using sed. Thanks lot. (2 Replies)
Discussion started by: ram2s2001
2 Replies

2. UNIX for Dummies Questions & Answers

Find and Replace

After running a command like grep -ir files2/ * This will find all the files that contain "files2/" in it. For example if it finds files2/dir/today files2/dir/yesterday files2/dir/2daysago Now it may find 100 instances, so is there a quick find and replace command I can use? I... (4 Replies)
Discussion started by: NycUnxer
4 Replies

3. Solaris

find/replace?

Dear All To find a file, according to you, I tried as: #find / -name file-name -print To find a string inside the files , I tried as : #find / -name "*" |xargs grep "string" Can you please let me know how can I try for find/replace (i.e. finding the intended string inside the text files... (6 Replies)
Discussion started by: hadimotamedi
6 Replies

4. UNIX for Dummies Questions & Answers

find and replace

I have a tab-delimited inFile: cat inFile A B C D E F 1 2 3 4 5 6 a b c d e fI would like to replace the first 3 tabs in each row with underscore to get outFile: A_B_C_D E F 1_2_3_4 5 6 a_b_c_d e fhow can I modify the following... (5 Replies)
Discussion started by: jdhahbi
5 Replies

5. Shell Programming and Scripting

find and replace

Hi I am very new to shell scripting (and linux in general)... I am trying to build some script, that will read a person from a csv file, (each person will have an ID, eg id001abc, which will go up one by one a few hundred times) then when find and replace the matching data in an xml file. ... (4 Replies)
Discussion started by: sam.breslin
4 Replies

6. Shell Programming and Scripting

VI - Find and replace

Hi All, How can i replace a pattern where its with the pattern / To be more clear, this is what am trying to replace with Current pattern => /abc/xyz Replace to => /xyz/abc Giving the commad :%s/"/abc/xyz"/"/xyz/abc"/g throw me off. :wall: Awaiting for your assistance... (3 Replies)
Discussion started by: kusathy
3 Replies

7. Shell Programming and Scripting

Using records iteratively with increament

I am very new to unix. Trying to use a for loop for this task I have a file like this abc.uml ccc.uml ddd.uml rrr.uml kkk.uml . . . n.uml ( more than 10000) I want to read this file but just 5 names at a time and then again it should read next 5 names and agin next 5. this... (6 Replies)
Discussion started by: nnani
6 Replies

8. Shell Programming and Scripting

find and replace

Hi, I have to grep value from one file, if that value is already present with "#" symbol. I have to remove that symbol in that file. Ex: file1.txt contains the following string #value=15 I have to search for "Value". If I found the string with hash symbol, nee to remove the # in... (6 Replies)
Discussion started by: ckchelladurai
6 Replies

9. Shell Programming and Scripting

Find and replace

Hi , i have a file with some data and i need replace a perticular value with some other value from another another file req: file1.txt abc,idle.txt,1234 file2.txt 5678 now the requirement is need to replace the "idle.txt" is with "mike_5678" here 5678 from file2.txt... file2.txt... (1 Reply)
Discussion started by: dssyadav
1 Replies

10. Shell Programming and Scripting

Find and replace

Hi, I have a variable which holds the below value: echo $FROM_DIR /fsg/fgldevu/fs_ne/inst/FGLDEVU_01/logs/appl/conc/out/o14946708.out I want to change the value in the variable as below: out/o to be replaced with log/l .out to be replaced with .req The desired output should look like... (5 Replies)
Discussion started by: Prasannag87
5 Replies
RBASH(1)						      General Commands Manual							  RBASH(1)

NAME
rbash - restricted bash, see bash(1) RESTRICTED SHELL
If bash is started with the name rbash, or the -r option is supplied at invocation, the shell becomes restricted. A restricted shell is used to set up an environment more controlled than the standard shell. It behaves identically to bash with the exception that the follow- ing are disallowed or not performed: o changing directories with cd o setting or unsetting the values of SHELL, PATH, ENV, or BASH_ENV o specifying command names containing / o specifying a file name containing a / as an argument to the . builtin command o specifying a filename containing a slash as an argument to the -p option to the hash builtin command o importing function definitions from the shell environment at startup o parsing the value of SHELLOPTS from the shell environment at startup o redirecting output using the >, >|, <>, >&, &>, and >> redirection operators o using the exec builtin command to replace the shell with another command o adding or deleting builtin commands with the -f and -d options to the enable builtin command o using the enable builtin command to enable disabled shell builtins o specifying the -p option to the command builtin command o turning off restricted mode with set +r or set +o restricted. These restrictions are enforced after any startup files are read. When a command that is found to be a shell script is executed, rbash turns off any restrictions in the shell spawned to execute the script. SEE ALSO
bash(1) GNU Bash-4.0 2004 Apr 20 RBASH(1)
All times are GMT -4. The time now is 07:50 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy