Replace a line with another string + Solaris

Hi,

In my /etc/ldap.conf , I have below entry

uri ldaps://pbs-mast.prd.prp.ia/ ldaps://dbs-mast.prd.prp.ia/

I want to replace it with -

uri ldaps://dbs-mast.prd.prp.ia/

I tried with awk, but due to / , it is giving error.
Thanks

1 Like

something along these lines:

echo 'uri ldaps://pbs-mast.prd.prp.ia/ ldaps://dbs-mast.prd.prp.ia/' | awk '/^uri ldaps:/{print $2}'

NOTE: use nawk on Solaris.

1 Like

It did the trick. Thanks

I must be missing something here. Why isn't the desired output produced by:

echo 'uri ldaps://pbs-mast.prd.prp.ia/ ldaps://dbs-mast.prd.prp.ia/' | nawk '/^uri ldaps:/{print $1,$2}'

You did say you wanted the uri at the start of the desired output didn't you?

Note that in addition to nawk , you could also use /usr/xpg4/bin/awk on a Solaris system. For some types of extended regular expression matching you would need to use /usr/xpg4/bin/awk , but for the EREs used in this example, either will work.

1 Like
awk '/^uri ldaps:/{print $2}'

hence you'll change *any* line with trailing uri ldaps: