I have lines
bpdppa301p.corpads.local 86929680 JC_UNIX_FS01_INCR JC_FS UNIX_FS01_INCR incr 02/24/2022 03/30/2022 03/30/2022 disk 1645678800 backup 84 MB /dbwsrp01/dbwsrp01 JCBDD1300P.corpads.local
bpdppa301p.corpads.local 82578060 MN_DB_ORA manual 02/24/2022 04/21/2022 03/31/2022 disk 1645678854 80 MB RMAN:PFDPRE01_jf0mjj9l_1_1 MNBDD3302P.corpads.local
bpdppa301p.corpads.local 86929880 JC_UNIX_FS01_INCR JC_FS UNIX_FS01_INCR Notincr 02/24/2022 03/30/2022 03/30/2022 disk 1645678800 backup 84 MB /dbwsrp01/dbwsrp01 JCBDD1300P.corpads.local
i am picking line by below code $mn=$line -csplit "incr|full|manual" but i also need way to capture which one was match incr or full or manual in a line. any idea ?
CodePudding user response:
Use ()
to capture the matched word, this will make PowerShell include it in the output from the split operation:
$mn = $line -csplit "(incr|full|manual)"
$mn[1] # this will now contain `incr`, `full` or `manual`