I have a bash script that put names, dates, and place in to a sample file. The code looks like this
#/bin/bash
if [ $# -ne 2 ]; then
echo You should give two parameters!
exit
fi
while read line
do
name=`echo $line | awk '{print $1}'`
date=`echo $line | awk '{print $2}'`
place=`echo $line | awk '{print $3}'`
echo `cat $1 | grep "<NAME>"| sed -e's/<NAME>/'$name'/g'`
echo `cat $1 | grep "<DATE>" | sed -e's/<DATE>/'$date'/g'`
echo `cat $1 | grep "<PLACE>" | sed -e's/<PLACE>/' $place'/g'`
echo
done < $2
I want to write it in powershel. This is my try:
if($args.count -ne 2)
{
write-host You should give two parameters!
return
}
$input = Get-Content $args[1]
$samplpe = Get-Content $args[0]
foreach($line in $input)
{
name= $line | %{"$($_.Split('\t')[1])"}
date= $line | %{"$($_.Split('\t')[2])"}
place= $line | %{"$($_.Split('\t')[3])"}
write-host cat $sample | Select-String [-"<NAME>"] | %{$_ -replace "<NAME>", "$name"}`
write-host cat $sample | Select-String [-"<NAME>"] | %{$_ -replace "<DATE>", "$date"}
write-host cat $sample | Select-String [-"<NAME>"] | %{$_ -replace "<PLACE>", "$place"}
}
But it's dosent work, but i dont know why :S