Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

want to delete a record from a file

Status
Not open for further replies.

masif

IS-IT--Management
Jun 6, 2002
2
PK
I have a users record file in plain text format , all users have same record entry except their usename and password , now i want to delete a specific record entry but when i try to delete a john entry it deletes both john and john12 entries , kindly tell me how can i achive my result


john Password = "john"
User-Service = Framed-User,
Framed-Protocol = PPP,
Ascend-Assign-IP-Pool = 1,
Ascend-Idle-Limit = 300

john12 Password = "john12"
User-Service = Framed-User,
Framed-Protocol = PPP,
Ascend-Assign-IP-Pool = 1,
Ascend-Idle-Limit = 300

shag Password = "shag"
User-Service = Framed-User,
Framed-Protocol = PPP,
Ascend-Assign-IP-Pool = 1,
Ascend-Idle-Limit = 300

a-a-scot Password = "xyz234"
User-Service = Framed-User,
Framed-Protocol = PPP,
Ascend-Assign-IP-Pool = 1,
Ascend-Idle-Limit = 300


[pc3]
 
Hi
In order to just find john, and not john12, in this case,
you could use "awk" to do the comparison. If I have a file
called filename with the following lines in it:

john
john1
john2
john21
john12
john44

then by running this:

cat filename | awk '{if ($1 == "john") print $0}'
will give me

john

it will not include the other entries as they do not
match "exactly".
You could incorporate this into a shell script and input the
entry to be deleted as a parameter of the script.
Hope this helps.

John (Really)
John Philcox
Mobile Ventures Limited UK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top