Hints and tips on cmd
These are some helpful hints on various topics.
Capturing windows command output directly into clipboard
Windows command prompt is famous for plenty of disadvantages. One very annoying "feature" is that it breaks longer lines and if you want to copy them you need to manually glue them back. Here's one convenient way of capturing command output directly into clipboard: just type| clip
after the command. For example
netstat -an | clip
Now you can paste it in your favorite text editor.
/dev/null in Windows
Analogue for the /dev/null file on Windows is NUL. So the command
./my_prog 2>/dev/null
translates to
my_prog.exe 2>NUL
Getting full directory path in bash and cmd prompt
To get the absolute path for the current or any other realtively addressed folder, for example the parent, use the following constructs:
bash
parent_dir=`cd .. && pwd`
cmd
set current_dir=%CD%
cd ..
set parent_dir=%CD%
cd %current_dir%