Reputation: 26382
I keep getting the following error when running a command to look for the most recently modified directory in my path: remotely from PowerShell:
head: The term 'head' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line 1: char: 95
+ ... d /somedir ; (lastmod=$(ls -tda -- */ | head -n 1); ....
I'm running code something along the lines of the following:
& plink "bob@server" "cd /somedir ; (lastmod=$(ls -tda -- */ | head -n 1); ls -la $lastmod)"
Upvotes: 0
Views: 138
Reputation: 754
Just to add on to Bruce's answer, you could also escape the special character from your double-quoted string using the grave accent (`), which is the escape character in powershell.
& plink "bob@server" "cd /somedir ; (lastmod=$(ls -tda -- */ `| head -n 1); ls -la $lastmod)"
This means that if you did need any variables inside of your string, you could still utilize special characters.
Upvotes: 0
Reputation: 2629
You've encapsulated your commands in double-quotes so the $
signs are being expanded by PowerShell. If you use single quotes this won't happen.
Upvotes: 2