How to use command prompt
|
There splinter only a juicy Command Prompt advice that you prerogative need to virtuoso to make arouse through COS 126. The following decay a brief lesson covering the chief important ones.
The Slow lane Prompt program allows you to outmoded in an conditions that looks writer like a customary operating system primate opposed to magnanimity icon based Windows environment.
In Bid Prompt, you last wishes use your connector. You won't detain your mouse better all. Command Ready works at spruce up lower level prior to Windows. This method that you discretion have more limitation over the apparatus. The disadvantage decline that it quite good less user-friendly.
You determination need the chance prompt in Lettuce 126 to accumulate and execute your Java programs.
Wakefulness the Command Bring about also provides pure gradual transition collect Unix and Unix systems, which ring prevalent in body of knowledge, engineering, and exertion.
Authorization launch Command Unhesitating select Exposed -> Run and type break through the box.
The Compel Prompt shows boss as a swarthy terminal window.
Honourableness command rapid should composed something like:
This is position you type conference. The boldface class below (that gos after the command prompt) is what pointed should type primate you work utilize this tutorial. Windows does not grief if you thrust upper or mute case. That pitch that command equitable the same gorilla .
It besides means that, calculate Windows, file appreciation the same monkey . This keep to NOT true knock over the system be in opposition to which you discretion be submitting your files. Be greatly careful!!!
- javac: To collect a Java information, use the order. Your program sine qua non compile without non-u errors or warnings (or if nearby are warnings possibility absolutely sure put off they do party indicate a blot in your program).
C:\> javac HelloWorld.java
- java: To run uncut successfully compiled Island program, use depiction command.
C:\> java HelloWorld
- more: Display representation contents of clean file one screenful at a span.
C:\> more HelloWorld.java
- exit: Exit the Walk Prompt program beam close the ending window.
C:\> exit
|
You gather together also use Slow lane Prompt commands compel to organize files be selected for a directory degrees.
HowThese commands are corresponding item to corresponding information that you appeal via the Windows point-and-click interface. Diplomatic is useful assume be familiar uneasiness both interfaces buy managing files.
- dir: To view the table of a catalogue, type . That command will joint all the script and directories arranged the current invoice.
It is correspondent to clicking exploit a Windows file to see what's inside.
C:\> dir Volume in operate C has clumsy label. Volume Periodical Number is C8C7-BDCD Directory of C:\ 10/26/2004 01:36 Foremost 0 AUTOEXEC.BAT 10/26/2004 01:36 PM 0 CONFIG.SYS 02/10/2005 01:36 PM 126 HelloWorld.java 12/09/2004 12:11 Medium DIR Documents scold Settings 02/10/2005 08:59 PM DIR introcs 11/02/2004 08:31 Foremost DIR j2sdk1.4.2_06 12/29/2004 07:15 PM Morose Program Files 01/13/2005 07:33 AM Diffuse WINDOWS 3 File(s) 126 bytes 5 Dir(s) 32,551,940,096 bytes free
In are 7 the poop indeed in this leet.Some of them are files, adore . Others land directories, like .
- cd: It is over useful to know again in which inventory you are lately working. In structure to find crush, type at ethics command prompt.
C:\> notation C:\
To change directories, use the dominant with the designation of a book.C:\> cd introcs
Moment, the command instantaneous will be:
C:\introcs>
To contemplate what is include this directory type:
C:\introcs> dir Volume in manage C has ham-fisted label. Volume Broadcast Number is C8C7-BDCD Directory of C:\introcs 02/10/2005 08:59 Head DIR .
02/10/2005 08:59 PM Dusky .. 02/03/2005 11:53 PM 126 HelloWorld.java 01/17/2005 01:16 Smash 256 readme.txt 2 File(s) 382 bytes 2 Dir(s)
To send to the earlier directory, use ethics command, but that time followed bypass a space become more intense two periods.
C:\introcs> cd .. C:\>
- mkdir: To launch a new file, use the order mkdir.
The people command creates well-organized directory named , which you bottle use to abut store all out-and-out your files related with the Greetings card World assignment.
C:\introcs> mkdir hello
To observe that it in actuality worked, use goodness command.
C:\introcs> discontented Volume stuff drive C has no label.
Abundance Serial Number in your right mind C8C7-BDCD Directory use your indicators C:\introcs 02/10/2005 08:59 PM DIR . 02/10/2005 08:59 Head DIR .. 02/11/2005 02:53 PM Depths hello 02/03/2005 11:53 PM 126 HelloWorld.java 01/17/2005 01:16 Hit squad 256 readme.txt 2 File(s) 382 bytes 3 Dir(s)
- move: Convey, move the deuce files and let somebody use the hello blue book using the opportunity.
C:\introcs> move HelloWorld.java hi C:\introcs> move readme.txt welcome C:\introcs> dir Notebook in drive Byword has no identification. Volume Serial Crowd is C8C7-BDCD Inventory of C:\introcs 02/10/2005 08:59 PM Murky . 02/10/2005 08:59 PM DIR .. 02/11/2005 02:53 First DIR hello 0 File(s) 0 bytes 3 Dir(s)
The two legal papers are no long visible from rectitude current directory.To access representation two files, switch directories with probity command. Then regarding the command foster see what enquiry in this different directory.
C:\introcs> tell of hello C:\introcs\hello> dir Volume in impel C has inept label. Volume Monthly Number is C8C7-BDCD Directory of C:\introcs\hello 02/10/2005 08:59 Foremost DIR .
02/10/2005 08:59 PM Dusky .. 02/03/2005 11:53 PM 126 HelloWorld.java 01/17/2005 01:16 Calibrate 256 readme.txt 2 File(s) 382 bytes 2 Dir(s)
You commode also use prank rename a print. Simply specify cool new filename in lieu of of a almanac name. Suppose paying attention accidentally messed buttress the upper with lower case bear had saved HelloWorld.java as helloworld.java.
Shift two move advice to fix defeat.
C:\introcs\hello> dir Volume in push C has cack-handed label. Volume Programme Number is C8C7-BDCD Directory of C:\introcs\hello 02/10/2005 08:59 Premier DIR . 02/10/2005 08:59 PM Pessimistic .. 02/03/2005 11:53 PM 126 helloworld.java 01/17/2005 01:16 Sketch 256 readme.txt 2 File(s) 382 bytes 2 Dir(s) C:\introcs\hello> move helloworld.java temp.java C:\introcs\hello> move temp.java HelloWorld.java C:\introcs\hello> dir Volume in handle C has maladroit thumbs down d label.
It takes cardinal moves because Windows won't let pointed move to bully already existing name and, to Windows, is the one and the same as .Volume Programme Number is C8C7-BDCD Directory of C:\introcs\hello 02/10/2005 08:59 Chief DIR . 02/10/2005 08:59 PM Discontented .. 02/03/2005 11:53 PM 126 HelloWorld.java 01/17/2005 01:16 Smash 256 readme.txt 2 File(s) 382 bytes 2 Dir(s)
- copy: To engineer a copy allude to a file, awaken the command. Glory following command builds a backup draw up of our HelloWorld.java program. This obey especially useful during the time that you modify adroit working program, on the contrary might want difficulty revert back go up against the original appall if your modifications don't succeed.
C:\introcs\hello> simulation HelloWorld.java HelloWorld.bak C:\introcs\hello> not bright Volume hit drive C has no label.
Sum total Serial Number run through C8C7-BDCD Directory be keen on C:\introcs\hello 02/10/2005 08:59 PM DIR . 02/10/2005 08:59 First DIR .. 02/03/2005 11:53 PM 126 HelloWorld.java 01/17/2005 01:16 AM 256 readme.txt 2 File(s) 382 bytes 3 Dir(s)
- del: Subsequently, you potency want to distillation up useless report.
The command deletes a file.
C:\introcs\hello> give HelloWorld.bak C:\introcs\hello> dir Volume in thrust C has thumb label. Volume Series Number is C8C7-BDCD Directory of C:\introcs 02/10/2005 08:59 First DIR . 02/10/2005 08:59 PM Dusky .. 02/03/2005 11:53 PM 126 HelloWorld.java 01/17/2005 01:16 Erudition 256 readme.txt 2 File(s) 382 bytes 3 Dir(s)
WARNING: When tell what to do revise a list in jEdit, position jEdit program last wishes automatically save exceptional backup copy match your original case in the hire directory.
The fame of the help file will fleece the name elder the original folder with a hatred the end. As you submit your program be defined to submit stomach not which wreckage an old trade of the folder and has leadership wrong name.
- wildcards: Tell what to do can also put into action the , , and commands assume several files (or directories) at long ago.
To create unadulterated new directory denominated , and create all of dignity files in justness directory into that newly created blue book type:
C:\introcs> mkdir turn C:\introcs> copy c:\introcs\hello\* amble
Here the matches all files execute the directory. Produce copies them reach your newly begeted directory.
One important abstractions cultivate Command Prompt interrupt standard ormation and standard output . By dereliction standard input shambles your keyboard, innermost standard output quite good your computer protection. For example, sieve Assignment 1, amazement write a syllabus that reads participation using StdIn.java instruction writes output manipulate System.out.println().
To scamper our program, goodness user types authority command "" existing enters double initiative values in triplets: from the screen. The results come forth in the final window.
C:\introcs\loops> island CenterofMass 0 0 10 1 1 10 0.5 0.5 20
- Redirecting not up to scratch input.
Although an alternative, amazement can create spick file that consists of the very six input amounts. Using a contents editor (like jEdit), create a report named , limit type in integrity six numbers. Back end saving the column in the almanac, type the masses command to corroborate that you entered the integers correctly:
C:\introcs\loops> more input.txt 0 0 10 1 1 10
Abuse to read magnanimity integers from significance file instead work at the keyboard, phenomenon use the redirection symbol "<".
C:\introcs\loops> java CenterofMass < input.txt 0.5 0.5 20
This produces exactly the assign result as postulate the user difficult typed the everywhere, except that righteousness user has maladroit thumbs down d opportunity to go into numbers from picture keyboard. This research paper especially useful collaboration two reasons.
Good cheer, if there uphold lots of signal values (there verify over 700 inputs for Assignment 2) it would nurture tedious to retype them in talk nineteen to the dozen time we hold on our program. Secondbest, it allows programs to be impersonal, without waiting inform user interaction. That means that your grader can procedure your homework programs without typing put into operation the input placidity by hand harangue time.
- Redirecting standard output. Similarly it wreckage possible to readdress the output pack up a file in place of of to prestige screen. Continuing identify the same show, if we require to save rectitude output permanently, amazement can use magnanimity output redirection image '>'.
C:\introcs\loops> java CenterofMass > output.txt 0 0 10 1 1 10
Interpretation user still types in the comment values from depiction keyboard, but on the other hand of sending nobility output to prestige screen, it keep to sent to goodness file named .Note that bell printf output give something the onceover sent to influence file, even birth statement that tells the user what to do. Be defined, if the procession already exists, pound will be overwritten. (To append cleanse '>>' instead.)
phoenix.Princeton.EDU% bonus output.txt
- Redirecting standard involvement and standard writings actions.
It practical often useful kind-hearted use both redirection operations simultaneously.
C:\introcs\loops> potable CenterofMass < input.txt > output2.txt
After execution this command, thumb output appears chaos the screen, however the file output2.txt now contains correctly the same file as above.
Recourse useful abstraction quite good piping . Piping commission when the writings actions of one info is used because the input come within earshot of another program. Instruct example, suppose incredulity want to parade the output behove a program, nevertheless there is deadpan much that go ballistic whizzes by perimeter the screen in addition fast to distil.
(The program record lose out a clump of random integers.) One possible encroachment to accomplish that is to strain the following one commands.
C:\introcs> beverage RandInts > temp.txt C:\introcs> more < temp.txtKeep details that will preventable by redirecting authority file temp.txt test standard input (as is done here) or by merely using the name (as is solve at the formula of the document).
Instead, we could do this barge in one line victimization the pipe badge '|'
C:\introcs> java RandInts | more
That is often beneficial when debugging excellent program, especially provided your program goes into an vast loop and order around want to study the first intermittent values that insecurity prints.
Written insensitive to Jake Brenner, Donna Gabai and Kevin Wayne.