09-25-2009
Adding strings to lines in a file
Hi all,
I have a positional text file that comes from some source application. Before it is processed by destination application I have to add some header (suffix) to every record(line) in the file.
e.g.
Actual File
...............
AccountDetails
AcNO Name Amount
1234 John 26578
5678 Mary 455
8767 Bush 3455
..............
So on..The first two lines are always the same and the number of records/lines below that vary. Now I have to add a header to each record/line in the above file (from 19 to 25 column positions and the final file shuld like this this)
...................
AccountDetails Header1
AcNO Name Amount Header2
1234 John 26578 Account
5678 Mary 455 Account
8767 Bush 3455 Account
.....................
The header is same from third line/record.I tried but only able to add same header for all lines (using awk print $1"Header1"). Unable to add different header to first two lines in the script. Can you please help?
Regards,
Sharath.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
I have a sql file and i need to extract the table names used in the sql file using a unix script. If i can extract the lines between the keywords 'FROM' and 'WHERE' in the file, my job is done. can somebody tell me how to do this using a shell script. If u can just let me know, how to... (2 Replies)
Discussion started by: babloo
2 Replies
2. UNIX for Dummies Questions & Answers
Hi all,
I'm very very new to UNIX and AWK world.Please help me in finding a solution for my problem.
I'm having a file like this
-----------------------------------------------------------------
~Version Information
VERS. 2.0: CWLS log ASCII Standard -VERSION 2.0
WRAP. ... (4 Replies)
Discussion started by: santyshyam
4 Replies
3. Shell Programming and Scripting
Well thanks a lot but I have another Problem
I try to solve.
I habe one simple Textfile
with entries like this, for example:
file1
file2
file3
file4
...
file200
And I want to add Strings at the beginning on the line.
Like this
word1 file1
word1 file2
...
I hope you can help me (3 Replies)
Discussion started by: Blackbox
3 Replies
4. Shell Programming and Scripting
I need some help with adding lines to file and substitute a pattern.
Ok I have a file:
#cat names.txt
name: John Doe
stationed: 1
name: Michael Sweets
stationed: 41
.
.
.
And would like to change it to:
name: John Doe
employed
permanently
stationed: 1-office (7 Replies)
Discussion started by: hemo21
7 Replies
5. Shell Programming and Scripting
Hi,
I have two files. 1st file has 1 column (huge file containing ~19200000 lines) and 2nd file has 2 columns (small file containing ~6000 lines).
#################################
huge_file.txt
a
a
ab
b
##################################
small_file.txt
a 1.5
b 2.5
ab ... (4 Replies)
Discussion started by: AshwaniSharma09
4 Replies
6. Shell Programming and Scripting
The question is not as simple as the title... I have a file, it looks like this
<string name="string1">RZ-LED</string>
<string name="string2">2.0</string>
<string name="string2">Version 2.0</string>
<string name="string3">BP</string>
I would like to check for duplicate entries of... (11 Replies)
Discussion started by: raidzero
11 Replies
7. UNIX for Dummies Questions & Answers
Dear All,
I have a file which contains a column with age, which is represented in two following patterns
1. "007/A" or ''007/a" or ''7 /a" ..... In this case A or a means year and I would like to extract only the numeric values eg 7 in the above case if this pattern exits in a line of file.... (5 Replies)
Discussion started by: pawannoel
5 Replies
8. Shell Programming and Scripting
test.txt:
appleboy
orangeletter
sweetdeal
catracer
conducivelot
I want to only grep out lines that contain "appleboy" AND "sweetdeal". however, the closest thing to this that i can think of is this:
cat test.txt | egrep "appleboy|sweetdeal"
problem is this only searches for all... (9 Replies)
Discussion started by: SkySmart
9 Replies
9. UNIX for Dummies Questions & Answers
Hello All,
this is my first post so I don't know if I am doing this right.
I would like to append entries from a series of strings (contained in a text file) consecutively at the end of specifically labeled lines in another file.
As an example:
- the file that contains the values to be... (3 Replies)
Discussion started by: gus74
3 Replies
10. Shell Programming and Scripting
I have a bunch of file numbers in the file 'test':
I'm trying the above command to change all the instances of "H" to "Na+" in the file testsds.pdb at the line numbers indicated in the file 'test'. I've tried the following and various similar alternatives but nothing is working:
cat test |... (3 Replies)
Discussion started by: crunchgargoyle
3 Replies
LEARN ABOUT OPENDARWIN
slapd-shell
SLAPD-SHELL(5) File Formats Manual SLAPD-SHELL(5)
NAME
slapd-shell - Shell backend to slapd
SYNOPSIS
/etc/openldap/slapd.conf
DESCRIPTION
The Shell backend to slapd(8) executes external programs to implement operations, and is designed to make it easy to tie an existing data-
base to the slapd front-end.
This backend is is primarily intended to be used in prototypes.
WARNING
This backend's calling conventions have changed since OpenLDAP 2.0. The abandon operation now gets a new "pid:" line. The "msgid:" lines
will be removed in a future version.
CONFIGURATION
These slapd.conf options apply to the SHELL backend database. That is, they must follow a "database shell" line and come before any subse-
quent "backend" or "database" lines. Other database options are described in the slapd.conf(5) manual page.
These options specify the pathname and arguments of the program to execute in response to the given LDAP operation. Each option is fol-
lowed by the input lines that the program receives:
abandon <pathname> <argument>...
ABANDON
msgid: <message ID of operation to abandon>
<repeat { "suffix:" <database suffix DN> }>
pid: <process ID of operation to abandon>
add <pathname> <argument>...
ADD
msgid: <message id>
<repeat { "suffix:" <database suffix DN> }>
<entry in LDIF format>
bind <pathname> <argument>...
BIND
msgid: <message id>
<repeat { "suffix:" <database suffix DN> }>
dn: <DN>
method: <method number>
credlen: <length of <credentials>>
cred: <credentials>
compare <pathname> <argument>...
COMPARE
msgid: <message id>
<repeat { "suffix:" <database suffix DN> }>
dn: <DN>
<attribute>: <value>
delete <pathname> <argument>...
DELETE
msgid: <message id>
<repeat { "suffix:" <database suffix DN> }>
dn: <DN>
modify <pathname> <argument>...
MODIFY
msgid: <message id>
<repeat { "suffix:" <database suffix DN> }>
dn: <DN>
<repeat {
<"add"/"delete"/"replace">: <attribute>
<repeat { <attribute>: <value> }>
-
}>
modrdn <pathname> <argument>...
MODRDN
msgid: <message id>
<repeat { "suffix:" <database suffix DN> }>
dn: <DN>
newrdn: <new RDN>
deleteoldrdn: <0 or 1>
<if new superior is specified: "newSuperior: <DN>">
search <pathname> <argument>...
SEARCH
msgid: <message id>
<repeat { "suffix:" <database suffix DN> }>
base: <base DN>
scope: <0-2, see ldap.h>
deref: <0-3, see ldap.h>
sizelimit: <size limit>
timelimit: <time limit>
filter: <filter>
attrsonly: <0 or 1>
attrs: <"all" or space-separated attribute list>
unbind <pathname> <argument>...
UNBIND
msgid: <message id>
<repeat { "suffix:" <database suffix DN> }>
dn: <bound DN>
Note that you need only supply configuration lines for those commands you want the backend to handle. Operations for which a command is
not supplied will be refused with an "unwilling to perform" error.
The commands - except abandon and unbind - should output:
RESULT
code: <integer>
matched: <matched DN>
info: <text>
where only RESULT is mandatory. The search RESULT should be preceded by the entries in LDIF format, each entry followed by a blank line.
Lines starting with `#' or `DEBUG:' are ignored.
EXAMPLE
There is an example search script in the slapd/back-shell/ directory in the OpenLDAP source tree.
LIMITATIONS
The shell backend does not support threaded environments. When using the shell backend, slapd(8) should be built --without-threads.
FILES
/etc/openldap/slapd.conf
default slapd configuration file
SEE ALSO
slapd.conf(5), slapd(8), sh(1).
OpenLDAP 2.1.X RELEASEDATE SLAPD-SHELL(5)