1 2 3 4 5 6 7 8 9 10 11 |
1..15 | foreach { $index = $_.ToString() if ($index.Length -eq 1) { $index = "0$index" } $fileName = "usridx$index.dbf" #file name $file = "/u01/oradata/DB1/$fileName" #file full path $symlink = "/u00/oradata/DB1/$fileName" #symlink write-host "touch $file && ln -s $file $symlink" } |
Output:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
PS C:\Users\strachotao> C:\Temp\oracle1.ps1 touch /u01/oradata/DB1/usridx01.dbf && ln -s /u01/oradata/DB1/usridx01.dbf /u00/oradata/DB1/usridx01.dbf touch /u01/oradata/DB1/usridx02.dbf && ln -s /u01/oradata/DB1/usridx02.dbf /u00/oradata/DB1/usridx02.dbf touch /u01/oradata/DB1/usridx03.dbf && ln -s /u01/oradata/DB1/usridx03.dbf /u00/oradata/DB1/usridx03.dbf touch /u01/oradata/DB1/usridx04.dbf && ln -s /u01/oradata/DB1/usridx04.dbf /u00/oradata/DB1/usridx04.dbf touch /u01/oradata/DB1/usridx05.dbf && ln -s /u01/oradata/DB1/usridx05.dbf /u00/oradata/DB1/usridx05.dbf touch /u01/oradata/DB1/usridx06.dbf && ln -s /u01/oradata/DB1/usridx06.dbf /u00/oradata/DB1/usridx06.dbf touch /u01/oradata/DB1/usridx07.dbf && ln -s /u01/oradata/DB1/usridx07.dbf /u00/oradata/DB1/usridx07.dbf touch /u01/oradata/DB1/usridx08.dbf && ln -s /u01/oradata/DB1/usridx08.dbf /u00/oradata/DB1/usridx08.dbf touch /u01/oradata/DB1/usridx09.dbf && ln -s /u01/oradata/DB1/usridx09.dbf /u00/oradata/DB1/usridx09.dbf touch /u01/oradata/DB1/usridx10.dbf && ln -s /u01/oradata/DB1/usridx10.dbf /u00/oradata/DB1/usridx10.dbf touch /u01/oradata/DB1/usridx11.dbf && ln -s /u01/oradata/DB1/usridx11.dbf /u00/oradata/DB1/usridx11.dbf touch /u01/oradata/DB1/usridx12.dbf && ln -s /u01/oradata/DB1/usridx12.dbf /u00/oradata/DB1/usridx12.dbf touch /u01/oradata/DB1/usridx13.dbf && ln -s /u01/oradata/DB1/usridx13.dbf /u00/oradata/DB1/usridx13.dbf touch /u01/oradata/DB1/usridx14.dbf && ln -s /u01/oradata/DB1/usridx14.dbf /u00/oradata/DB1/usridx14.dbf touch /u01/oradata/DB1/usridx15.dbf && ln -s /u01/oradata/DB1/usridx15.dbf /u00/oradata/DB1/usridx15.dbf |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
$files = @{ "/u00/oradata/DB1/redo01.log"="/u06"; "/u00/oradata/DB1/redo02.log"="/u06"; "/u00/oradata/DB1/redo03.log"="/u06"; "/u00/oradata/DB1/redo04.log"="/u06"; "/u00/oradata/DB1/system01.dbf"="/u06"; "/u00/oradata/DB1/sysaux01.dbf"="/u06"; "/u00/oradata/DB1/undo01.dbf"="/u06"; "/u00/oradata/DB1/data01.dbf"="/u06"; "/u00/oradata/DB1/data02.dbf"="/u06"; "/u00/oradata/DB1/data03.dbf"="/u06"; "/u00/oradata/DB1/data04.dbf"="/u06"; "/u00/oradata/DB1/data05.dbf"="/u06"; "/u00/oradata/DB1/data06.dbf"="/u06"; "/u00/oradata/DB1/data07.dbf"="/u06"; "/u00/oradata/DB1/data08.dbf"="/u06"; "/u00/oradata/DB1/data09.dbf"="/u06"; "/u00/oradata/DB1/data10.dbf"="/u06"; "/u00/oradata/DB1/data11.dbf"="/u06"; "/u00/oradata/DB1/data12.dbf"="/u06"; "/u00/oradata/DB1/data13.dbf"="/u06"; "/u00/oradata/DB1/data14.dbf"="/u06"; "/u00/oradata/DB1/rbs01.dbf"="/u06"; "/u00/oradata/DB1/temp01.dbf"="/u06"; "/u00/oradata/DB1/temp02.dbf"="/u06" } $instanceName = "DB1"; $files.GetEnumerator() | Foreach-Object { $file = $_.Key $targetFs = $_.Value $leaf = Split-Path $file -Leaf Write-Host "touch $targetFs/oradata/$instanceName/$leaf && ln -s $targetFs/oradata/$instanceName/$leaf $file" } |
Output:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
touch /u06/oradata/DB1/data02.dbf && ln -s /u06/oradata/DB1/data02.dbf /u00/oradata/DB1/data02.dbf touch /u06/oradata/DB1/data03.dbf && ln -s /u06/oradata/DB1/data03.dbf /u00/oradata/DB1/data03.dbf touch /u06/oradata/DB1/temp01.dbf && ln -s /u06/oradata/DB1/temp01.dbf /u00/oradata/DB1/temp01.dbf touch /u06/oradata/DB1/redo03.log && ln -s /u06/oradata/DB1/redo03.log /u00/oradata/DB1/redo03.log touch /u06/oradata/DB1/data11.dbf && ln -s /u06/oradata/DB1/data11.dbf /u00/oradata/DB1/data11.dbf touch /u06/oradata/DB1/data09.dbf && ln -s /u06/oradata/DB1/data09.dbf /u00/oradata/DB1/data09.dbf touch /u06/oradata/DB1/data07.dbf && ln -s /u06/oradata/DB1/data07.dbf /u00/oradata/DB1/data07.dbf touch /u06/oradata/DB1/data06.dbf && ln -s /u06/oradata/DB1/data06.dbf /u00/oradata/DB1/data06.dbf touch /u06/oradata/DB1/temp02.dbf && ln -s /u06/oradata/DB1/temp02.dbf /u00/oradata/DB1/temp02.dbf touch /u06/oradata/DB1/redo01.log && ln -s /u06/oradata/DB1/redo01.log /u00/oradata/DB1/redo01.log touch /u06/oradata/DB1/data01.dbf && ln -s /u06/oradata/DB1/data01.dbf /u00/oradata/DB1/data01.dbf touch /u06/oradata/DB1/redo04.log && ln -s /u06/oradata/DB1/redo04.log /u00/oradata/DB1/redo04.log touch /u06/oradata/DB1/data04.dbf && ln -s /u06/oradata/DB1/data04.dbf /u00/oradata/DB1/data04.dbf touch /u06/oradata/DB1/data10.dbf && ln -s /u06/oradata/DB1/data10.dbf /u00/oradata/DB1/data10.dbf touch /u06/oradata/DB1/data05.dbf && ln -s /u06/oradata/DB1/data05.dbf /u00/oradata/DB1/data05.dbf touch /u06/oradata/DB1/data08.dbf && ln -s /u06/oradata/DB1/data08.dbf /u00/oradata/DB1/data08.dbf touch /u06/oradata/DB1/rbs01.dbf && ln -s /u06/oradata/DB1/rbs01.dbf /u00/oradata/DB1/rbs01.dbf touch /u06/oradata/DB1/system01.dbf && ln -s /u06/oradata/DB1/system01.dbf /u00/oradata/DB1/system01.dbf touch /u06/oradata/DB1/redo02.log && ln -s /u06/oradata/DB1/redo02.log /u00/oradata/DB1/redo02.log touch /u06/oradata/DB1/data12.dbf && ln -s /u06/oradata/DB1/data12.dbf /u00/oradata/DB1/data12.dbf touch /u06/oradata/DB1/data13.dbf && ln -s /u06/oradata/DB1/data13.dbf /u00/oradata/DB1/data13.dbf touch /u06/oradata/DB1/sysaux01.dbf && ln -s /u06/oradata/DB1/sysaux01.dbf /u00/oradata/DB1/sysaux01.dbf touch /u06/oradata/DB1/data14.dbf && ln -s /u06/oradata/DB1/data14.dbf /u00/oradata/DB1/data14.dbf touch /u06/oradata/DB1/undo01.dbf && ln -s /u06/oradata/DB1/undo01.dbf /u00/oradata/DB1/undo01.dbf |