Change some string in specific column with space

Hello All of Master Script ,
i need help to solve my problem
before :

mount  /dev/rdsk/c1t69d0s6 /dev/rdsk/c1t69d0s6 /vol/cl123/PURGE1 ufs
mount  /dev/rdsk/c1t70d0s6 /dev/rdsk/c1t70d0s6 /vol/cl123/PURGE2 ufs

expected :

mount  /dev/dsk/c1t69d0s6 /dev/rdsk/c1t69d0s6 /PURGE1 ufs
mount  /dev/dsk/c1t70d0s6 /dev/rdsk/c1t70d0s6 /PURGE2 ufs

so i need to change column 2 (from /dev/rdsk/c1t69d0s6 -> /dev/dsk/c1t69d0s6)
and column 4 (from /vol/cl123/PURGE1 -> /PURGE1 )

words in column content special character "/"

how can i get that result.
what command should i use ?
sed / awk or other best command please suggest me.
thankyou..

Any attempts/ideas/thoughts from your side?

---------- Post updated at 20:10 ---------- Previous update was at 20:04 ----------

Howsoever, try

sed 's-rdsk-dsk-; s-/vol/cl123--' file
mount  /dev/dsk/c1t69d0s6 /dev/rdsk/c1t69d0s6 /PURGE1 ufs
mount  /dev/dsk/c1t70d0s6 /dev/rdsk/c1t70d0s6 /PURGE2 ufs

or

awk '{sub(/rdsk/, "dsk", $2) sub (/\/vol\/cl123/, "", $4)}1' file
mount /dev/dsk/c1t69d0s6 /dev/rdsk/c1t69d0s6 /PURGE1 ufs
mount /dev/dsk/c1t70d0s6 /dev/rdsk/c1t70d0s6 /PURGE2 ufs

What do you mean by

1 Like

Dear RudiC,
thankyou for your reply

Howsoever, try:

 sed 's-rdsk-dsk-; s-/vol/cl123--' file
mount  /dev/dsk/c1t69d0s6 /dev/rdsk/c1t69d0s6 /PURGE1 ufs
mount  /dev/dsk/c1t70d0s6 /dev/rdsk/c1t70d0s6 /PURGE2 ufs

it's work , can you explain me why with this command , the ouput on colum3 not changed as sed command. ("rdsk" become "dsk")?
does sed command only process the first word that matched with the command that we type?
or

 awk '{sub(/rdsk/, "ask", $2) sub (/\/vol\/cl123/, "", $4)}1' file
mount /dev/dsk/c1t69d0s6 /dev/rdsk/c1t69d0s6 /PURGE1 ufs
mount /dev/dsk/c1t70d0s6 /dev/rdsk/c1t70d0s6 /PURGE2 ufs

show an error after execute this (i'm using oracle solaris OS), any special symbol that we must input in solaris OS?

awk '{sub(/rdsk/, "dsk", $2) sub (/\/vol\/cl123/, "", $4)}1' file
awk: syntax error near line 1
awk: illegal statement near line 1
awk: syntax error near line 1
awk: bailing out near line 1

What do you mean by Quote:
words in column content special character "/"
it's mean on this sentence

/dev/rdsk/c1t69d0s6it

content of 3Three special character ("/")

A sed substitute command (without the g flag) only changes the first occurrence of the pattern on each line. If you add the g flag:

sed 's-rdsk-dsk-g; s-/vol/cl123--' file
mount  /dev/dsk/c1t69d0s6 /dev/dsk/c1t69d0s6 /PURGE1 ufs
mount  /dev/dsk/c1t70d0s6 /dev/dsk/c1t70d0s6 /PURGE2 ufs

all occurrences of rdsk would be changed to dsk . Note that your specified desired output only changed the 1st occurrence.

On Solaris/SunOS systems, always change awk to /usr/xpg4/bin/awk (or, when internationalized REs are not being used, as in this case, nawk ).