03-22-2009
How can I append a string at the end of a line in a file
Hi, guys. I have one question:
I have a file called "group", the contents of it is below:
********************************
...
test:x:203:
sales:x:204:
repair:x:205:
research:x:206:brownj
...
***********
Now I want to add string ",sherrys" at the end of "research:x:206:brownj", so the result should be "research:x:206:brownj,sherrys".
My code is below:
added_string=",sherrys"
sed "s/research:x:206:*/&${added_string}/" group
However, it doesn't work properly, it gives this result "research:x:206:,sherrysbrownj"
Does anybody know how to fix my problem?
Thank you very much for your time in advance
-Keyang
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi
I need to append some text @ end of the first line in a file.
like
myfile.txt
list = a,b,c
list.a=some..
I give the arg "d" . now it append at end of first line
list=a,b,c,d
list.a=some...
Please help me out this (7 Replies)
Discussion started by: catgovind
7 Replies
2. Shell Programming and Scripting
Hi,
i want to append a character '|' at end of each line of a file abc.txt.
for example if the file abc.txt conatins:
a|b|c
1|2|33
w|2|11
i want result file xyz.txt
a|b|c|
1|2|33|
w|2|11|
I know this is simple but sumhow i am not able to reach end of line.
its urgent, thanks for... (4 Replies)
Discussion started by: muaz
4 Replies
3. Shell Programming and Scripting
Hi,
I want to get a Line count of a file and append that at the end of the file. The Line count should not include the Headers :
------------------
COL1,COL2,COL3
123,abc,011
111,abd,0212
Record Count: 2
-------------------
Thanks. (7 Replies)
Discussion started by: smc3
7 Replies
4. UNIX for Dummies Questions & Answers
I have a comma delimited text file and need to appened ",000000" to the end of every line. For example:
Before:
"D700000","2006" ,"5000","Open Year" ,"Conversion" ,"Wk64","Productive Payroll $" ,1103.45
After:
"D700000","2006" ,"5000","Open Year" ,"Conversion" ,"Wk64","Productive Payroll... (3 Replies)
Discussion started by: bggibson
3 Replies
5. Shell Programming and Scripting
Hi Friends, I have a file with many lines as shown below.
/START SAMPLE LINE/
M:\mmarimut_v6.4.0_pit_01\java\build.xml@@\main\v6.4.0_pit_a
M:\mmarimut_v6.4.0_pit_01\port\Post.java@@\main\v6.4.0_pit_a
M:\mmarimut_v6.4.0_pit_01\switchview\View.java@@\main\v6.4.0_pit_a
/END SAMPLE LINE/
I... (1 Reply)
Discussion started by: nmattam
1 Replies
6. Shell Programming and Scripting
Hi friends,
I have a file containing many lines as follows.
M:\mmarimut_v6.4.0_pit_01\java\build.xml@@\main\v6.4.0_pit_a
M:\mmarimut_v6.4.0_pit_01\ADBasicView.java@@\main\v6.4.0_pit_a
I would like to append the string "\0" at the end of each line in the file. The output should look... (10 Replies)
Discussion started by: nmattam
10 Replies
7. Shell Programming and Scripting
I have 2 files that I am working with
$ cat file1
server1
server3
server5
server6
server8
$ cat file2
server1;Solaris;
server2; SLES;
server3;Linux;
server4; Solaris;
server5;SLES;
server6;SLES;
server7;Solaris;
server8;Linux; (1 Reply)
Discussion started by: snoman1
1 Replies
8. Shell Programming and Scripting
Hi,
I have a File, which have multiple rows.
Like below
123456 Test1 FNAME JRW#$% PB MO Approver XXXXXX. YYYY
123457 Test2 FNAME JRW#$% PB MO Super XXXXXX. YYYY
123458 Test3 FNAME JRW#$% PB MO Approver XXXXXX. YYYY
I want to search a line which contains PB MO Approver and append... (2 Replies)
Discussion started by: java2006
2 Replies
9. Shell Programming and Scripting
Platform: Solaris 10
I have a file like below
$ cat languages.txt
Spanish
Norwegian
English
Persian
German
Portugese
Chinese
Korean
Hindi
Malayalam
Bengali
Italian
Greek
Arabic
I want to append the string " is a great language" at end of each line in this file. (3 Replies)
Discussion started by: omega3
3 Replies
10. UNIX for Advanced & Expert Users
hi,
i need a help in the script , need to append a string at the end of each line of a files , and append the files into a single file vertically.
eg
file1 has the following columns
abc,def,aaa
aaa,aa,aaa
files 2 has the following rows and columns
abc,def,aaa
aaa,aa,aaa
i... (3 Replies)
Discussion started by: senkerth
3 Replies
NDB(8) System Manager's Manual NDB(8)
NAME
query, mkhash, mkdb, cs, csquery, dns, dnsquery - network database
SYNOPSIS
ndb/query attr value [ rattr ]
ndb/mkhash file attr
ndb/cs [ -n ] [ -f dbfile ]
ndb/csquery
ndb/dns [ -s ] [ -f dbfile ]
ndb/dnsquery
ndb/mkdb
DESCRIPTION
The network database holds administrative information used by network programs such as bootp(8), ipconfig(8), con(1), etc.
Ndb/query searches the database for an attribute of type attr and value value. If rattr is not specified, all entries matched by the
search are returned. If rattr is specified, the value of the first pair with attribute rattr of all the matched entries is returned.
Ndb/mkhash creates a hash file for all entries with attribute attr in database file file. The hash files are used by ndb/query and by the
ndb library routines.
Ndb/cs is a server used by dial(2) to translate network names. Option -f supplies the name of the data base file to use, default
/lib/ndb/local. It is started at boot time. It finds out what networks are configured by looking for /net/*/clone when it starts. It can
also be told about networks by writing to /net/cs a message of the form:
add net1 net2 ...
Ndb/cs also sets the system name in /dev/sysname if it can figure it out. Option -n causes cs to do nothing but set the system name.
Ndb/csquery can be used to query ndb/cs to see how it resolves addresses. Ndb/csquery prompts for addresses and prints out what ndb/cs
returns.
Ndb/dns is a server used by ndb/cs and by remote systems to translate Internet domain names. Ndb/dns is started at boot time. By default
dns serves only requests written to /net/dns. Option -s causes the server to also answer domain requests sent to UDP port 53. Name reso-
lution is performed by searching the local database and by querying remote servers. The server for a domain is indicated by a database
entry containing both a dom and a ns attribute. For example, the entry for the Internet root is:
dom=
ns=ns.nic.ddn.mil
ns=kava.nisc.sri.com
ns=aos.brl.mil
The root of a domain subtree served by the local database is indicated by an entry with an soa attribute. For example, the AT&T research
domain is:
dom=research.att.com soa
mb=ches.research.att.com
ns=inet.research.att.com
ns=research.research.att.com
Here, the mb entry is the mail address of the person responsible for the domain (default postmaster). Wild-carded domain names can also be
used. For example, to specify a mail forwarder for all AT&T research systems:
dom=*.research.att.com
mx=research.att.com
Ndb/dnsquery can be used to query ndb/dns to see how it resolves requests. Ndb/dnsquery prompts for commands of the form
domain-name request-type
where request-type can be ip, mx, ns, cname, ptr.... In the case of the inverse query type, ptr, dnsquery will reverse the ip address and
tack on the .in-addr.arpa for you.
Ndb/mkdb is used in concert with awk(1) scripts to convert uucp systems files, IP host files, and Datakit configuration files into database
files. It is very specific to the situation at Murray Hill.
When the database files change underfoot, ndb/cs and ndb/dns track them properly. Nonetheless, to keep the database searches efficient it
is necessary to run ndb/mkhash whenever the files are modified. It may be profitable to control this by a frequent cron(8) job.
EXAMPLES
% ndb/query sys helix
sys=helix dom=helix.research.att.com bootf=/mips/9powerboot
ip=135.104.117.31 ether=080069020427
dk=nj/astro/helix
proto=il
% ndb/query sys helix ip
135.104.117.31
% ndb/dnsquery
> 9net.research.att.com ip
9net.research.att.com ip 192.20.225.252
> 192.20.225.252 ptr
252.225.20.192.in-addr.arpa ptr 9net.research.att.com
>
FILES
/lib/ndb/local
first database file searched
/lib/ndb/local.*
hash files for /lib/ndb/local
/srv/cs
service file for ndb/cs
/net/cs
where /srv/cs gets mounted
/srv/dns
service file for ndb/dns
/net/dns
where /srv/dns gets mounted
SOURCE
/sys/src/cmd/ndb
SEE ALSO
ndb(2) ndb(6)
NDB(8)