Lemme give a shot with explanin Scrutinizer code :
Code:
{
for(i=1; i<=NF; i++) { # for all fields in the line separated by field separator (in this case default FS space)
if($i~/^name="WorkJobNumber"/) # if field matches desired string
w=1 # create a variable w with value 1
if($i~/^value=/ && w) { # if field in the line matches '^value=' and w is defined (regular expression '^name="WorkJobNumber"' has been matched in the same line)
sub(/".*"/,"\"\"",$i) # substitute, in this case truncate, ..value.. with nothing.
w=0 # reset w for next line of input
}
}
}
1 # print everything
NF determines the number of fields per line.
Using that information, we can use i in a for loop with $ to evaluate each field string wise with our conditions. (NF is 4, so i is from 1 to 4, $1 being first field etc.)
awk considers record separator(RS) a line (if not stated otherwise).
So we introduce a w variable to process our conditions per line.
Everything is printed (again per line, if matched print changed if not print as is) as file is processed line by line.
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)
Hi,
I have a fixed width file.
The way this file works is say for example there are 30 columns in it each with different sizes say 10,5,2, etc...
If data in a field is less than the field size the rest of it is loaded with spaces.
I would like an awk command to that would replace
I have... (8 Replies)
here is what i want to achieve... consider a file contains below contents. the file size is large about 60mb
cat dump.sql
INSERT INTO `table1` (`id`, `action`, `date`, `descrip`, `lastModified`) VALUES (1,'Change','2011-05-05 00:00:00','Account Updated','2012-02-10... (10 Replies)
Hi
cat test.txt
H|123|341|567|asfg
D|dfg|trtyy|errt
D|ert|frty|wer
Here I need to replace the third column value with 100 of the first record only and while printing I need to print the full file content also..I am expecting a result like this
H|123|100|567|asfg
D|dfg|trtyy|errt... (3 Replies)
Hi
I know sed and awk has options to give range of line numbers, but
I need to replace pattern in specific lines
Something like
sed -e '1s,14s,26s/pattern/new pattern/' file name
Can somebody help me in this....
I am fine with see/awk/perl
Thank you in advance (9 Replies)
Hi All,
I already have a code which replaces column 14 of NPBR.XTR.tmp with column 8 of NPBR3G.XTR.final
awk -F'\|' 'FNR==NR{a= $2"^"$8;next;}a{split(a,b,"^");$8=b;$14=b;}1' OFS="|" ${SHTEMP}NPBR3G.XTR.final ${SHTEMP}NPBR.XTR.tmp > ${SHTEMP}NPBR.XTR.final
I also need to replace column 15... (2 Replies)
Hi,
In a file we have the following data like as below
abcdef="cfg-1-15"
bmmdda-g-45-2
yhdiao"rtg-1-df-34"
I need a sed/awk command to replace the above string with empty.
Thx, (1 Reply)
Hi Forum.
I'm trying to cleanup the following data elements (To remove any occurences of commas and any extra spaces) while preserving the <TAB> delimiter using awk gsub but I have not been successful.
Original Data:
4365 monte des source rue,, ,<TAB>trevost<TAB>QC
Desired Data:... (1 Reply)
I have a csv which has lot of columns . I was looking for an awk script which would extract a column twice. for the first occurance the header and data needs to be intact but for the second occurance i want to replace the header name since it a duplicate and extract year value which is in ddmmyy... (10 Replies)
Hello Everyone,
I have many files like so:
file1.txt
file2.txt
file3.txt
Within each file I have many lines of random text separated by commas like so:
abcAAA,123,defAA,456777,ghiA,789
jklB,101,mnoBBB,11211,pqrB,13111
stuCC,415,vwxCCCC,161,yzaC,718
I am trying to use SED or AWK to... (4 Replies)
Discussion started by: D3U5X
4 Replies
LEARN ABOUT OPENDARWIN
slurpd
SLURPD(8C)SLURPD(8C)NAME
slurpd - Standalone LDAP Update Replication Daemon
SYNOPSIS
/usr/libexec/slurpd [-d debug-level] [-f slapd-config-file] [-r slapd-replog-file] [-t temp-dir] [-o] [-k srvtab-file]
DESCRIPTION
Slurpd is used to propagate changes from one slapd database to another. If slapd is configured to produce a replication log, slurpd reads
that replication log and sends the changes to the slave slapd instances via the LDAP protocol. slurpd is typically invoked at boot time,
usually out of /etc/rc.local.
Upon startup, slurpd normally forks and disassociates itself from the invoking tty, then reads the replication log (given either by the
replogfile directive in the slapd config file, or by the -r command-line option). If the replication log file does not exist or is empty,
slurpd goes to sleep. It periodically wakes up and checks to see if there are any changes to be propoagated.
When slurpd notices that there are changes to propagate to slave slapd instances, it locks the replication log, makes its own private copy,
releases the lock, and forks one copy of itself for each replica slapd to be updated. Each child process binds to the slave slapd as the
DN given by the binddn option to the replica directive in the slapd config file, and sends the changes.
See slapd(8) for details on the standalone LDAP daemon.
Note that slurpd reads replication directive from slapd.conf(5), but uses ldap.conf(5) to obtain other configuration settings (such as TLS
settings).
OPTIONS -d debug-level
Turn on debugging as defined by debug-level. If this option is specified, even with a zero argument, slurpd will not fork or disas-
sociate from the invoking terminal. Some general operation and status messages are printed for any value of debug-level.
debug-level is taken as a bit string, with each bit corresponding to a different kind of debugging information. See <ldap.h> for
details.
-f slapd-config-file
Specifies the slapd configuration file. The default is /etc/openldap/slapd.conf.
-r slapd-replog-file
Specifies the name of the slapd replication logfile. Normally, the name of the replication log file is read from the slapd configu-
ration file. The file should be located in a directory with limited read/write/execute access. The -r option allows you to over-
ride this. In conjunction with the -o option, you can process a replication log file in a "one-shot" mode. For example, if slurpd
has encountered errors in processing a replication log, you can run it in one-shot mode and give the rejection file name as the
argument to the -r option, once you've resolved the problem which caused the replication to fail.
-o Run in "one-shot" mode. Normally, slurpd processes the replog file and then watches for more replication entries to be appended.
In one-shot mode, slurpd processes a replication log and exits.
-t temp-dir
slurpd copies the replication log to a working directory before processing it. The directory permissions should limit
read/write/execute access as temporary files may contain sensitive information. This option allows you to specify the location of
these temporary files. The default is /var/db/openldap/openldap-slurp.
-k srvtab-file
Specify the location of the kerberos srvtab file which contains keys for the replica slapd instances. Overrides the srvtab argument
to the replica directive in the slapd configuration file.
EXAMPLES
To start slurpd and have it fork and detach from the terminal and process the replication logs generated by slapd, just type:
/usr/libexec/slurpd
To start slurpd with an alternate slapd configuration file, and turn on voluminous debugging which will be printed on standard error, type:
/usr/libexec/slurpd -f /etc/openldap/slapd.conf -d 255
SEE ALSO ldap(3), ldap.conf(5), slapd.conf(5), slapd.replog(5), slapd(8)
"OpenLDAP Administrator's Guide" (http://www.OpenLDAP.org/doc/admin/)
ACKNOWLEDGEMENTS
OpenLDAP is developed and maintained by The OpenLDAP Project (http://www.openldap.org/). OpenLDAP is derived from University of Michigan
LDAP 3.3 Release.
OpenLDAP 2.1.X RELEASEDATE SLURPD(8C)