terminal - Is there a !$ equivalent in powershell? -
is there !$ equivalent in powershell? essentially, i'd able use command
mv *.txt ~\documents
and able use like
cd !$
and should take me documents folder specified in previous command. use time in linux , bugs me it's not in powershell.
thanks!
edit: when using $$ following error
ps c:\users\josh.howard\desktop\test> mv *.mp 'c:\program files\landesk\managementsuite\ldscan' ps c:\users\josh.howard\desktop\test> cd $$ cd : cannot find drive. drive name ''c' not exist. @ line:1 char:1 + cd $$ + ~~~~~ + categoryinfo : objectnotfound: ('c:string) [set-location], drivenotfoundexception + fullyqualifiederrorid : drivenotfound,microsoft.powershell.commands.setlocationcommand
about_automatic_variables has immediate answer looking here.
$$
contains last token in last line received session.
in practice should have worked.
ps c:\users\josh.howard\desktop\test> mv *.mp 'c:\program files\landesk\managementsuite\ldscan' ps c:\users\josh.howard\desktop\test> cd $$
however in case there problem embedded quotes of token.
cd : cannot find drive. drive name ''c' not exist.
i able replicate issue using powershell v4. when sent quoted string cmdlet set-location
parser consume quotes send full path parameter path
. using $$
test case sending unescaped quoted string! why removing them make process work.
cd ($$.trim("'"))
bill stewart has process address issue well.
it possible has been addressed in v5 cannot confirm exact situation.
so tested in windows 10 , seems work there, not in version 4. seems have been fixed long on newer 4.
Comments
Post a Comment