Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top
  1. Is there a command line bash's !$ (match last word of previous command)

  2. any shortcut to delete previous word. Ex: cd D:\programs\scrap .<ctrl+backspace> deletes the word 'scrap'

  3. Replace <br> tags with newlines in the output. I tried this:

    PS D:\program files\wamp\www\play> p .\delete.php | Foreach-Object {$_ -replace "<br>", "\n"}

    1310210455\n13101240552218 //OUTPUT

which does replace the
with \n , but it doesn't create a newline.just a plain text \n. Fix?

  1. cd d:\pro completes the directory name , but doesn't add a . Why? possible at all to fix it?

Thats all for now. powershell is really working for me now. Thanks

share|improve this question
up vote 3 down vote accepted

1) $$ will match the last token of the previous command. E.g.:

C:\PS> cd 'C:\Program Files'
C:\Program Files>$$
C:\Program Files
C:\Program Files>

2) <ctrl+backspace> will delete the previous word if you are using the PowerShell ISE, but the Windows console does not support deleting a previous word. You can run the ISE with the script pane hidden so there is only a command pane and output pane.

3) To put a newline in a string use `n. For your example:

PS D:\program files\wamp\www\play> p .\delete.php | Foreach-Object {$_ -replace "<br>", "`n"}

4) I'm not sure what your last question is. You say "but doesn't add a ." Is there something missing between the 'a' and the '.'? I'm assuming it's a '\'. If it is, you can add a backslash after the quote and continue to tab-complete. PowerShell will move the quote next time you tab. E.g.

cd c:\pro<tab> yields -> cd 'C:\Program Files' then,

cd 'C:\Program Files'\mic<tab> yields -> cd 'C:\Program Files\Microsoft'

share|improve this answer

You can also do:

gc myfile.txt | %{$_ -replace '$`r`n','MyValue'}

So, the above will remove the carriage return from the end of the line and replace it with MyValue

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.