---------- 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
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
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 ).