Edit entry if not equal


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Edit entry if not equal
# 1  
Old 08-06-2008
Edit entry if not equal

Ok here's the scenario, i have a ll.conf file and masterlist.

#cat ll.conf
123456
banner 1234
abcdefghi

#cat masterlist
abcdefghi
banner 123456789

what script to change ll.conf banner 123456789 from banner 1234 if they are not equal.
the final output will looks like this.

#cat ll.conf
123456
banner 123456789
abcdefghi
# 2  
Old 08-06-2008
Code:
{
 read
 read banner num
} < masterlist
sed "s/^banner .*/banner $num" ll.conf

# 3  
Old 08-07-2008
sed: 0602-404 Function s/^banner .*/banner cannot be parsed. thanks for the effort but error,
# 4  
Old 08-07-2008
Quote:
Originally Posted by kenshinhimura
sed: 0602-404 Function s/^banner .*/banner cannot be parsed. thanks for the effort but error,

Sorry; typo:

Code:
{
 read
 read banner num
} < masterlist
sed "s/^banner .*/banner $num/" ll.conf

# 5  
Old 08-07-2008
thanks i got it, is it possible if we could not change it,like for exzample it will ask if we want to change it by pressing yes or no, then if they are equal it will pop a message "they are equal",if they are not it will me an option if i will change it or not.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to replace multiple "&nbsp;" entry with in <td> tag into single entry using sed?

I have the input file like this. Input file: 12.txt 1) There are one or more than one <tr> tags in same line. 2) Some tr tags may have one <td> or more tna one <td> tags within it. 3) Few <td> tags having "<td> &nbsp; </td>". Few having more than one "&nbsp;" entry in it. <tr> some td... (4 Replies)
Discussion started by: thomasraj87
4 Replies

2. How to Post in the The UNIX and Linux Forums

Help me, write a bash script to delete parent entry with all their child entry in LDAP UNIX server

Hi All, Please help me and guide me to write a bash/shell script on Linux box to delete parent entry with all their child entries. example: Parent is : ---------- dn: email=yogesh.kumar@wipro.com, o=wipro, o=in child is: ---------- dn: cn: yogesh kumar, email=yogesh.kumar@wipro.com,... (1 Reply)
Discussion started by: Chand
1 Replies

3. Shell Programming and Scripting

Plus edit and edit header

Dear Masters, i have a problem with unix script, till now i just know about how to create header. i want to change file below -63395.2 72653.5 -63361.3 72696.0 ... (9 Replies)
Discussion started by: ipatah
9 Replies

4. Shell Programming and Scripting

Not equal to in Unix

Guys, I am trying to do below operation LAST_TRANSACTION=2 if ]; then # do something fi If the LAST_TRANSACTION variable is not equal to 1 or 2 or 3 then code inside the if block should be execute. This code is not working, Any help is appreciated. (7 Replies)
Discussion started by: gowrishankar05
7 Replies

5. Shell Programming and Scripting

How to edit file to have one line entry?

Hello All, My file content is: DROP TABLE "FACT_WORLD"; CREATE TABLE "FACT_WORLD" ( "AR_ID" INTEGER NOT NULL, "ORG_ID" INTEGER NOT NULL ) DATA CAPTURE NONE COMPRESS YES; I want to change this file to have entries in one... (6 Replies)
Discussion started by: akash2508
6 Replies

6. Shell Programming and Scripting

Edit date entry inside a file

Hi All, I wanted to edit the date value located at /var/opt/CPsuite-R65/fw1/conf/local.scv. The date entry looks like this : :Signature (">=20100717") How can I update the date value by 1 day every other day while preserving the margins of the whole file in a shell script? I have... (5 Replies)
Discussion started by: achillesxv
5 Replies

7. Shell Programming and Scripting

while [ $x -ge 50 ] + and equal to zero ; then

while + and equal to zero ; then what to punt instead of phrase and equal to zero. it's bash thank you in advance (1 Reply)
Discussion started by: losh
1 Replies

8. Shell Programming and Scripting

shell script to edit file and delete entry

Can anyone provide me a shell script to edit a xml file and delete one entry. To do manually i can edit(vi editor) the file and 'dd' will delete the file.But I wiluld to know if I can do with a script. Thanks in advance Tannu (6 Replies)
Discussion started by: tannu
6 Replies

9. UNIX and Linux Applications

Edit/update an /etc/group database entry (c/c++)

Hello I'm writing a program for managing accounts and groups in a linux system. My problem is how to update the members of a group in the /etc/group file,if i have to add/remove those members. total 3 variables for adding some new members to the group : char **oldmembers=grp->gr_mem; ... (1 Reply)
Discussion started by: mekos
1 Replies
Login or Register to Ask a Question