How do I pass $dir
and $file
, then concatenate them to a single path?
Output:
posh>
posh> pwsh ./worker.ps1
dir is /home/nicholas/powershell/regex a.log
file is
full is /home/nicholas/powershell/regex a.log/
posh>
library:
function SearchFile($dir,$file)
{
"dir is $dir"
"file is $file"
$full = [string]::Concat("full is ",$dir,"/",$file)
$full
#$pattern='(?=.*?foo)(?=.*?bar)'
#$string = Get-Content $full
#$result = $string | Select-String $pattern
#$result
}
worker:
. /home/nicholas/powershell/functions/library.ps1
$dir = "/home/nicholas/powershell/regex"
$file = "a.log"
SearchFile($dir,$file)
I seem to be passing an array of sorts for $dir
and nothing is getting assigned for $file
in SearchFile
as expected.