background preloader

The Command Line Crash Course Controlling Your Computer From The Terminal

The Command Line Crash Course Controlling Your Computer From The Terminal
Contents Preface I wrote this book really quickly as a way to bootstrap students for my other books. Many students don't know how to use the basics of the command line interface, and it was getting in the way of their learning. This book is designed to be something they can complete in about a day to a week and then get enough skill at the command line to graduate to other books. This book isn't a book about master wizardry system administration. Introduction: Shut Up And Shell This book is a crash course in using the command line to make your computer perform tasks. The only piece of advice I am going to give you is this: Shut up and type all of this in. Sorry to be mean, but that's what you have to do. You are not going to destroy your computer. Why? How To Use This Book The best way to use this book is to do the following: Just keep going through this process of doing an exercise, writing down questions you have, then going back through and answering the questions you can. License I (Zed A.

The %~dp0 Variable « Miscellaneous IT Pimpery The %~dp0 (that’s a zero) variable when referenced within a Windows batch file will expand to the drive letter and path of that batch file. The variables %0-%9 refer to the command line parameters of the batch file. %1-%9 refer to command line arguments after the batch file name. %0 refers to the batch file itself. If you follow the percent character (%) with a tilde character (~), you can insert a modifier(s) before the parameter number to alter the way the variable is expanded. The d modifier expands to the drive letter and the p modifier expands to the path of the parameter. Example: Let’s say you have a directory on C: called bat_files, and in that directory is a file called example.bat. In this case, %~dp0 (combining the d and p modifiers) will expand to C:\bat_files\. Check out this Microsoft article for a full explanation. Also, check out this forum thread.

Silly batch file tricks, redirecting stdout into an evironment variable and %~dp0 - Loren Halvorson's Blog Some things in batch files seem like they should be so simple, but I'm embarrassed to say how long it took to come up with this little trick. Maybe YOU knew it already, but you should have posted it in your blog so I could have googled it and been done in the 10 seconds it SHOULD have taken me to solve it :-) In case you ever have wanted to take the console output of a command line tool and capture it in an environment variable, this works. There may be better ways. Thanks to Scott Colestock for helping dig this one up. setlocalsometool.exe > temp.txtset /p TOOLOUTPUT= < temp.txtdel temp.txt..do something with %TOOLOUTPUT%...endlocal Of course when Monad comes out none of this monkey business will be necessary. Since I'm on the topic of useful/(or useless?) setlocal"%~dp0sometool.exe" > temp.txtset /p TOOLOUTPUT= < temp.txtdel temp.txt..do something with %TOOLOUTPUT%...endlocal

Related: