I have written a following script to sort file content based on some column.
$lines = Get-Content $inputFile
foreach($line in $lines){
if($line.startsWith('*') -or $line.startsWith('-')){
continue
}
if(($line -eq $lines[0]) -or ($line -eq $lines[1]) -or ($line -eq $lines[2])){
Sort-Object { $line.Substring(70,9) } | set-content $outputFile
}
}
input file content:
...header row...
...header row...
...header row...
4
2
1
....trailor.....
Desired Output:
...header row...
...header row...
...header row...
1
2
3
....trailor.....
In my input file, I have first three lines as header and Lat line as trailer. I want to skip these lines while sorting. I tried to use above script. But it's not skipping those lines. Can someone correct me for this?