Sponsored Content
Top Forums Shell Programming and Scripting Find and replace data in text file with data in same file Post 302379019 by timothyha22 on Wednesday 9th of December 2009 03:28:55 PM
Old 12-09-2009
Find and replace data in text file with data in same file

OK I will do my best to explain what I need help with.

I am trying to format an ldif file so I can import it into Oracle oid.

I need the file to look like this example. Keep in mind there are 3000 of these in the file.

Code:
 
changetype: modify
replace: userpassword 
dn: cn=4448322,cn=Users,dc=bennettware,dc=com
userpassword: {SHA}r+uU3mySUIISdVdTDvQxPRLdBFj5w=
-
replace: passwordexpiretime
passwordexpiretime: 20091031112231
-
replace: orclpassword
orclpassword: {x- orcldbpwd}1.0:83sdfdf24977D14AA
 
changetype: modify
replace: userpassword 
dn: cn=213333,cn=Users,dc=bennettware,dc=com
userpassword: {SHA}r+ukljasdfl;kjafdVdTDvQxPRLdBFj5w=
-
replace: passwordexpiretime
passwordexpiretime: 20091031112231
-
replace: orclpassword
orclpassword: {x- orcldbpwd}1.0:835sdff4977D14AA

I have it to this point. Please keep in mind sometimes the userpassword: encrypted pass is in different places in the string of each user. Notice the userpassword: enc pass is not under the dn: line.

Code:
changetype: modify
replace: userpassword
dn: cn=418322,cn=Users,dc=bennettware,dc=com
-
replace: orclpassword
userpassword: {SHA}B6UenM9qwerwerews3V5ve8H3H0=
orclpassword: {x- orcldbpwd}1.0:8359A824977D14AA
-
replace: passwordexpiretime
passwordexpiretime: 20091031112231

The long and short is I need to move the "userpassword: encryptep pass" up to directly under the dn field for each record. Is there anyway I can do this with awk or sed or something.

Any help would be greatly appreciated.

Tim

---------- Post updated at 03:28 PM ---------- Previous update was at 09:49 AM ----------

I found a work around.

Thanks for the consideration.

Tim

Last edited by zaxxon; 12-09-2009 at 10:50 AM.. Reason: code tags please
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Extracting data from text file based on configuration set in config file

Hi , a:) i have configuration file with pattren <Range start no>,<Range end no>,<type of records to be extracted from the data file>,<name of the file to store output> eg: myfile.confg 9899000000,9899999999,DATA,b.dat 9899000000,9899999999,SMS,a.dat b:) Stucture of my data file is... (3 Replies)
Discussion started by: suparnbector
3 Replies

2. Shell Programming and Scripting

Find lines in text file with certain data in first field

Hi all, Sorry for the title, I was unsure how to word my issue. I'll get right to the issue. In my text file, I need to find all lines with the same data in the first field. Then I need to create a file with the matching lines merged into one. So my original file will look something like... (4 Replies)
Discussion started by: rstev39147
4 Replies

3. Shell Programming and Scripting

Replace data of one column with data on other file corresponding to transaction ID matched

Hi All, I have two files one of which having some mobile numbers and corresponding value whose sample content as follows: 9058629605,8.0 9122828964,30.0 And in second file complete details of all mobile numbers and sample content as follows and delimeter used is comma(,): ... (8 Replies)
Discussion started by: poweroflinux
8 Replies

4. Shell Programming and Scripting

find string(s) in text file and nearby data, export to list help

Hi, So I'm kinda new to shell scripts and the like. I've picked up quite a bit of use from browsing the forums here but ran into a new one that I can't seem to find an answer for. I'm looking to parse/find a string AND the next 15 or so charachters that follow the string within a text file... (1 Reply)
Discussion started by: kar23me
1 Replies

5. Shell Programming and Scripting

Filter a .kml file (xml) with data set from text file

I have a .kml file. So I want filter the .kml to get only the tags that have this numeric codes that they are in a text file 11951 11952 74014 11964 11965 11969 11970 11971 11972 60149 74018 74023 86378 11976 11980 11983 11984 11987 (5 Replies)
Discussion started by: pcoj33
5 Replies

6. UNIX for Dummies Questions & Answers

Mapping a data in a file and delete line in source file if data does not exist.

Hi Guys, Please help me with my problem here: I have a source file: 1212 23232 343434 ASAS1 4 3212 23232 343434 ASAS2 4 3234 23232 343434 QWQW1 4 1134 23232 343434 QWQW2 4 3212 23232 343434 QWQW3 4 and a mapping... (4 Replies)
Discussion started by: kokoro
4 Replies

7. Shell Programming and Scripting

Replace data of a file with data from another file using shell scripting.

Dears, I'm new to shell scripting and i was wondering if you can help me with following matter. I have a file containing 400,000 records. The file contains two columns like: 00611291,0270404000005453 25262597,1580401000016155 25779812,1700403000001786 00388934,1200408000000880... (1 Reply)
Discussion started by: paniklas
1 Replies

8. Shell Programming and Scripting

Compare 2 text file with 1 column in each file and write mismatch data to 3rd file

Hi, I need to compare 2 text files with around 60000 rows and 1 column. I need to compare these and write the mismatch data to 3rd file. File1 - file2 = file3 wc -l file1.txt 58112 wc -l file2.txt 55260 head -5 file1.txt 101214200123 101214700300 101250030067 101214100500... (10 Replies)
Discussion started by: Divya Nochiyil
10 Replies

9. Shell Programming and Scripting

Modifying text file records, find data in one place in the record and print it elsewhere

Hello, I have some text data that is in the form of multi-line records. Each record ends with the string $$$$ and the next record starts on the next line. RDKit 2D 15 14 0 0 0 0 0 0 0 0999 V2000 5.4596 2.1267 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 ... (5 Replies)
Discussion started by: LMHmedchem
5 Replies

10. Shell Programming and Scripting

awk script to find data in three file and perform replace operation

Have three files. Any other approach with regards to file concatenation or splitting, etc is appreciated If column55(billngtype) of file1 contains YMNC or YPBC then pick the value of column13(documentnumber). Now find this documentnumber in column1(Billdoc) of file2 and grep the corresponding... (4 Replies)
Discussion started by: as7951
4 Replies
GIT-REPLACE(1)							    Git Manual							    GIT-REPLACE(1)

NAME
       git-replace - Create, list, delete refs to replace objects

SYNOPSIS
       git replace [-f] <object> <replacement>
       git replace [-f] --edit <object>
       git replace [-f] --graft <commit> [<parent>...]
       git replace -d <object>...
       git replace [--format=<format>] [-l [<pattern>]]

DESCRIPTION
       Adds a replace reference in refs/replace/ namespace.

       The name of the replace reference is the SHA-1 of the object that is replaced. The content of the replace reference is the SHA-1 of the
       replacement object.

       The replaced object and the replacement object must be of the same type. This restriction can be bypassed using -f.

       Unless -f is given, the replace reference must not yet exist.

       There is no other restriction on the replaced and replacement objects. Merge commits can be replaced by non-merge commits and vice versa.

       Replacement references will be used by default by all Git commands except those doing reachability traversal (prune, pack transfer and
       fsck).

       It is possible to disable use of replacement references for any command using the --no-replace-objects option just after git.

       For example if commit foo has been replaced by commit bar:

	   $ git --no-replace-objects cat-file commit foo

       shows information about commit foo, while:

	   $ git cat-file commit foo

       shows information about commit bar.

       The GIT_NO_REPLACE_OBJECTS environment variable can be set to achieve the same effect as the --no-replace-objects option.

OPTIONS
       -f, --force
	   If an existing replace ref for the same object exists, it will be overwritten (instead of failing).

       -d, --delete
	   Delete existing replace refs for the given objects.

       --edit <object>
	   Edit an object's content interactively. The existing content for <object> is pretty-printed into a temporary file, an editor is
	   launched on the file, and the result is parsed to create a new object of the same type as <object>. A replacement ref is then created
	   to replace <object> with the newly created object. See git-var(1) for details about how the editor will be chosen.

       --raw
	   When editing, provide the raw object contents rather than pretty-printed ones. Currently this only affects trees, which will be shown
	   in their binary form. This is harder to work with, but can help when repairing a tree that is so corrupted it cannot be pretty-printed.
	   Note that you may need to configure your editor to cleanly read and write binary data.

       --graft <commit> [<parent>...]
	   Create a graft commit. A new commit is created with the same content as <commit> except that its parents will be [<parent>...] instead
	   of <commit>'s parents. A replacement ref is then created to replace <commit> with the newly created commit. See
	   contrib/convert-grafts-to-replace-refs.sh for an example script based on this option that can convert grafts to replace refs.

       -l <pattern>, --list <pattern>
	   List replace refs for objects that match the given pattern (or all if no pattern is given). Typing "git replace" without arguments,
	   also lists all replace refs.

       --format=<format>
	   When listing, use the specified <format>, which can be one of short, medium and long. When omitted, the format defaults to short.

FORMATS
       The following format are available:

       o   short: <replaced sha1>

       o   medium: <replaced sha1> -> <replacement sha1>

       o   long: <replaced sha1> (<replaced type>) -> <replacement sha1> (<replacement type>)

CREATING REPLACEMENT OBJECTS
       git-filter-branch(1), git-hash-object(1) and git-rebase(1), among other git commands, can be used to create replacement objects from
       existing objects. The --edit option can also be used with git replace to create a replacement object by editing an existing object.

       If you want to replace many blobs, trees or commits that are part of a string of commits, you may just want to create a replacement string
       of commits and then only replace the commit at the tip of the target string of commits with the commit at the tip of the replacement string
       of commits.

BUGS
       Comparing blobs or trees that have been replaced with those that replace them will not work properly. And using git reset --hard to go back
       to a replaced commit will move the branch to the replacement commit instead of the replaced commit.

       There may be other problems when using git rev-list related to pending objects.

SEE ALSO
       git-hash-object(1) git-filter-branch(1) git-rebase(1) git-tag(1) git-branch(1) git-commit(1) git-var(1) git(1)

GIT
       Part of the git(1) suite

Git 2.17.1							    10/05/2018							    GIT-REPLACE(1)
All times are GMT -4. The time now is 06:46 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy