The equivalent is much more readable with PowerShell:
$shrimp = Get-Content menu.txt | Select-String 'shrimp' $price = $shrimp | ForEach-Object { $cols = $_ -split ' '; $cols[-1] } $under10 = [decimal]$price.Substring(1) -lt 10 if ( $under10 ) { 'Available!' } else { ':(' }
Of course, you can use aliases to make this a bit "shorter", but then we're back in the world of Unix, where precious bytes have to be saved to achieve acceptable performance on 300 baud Teletype terminals:
$p = gc menu.txt | sls 'shrimp' | % { $c = $_ -split ' '; $c[-1] } if ([decimal]$p.Substring(1) -lt 10) {'Available!'} else {':('}
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
The equivalent is much more readable with PowerShell:
$shrimp = Get-Content menu.txt | Select-String 'shrimp'
$price = $shrimp | ForEach-Object { $cols = $_ -split ' '; $cols[-1] }
$under10 = [decimal]$price.Substring(1) -lt 10
if ( $under10 ) { 'Available!' } else { ':(' }
Of course, you can use aliases to make this a bit "shorter", but then we're back in the world of Unix, where precious bytes have to be saved to achieve acceptable performance on 300 baud Teletype terminals:
$p = gc menu.txt | sls 'shrimp' | % { $c = $_ -split ' '; $c[-1] }
if ([decimal]$p.Substring(1) -lt 10) {'Available!'} else {':('}