Need to change two words in a line using shell script.

Hi,
i have a line

tftp          dgram   udp      wait    nobody  /usr/sbin/tcpd  in.tftpd  /tftpboott

in /etc/inet.conf file. ineed to replace nobody with root and /tftpboott with /flx/boot. i tried using sed ,but i could not change both of them. can you please help me to do this.

Edit: Next time use

```text
 and 
```

tags when displaying code, data or logs etc. to enhance readability and preserve formatting like indention etc., ty.

sed 's/\/tftpboott/\/flx\/boot/; s/nobody/root/'

This will replace nobody to root in other lines also,but i want to replace nobody to root in those lines containing /tftpboott

That's true. Try this:

sed '/tftpboott/ { s/\/tftpboott/\/flx\/boot/; s/nobody/root/}' infile
sed '/nobody.*\/tftpboott$/ { s/\/tftpboott/\/flx\/boot/; s/nobody/root/}' /etc/inet.conf

i think this is more secure

Is it possible to change only the first line which has tftpd leaving other lines which may have tftpd.can u pls share the code snippet and can i pass the pattern to be replaced by a variable?

Post an your complete example of your input so we don't have to guess around and mark the line you want to have to be changed. Use

```text
 and 
```

tags when doing so, thank you!

Assume the file has

tftp          dgram   udp      wait    nobody  /usr/sbin/tcpd  in.tftpd  /tftpboott
tftp          dgram   udp      wait    anybody  /usr/sbin/tcpd  in.tftpd  /tftpdboott
.
.

i want to change 5th and 8th field of lines matching in.tftd,if 5th and 8th fields are not root and /flx/boot respectively.