Basic Command Line: Not So Interesting

So the past couple of blogs about this computer stuff has been useful, I showed how to write your own data backup script and how to launch a plethora of programs in two clicks. Now, I need to get to the boring stuff, teaching basic command principles. I’ll try to make this kind of stuff brief, since most people don’t really need it anyway.

So let’s start with the basics of file system navigation. We’ll need to know just a few things about how to get around directories from a command prompt.

cd – Literally stands for “change directory”, this allows you to any folder or directory you type in. cd’s syntax looks like this.

C:\User>cd Pictures

C:\User\Pictures>

.. – That’s right, just two periods .. , this indicates you’d like to go back one directory. ..’s syntax would be…

C:\User\Pictures>..

C:\User>

dir – Means directory, will print a somewhat readable output of all files and folders in the directory. Dir’s syntax looks like..

C:\User>dir

12/20/2007 01:12PM  <DIR>                        Contacts

Now as you might guess, the <DIR> means that item is a directory, so you can cd into that, actual files will have the suffixes (.jpg, .gif, .exe, etc.), and will not have the <DIR> indicator in the list.

The command prompt has something called auto-completion, by typing in a few letters of a word and hitting tab, the shell will automatically complete the word if possible. For instance:

C:\User>dir

date time <dir>     ridiculouslylongfoldernamethatIwouldneverwanttotypeagain

C:\User>cd ridi

Now, hitting the tab key…

C:\User>cd ridiculouslylongfoldernamethatIwouldneverwanttotypeagain

Would automatically complete the stupidly long name for you, once you get good at cd’ing and auto-completion, you can navigate faster than what you can with a mouse.

Also, don’t forget, when cd’ing, if folder names have spaces, you MUST use quotation marks.

C:\User>cd “C:\Documents\Some Folder”

or

C:\User>cd “Documents and Settings”  <- Only if this folder is in the current directory, auto-completion will quote it for you.

Also, if you just type in cd and then put a space and start hitting tab, it will cycle through possible directory changing choices.

It’s fairly late, so I won’t go into file manipulation, that’s for next time. This was a nice short post and should be extremely simple to understand. If you’re asking, “why learn the basics?”, it’s fairly simple, it’s the basis of scripting, once you know about syntax, arguments and parameter passing, writing correct and working scripts the first time is much easier.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: