You are on page 1of 19

Batch Scheduling Commands:

FORCE START sendevent -e FORCE_STARTJOB -j t_0415_lms_to_update.cmd CHECK STATUS autorep -j t_0415_lms_to_update.cmd

autostatus {-J job_name | -G global_name} [-S Autoserv_instance]

ONHOLD COMMAND sendevent -e JOB_ON_HOLD -j us_vasanth_test1_job1

OFFHOLD COMMAND sendevent -e JOB_OFF_HOLD -j us_vasanth_test1_job1

ON ICE COMMAND sendevent -e JOB_ON_ICE -j us_vasanth_test1_job1 OFF ICE COMMAND sendevent -e JOB_OFF_ICE -j us_vasanth_test1_job1

KILL COMMAND sendevent -e KILLJOB -j us_vasanth_test1_job1 TERMINATED COMMAND sendevent -e CHANGE_STATUS -s TERMINATED -J us_vasanth_test1_job1 SUCCESS COMMAND

sendevent -e CHANGE_STATUS -s SUCCESS -J us_vasanth_test1_job1

DELETE JOB Sendevent -e DELETEJOB j us_vasanth_test_job1 GETTING REPORT autorep -j job_name -r -1 report on the job for the day -1 (prev day) Autorep -J job_name -r -5 report on the job for last 5th run Autoping
Autoping m machine|ALL} [-A][-D]

-A Send an alarm if problems are detected. -D Check the database connections on the specified machine(s). Jil

jr jobname j
CHECKING THE DETAILS OF THE JOB jr jobname -w autorep -J job_name d autorep -J job_name -q > file_name queries Checking the logs similar to events in job console cat event_demon.PPR | grep j (job name) /opt/autosys/autouser/out > cat event_demon.PPR.06042011

List of all ON_HOLD jobs jr ALL | grep OH status Lists all the jobs that are in On-Hold

List of all INACTIVE jobs jr ALL | grep IN Lists all the jobs that are in Inactive status

* job_depends -c -J us_chaity_p% * mailx chaitanya.karanam@eds.com < chaity.txt * mailx -s "subject" chaitanya.karanam@eds.com < chaity.txt

************************************************ ************************************************

AutoSys - A Job Scheduling Tool AutoSys on Unix


Cd to the "autouser" ($AUTOUSER) directory and "." (or source) the "ksh" file. Ex: ". ./autosys.ksh.machine"After installing AutoSys, first make sure that the DB is up and running. Check the installation by running the command chk_auto_up to verify connection to the DB and event processor. Enter the KEYS through "gatekeeper", add keys Run the "autosys_secure" command to set the AutoSys Edit and Exec Super users (and also to enter NT users/passwords) Start the Event Processor by running the command "eventor" Shutdown AutoSys: "sendevent -E STOP_DEMON" To start the AutoSys GUI set your DISPLAY and run the command "autosc &". NT: Start AutoSys from start->programs->AutoSys-> administrator ->Graphical User Interface ->Command Prompt

Autosys Command Line Commands:


1. gatekeeper: Allows you to enter the License Keys which allow you to run AutoSys. 2. eventor [-M machine_name] : Starts the event processor. 3. autorep -J [ALL Job_name] [-q] [> file_name], -d (detail), -r (run number), -o (override) Ex: autorep -J job_name -d autorep -J job_name -d autorep -J job_name -q > file_name queries the DB & save job Dfn. Into a file vi file_name When you want a report of a box use the -L0 option Autorep -J job_name -r -1 report on the job for the day -1 (prev day) Autorep -J job_name -r -5 report on the job for last 5th run

4. sendevent -E STARTJOB -J job_name : Normally start Autosys job. sendevent -E FORCE_STARTJOB -J job_name : Forcefully starts Autosys job. [JOB_ON_ICE, JOB_OFF_ICE, JOB_ON_HOLD, JOB_OFF_HOLD, SET_GLOBAL, STOP_DEMON. . . .] sendevent -E STOP_DEMON - to stop AutoSys sendevent -E SET_GLOBAL -G "var_name=/home/mydir" : To set a variable in Autosys sendevent -E SET_GLOBAL -G "var_name=DELETE" : To delete Autosys variable that is declared/set

5. chk_auto_up: checks to see if event processor and the DB are both up. 6. autoping -m machine: verify that both client & server are correctly configured. 7. cron2jil -f cronfile [-d outdir] [-I incl_file] [-m machine] [-p prefix] 8. jil: To insert autosys job directly into the DB

/* ----------------- template test.jil ----------------- */ insert_job: template job_type: c box_name: box1 command: <unix command i.e. ls -l> machine: localhost owner: $jil < test.jil 9. autosyslog e : same as tail -f autosys_log_file. This command must be run from the machine where the server resides if used with the -e option. Else it can be used with the -J option to see that job's run log. 10. job_depends: -[cdt] -J jobname [-F "mm/dd/yy time"] [-T "mm/dd/yy time"] (Note: It will only print out the first occurrence found) 11. monbro -n monitor_name: Allows you to run from command line monitor/browser programs previously created using the monitor/browser GUI.exec superuser: AUTOSYS superuser 12. autocal_asc full_cal_name : prints, adds & deletes custom calendar definitions. 13. autostatus: Reports the current status of a specific job, or the value of an AutoSys global variable. Ex: autostatus -J job_name, -S instance 14. autotimezone -l : Allows additions, deletions, and queries to the timezones table (-l provides list). 15. autotrack: Tracks & report changes to the AutoSys DB. Ex: autotrack -l 2 (level 2) [sets the tracking level] autotrack -U sys -v (user sys: verbose) To start using the autotrack utility type: autotrack -u to set tracking level 1 or 2. By default it is set to 0. Autotrack -l will list the current tracking level. Options -[J, U, m, F, T, and t] are to request reporting on a specific Job, User, machine, time window (-F -T), and event type (t). Type is used in conjunction w/other parameters. autotrack w/no arguments retrieves information an all events omitting detail. -v option is for verbose.

16. autosys_secure: to change edit, exec superusers, change DB passwd, change remote authentication method. 17. chase [-AE]: Makes sure that jobs claiming to be running in the client machine are running. The "-E" option restarts the job. 18. archive_events: to archive events in the DB which are older than x days to prev DB from becoming full. 19. clean_files: Deletes old remote agent log files. It does it by searching the DB for all machines which have had jobs started on them. 20. autostatad: to get the status of a PeopleSoft job. You can define one of the user definable buttons to view PeopleSoft job: Autocons*userButton1Label: Adapter Status.

User definable buttons: There are user definable buttons in the


operator's console.

How to configure:
Autocons*userButton1Command: /autosys/bin/autostatad -J $JOB -g & (which allows you to have a command button on the operator's console.)

Dependencies:
success (job) and s(job_b) failure(job_a) or f (job_b) notrunning (job) terminated(job) exitcode(job) > 5 and exitcode(job_b) != 10 value(global_name)=100 done(job)

Hostscape: Schedule a job to run every x minutes & then go into


forecasting. Make that job fail.

Solid black line: Hostscape can communicate with the remote agent in the client machine. Solid red line: Hostscape can't communicate with the remote agent but it can communicate with the internet daemon (inetd) running on that machine.. Dashed red line: Hostscape can't communicate with the client machine at all. Client is probably down.

Accessing a variable name: $$GLOBAL_VAR_NAME (unless used in dependency condition with a job definition. If used in the "command" field, you must use the $$)

Tunable Parameters:

$AUTOUSER/config.ACE $AUTOUSER/autosys.ksh.xxx /etc/auto.profile /etc/inetd.conf /etc/services

Notify.Ace: The alarms to notify on are:


(There is an example in $AUTOSYS/install/data/Notify.Ace).

DB_ROLLOVER DB_PROBLEM EP_HIGH_AVAILABILITY EP_ROLLOVER EP_SHUTDOWN $AUTOUSER/out/event_demon.$AUTOSERV ($AUTOUSER/out/event_demon.ACE) Output from the job definition output & error files /tmp files created for job_run at client machine $AUTOSYS/out/DBMaint.out for DB problems $SYBASE/install/errorlog_$DSQUERY when event server will not start. NT: AutoNuTc\lib/X11\app-defaults\xpert

Where to go to find the Errors:

AutoSys Maintenance: DBMaint @$AUTOSYS/bin


Once a day the Database goes into a maintenance cycle. Every day at 3:00am it runs a program called DBMaint. This is user configurable. The program runs DBstatistics which is found in $AUTOSYS/bin. app-defaults file: /usr/openwin/lib/app-defaults directory. Autocons, Xpert, etc.. ( or: /usr/lib/X11/app-defaults, /autosys/bin/X11/appdefaults)

Environment file: /etc./auto.profile C programs: $AUTOSYS/code Where to change AutoSys screen fonts: /usr/openwin/lib/app-defaults Where to look for troubleshooting: Chapter 15 Summary of commands: Appendix C $AUTO_JOB_NAME: when naming a file dynamically using as prefix AutoSys's job name. $AUTORUN: unique identifier for the run of that job $AUTOPID: unique identifier for that job's run number (PID) $JOID: DB identifier for a job. To extract from the DB: select joid from job where job_name=" "

Creating a Virtual Machine:


insert_machine: virtual type: v /* default, not required */ machine: real_1 machine: real_2 max_load: 100 factor: 0.5 /* used to describe the relative processing power of a machine. Usually between 0.0-1.0*/ machine: real_2 max_load: 60 /* this is designed to limit the loading of a machine */

Load Balancing, Queuing, priorities:


insert_job: test_load machine: localhost command: echo "Test load balancing" job_load: 50 priority: 1 /* this only affects queues */ Note: For 5.0 we will be using information from ServerVision's towards our load balancer which is composed of 26 categories such as i/o usage, disk usage, CPU usage, etc. Testing: zql zql -U autosys -P autosys

NOTES:
When a job is stuck in the starting condition this means that the event processor communicated with the remote agent and passed all the information the remote agent ran the job but was not able to communicate to the DB. Once testing is done with AutoSys one should change the default refresh interval for AutoSys. This is so there is less querying to the DB. When AutoSys goes from dual mode to single

mode, always run the autobcp command before bringing AutoSys back to dual mode/High Availability. Default behavior for stdout is to always appends. If you want to overwrite the file enter the following, no spaces: ">file.out"

Box Logic
Use boxes to group jobs with like scheduling parameters, not as means of grouping jobs organizationally. For example, if you have a number of jobs that run daily at 1:00 a.m., you could put all these jobs in a box and assigning a daily start condition to the box. However, a variety of account processing jobs with diverse starting conditions should not be grouped in the same box.

Default Box Job Behavior


Some important rules to remember about boxes are:

Jobs run only once per box execution. Jobs in a box will start only if the box itself is running. As long as any job in a box is running, the box remains in RUNNING state; the box cannot complete until all jobs have run. By default, a box will return a status of SUCCESS only when all the jobs in the box have run and the status of all the jobs is "success." Default SUCCESS is described in Default Box Success and Box Failure on page 5-13. By default, a box will return a status of FAILURE only when all jobs in the box have run and the status of one or more of the jobs is "failure." Default FAILURE is described in Default Box Success and Box Failure on page 5-13. Unless otherwise specified, a box will run indefinitely until it reaches a status of SUCCESS or FAILURE. For a description of how to override this behavior, see Box Job Attributes and Terminators on page 5-6. Changing the state of a box to INACTIVE (via the sendevent command) changes the state of all the jobs in the box to INACTIVE.

When you Should Not Use a Box


The fact that all jobs in a box change status when a box starts running has lead some to use boxes to implement "job cycle" behavior. Be aware that placing jobs in a box to achieve this end may bring with it undesired behavior due to the nature of boxes. Avoid the temptation to put jobs in a box as a short cut for performing events (such as ON_ICE or ON_HOLD) on a large number of jobs at

once. You will most likely find that the default behavior of boxes inhibits the expected execution of the jobs you placed in the box. Likewise, you should not place jobs in a box solely because you want to run reports on all of them. When you run autorep on a box, you will get a report on the box and all the jobs in the box (unless you use the -L0 option). In addition, if you use wildcarding when specifying a job name, you could get duplicate entries in your report. For example, suppose you have a box named "acnt_box" containing three jobs named "acnt_job1", "acnt_job2", and "daily_rep". If you specify acnt% as the job name for the autorep report, the report will have an entry for the box "acnt_box" and an entry for each job in the box. Then autorep will continue searching for all job names matching the wildcard characters and, thus, will list "acnt_job1" and "acnt_job2" a second time.

What Happens when a Box Runs


As soon as a box starts running, all the jobs in the box (including subboxes) change to status ACTIVATED, meaning they are eligible to run. (Because of this, jobs in boxes do not retain their statuses from previous box cycles.) Then each job is analyzed for additional starting conditions. All jobs with no additional starting conditions are started, without any implied ordering or prioritizing. Jobs with additional starting conditions remain in the ACTIVATED state until those additional dependencies have been met. The box remains in the RUNNING state as long as there are activated or running jobs in the box. If a box is terminated before a job in it was able to start, the status of that job will change directly from ACTIVATED to INACTIVE. Note o Jobs in a box cannot start unless the box is running. However, once the job starts running, it will continue to run even if the box is later stopped for some reason.

Time Conditions in a Box


Each job in a box will run only once per box execution. Therefore, you should not define more than one time attribute for any job in a box because the job will only run the first time. If you want to put a job in a box, but you also want it to run more than once, you must assign multiple start time conditions to the box itself, and define no time conditions for the job. Remember also that the box must be running before the job can start. Do not assign a start time for a job in a box if the box will not be running at that time. If you do, the next time the box starts the job will start immediately. The following example illustrates a scenario that would not work properly if placed in a box.

"job_a" is defined to run repeatedly until it succeeds. "job_report" has one starting condition-the success of "job_a".

How Job Status Changes Affect Box Status


If a box that is not running contains a job that changes status, as a result of a FORCE_STARTJOB or CHANGE_STATUS event, the new job status could change the status of its container box. A change of status of the box could trigger the start of downstream jobs that are dependent on the box. If a box contained only one job, and the job changed status, the box status would change. SAMPLE JOB /* ----------------- BW_CRD_SOD_BOX ----------------- */ insert_job: BW_CRD_SOD_BOX job_type: b machine: boxName owner: user@boxName permission: gx,ge,wx,we,mx,me date_conditions: 1 #run_calendar: lm_weedday #start_mins: 0,30 run_window: "01:00 - 05:00" alarm_if_fail: 1 /* 1----------------- BW_CRD_SOD_POLL_DB ----------------- */ # Polls DB and triggers SOD insert_job: BW_CRD_SOD_POLL_DB job_type: c command: /opt/bps/xmusern4/opt/bin/bwt-sod-scheduler.sh machine: boxName owner: user@boxName permission: gx,ge,wx,we,mx,me box_name: BW_CRD_SOD_BOX description: "BW_CRD_SOD_POLL_DB" std_out_file: /opt/logs/BW_CRD_SOD_POLL_DB_OUT.log std_err_file: /opt/logs/BW_CRD_SOD_POLL_DB_ERR.log alarm_if_fail: 1 /* 2----------------- BW_CRD_SOD_GEN_PORTIA_FILE ----------------- */ insert_job: BW_CRD_SOD_GEN_PORTIA_FILE job_type: c command: /opt/bin/bwt-portiaimport.sh machine: sunprod36

owner: user@boxName permission: gx,ge,wx,we,mx,me box_name: BW_CRD_SOD_BOX condition: s(BW_CRD_SOD_POLL_DB) description: "BW_CRD_SOD_GEN_PORTIA_FILE" std_out_file: /home/crd_user/BW_CRD_SOD_GEN_PORTIA_FILE_OUT.log std_err_file: /home/crd_user/BW_CRD_SOD_GEN_PORTIA_FILE_ERR.log max_run_alarm: 60 alarm_if_fail: 1 insert_job: BW_CRD_SOD_PORTIA_FUND_FW job_type: f machine: BoxName owner: user permission: gx,ge,wx,we,mx,me box_name: BW_CRD_SOD_BOX condition: s(BW_CRD_SOD_GEN_PORTIA_FILE) #date_conditions: 1 #run_calendar: lm_weekday #start_mins:0,5,10,15,20,25,30,35,40,45,50,55 #run_window: "9:00 - 23:00" description: "BW_CRD_SOD_PORTIA_FUND_FW" watch_file: E:\import\fileName.txt watch_interval: 2 watch_file_min_size: 100 alarm_if_fail: 1

************************************************ ************************************************

Learning the vi Editor


Learning the vi Editor (http://www.cs.colostate.edu/helpdocs/vi.html) VI (visual editor) $ vi filename . edit filename starting at line 1 : vi -r recover filename that was being edited when system crashed To load an existing text file into vi $ vi myfile.txt tilde (~). 2)Two main modes of operation: command mode and insert mode To switch into insert mode , simply press the 'i' key. Although nothing will change on the screen to indicate the new mode, anything that you type from now on will appear in the screen. Try typing a few lines of text. When you press 'return' or 'enter' a new line will be created, and you may continue typing. press 'Esc'. If you were in insert mode, you will be returned to command mode. 1. Load vi by typing: $ vi

~ tilde (~) ~ ~ By default you are in command mode. Switch to insert mode, by pressing the 'i' key. Then type some text, using ENTER or RETURN to start new lines. For example: Hello. (This is my first session in the vi editor) This is the second line of text. ~ ~ ~ 3)To Exit vi When you have finished entering your sample text, press 'Esc' to return to command mode. To save the file: The command for this is ':w' :w firstfile The command for close the editor is ':q' :q :x <Return> quit vi, writing out modified file to file named in original invocation :wq <Return> quit vi, writing out modified file to file named in original invocation :q <Return> quit (or exit) vi :q! <Return> quit vi even though latest changes have not been saved for this vi call Saving and Reading Files :r filename<Return> read file named filename and insert after current line :w<Return> write current contents to file named in original vi call :w newfile<Return> write current contents to a new file named newfile :12,35w smallfile<Return> write the contents of the lines numbered 12 through 35 to a new file named smallfile :w! prevfile<Return> write current contents over a pre-existing file named prevfile Moving the Cursor To move the cursor around the screen, you must be in command mode h - Cursor left j - Cursor down k - Cursor up l - Cursor right 0 - (zero) $ - move cursor to end of current line W - move cursor to beginning of next word :0<Return> or 1G - move cursor to first line in file :n<Return> or nG - move cursor to line n :$<Return> or G - move cursor to last line in file

Cutting and Pasting Text Yy copy (yank, cut) the current line into the buffer Nyy or yNy copy (yank, cut) the next N lines, including the current line, into the buffer P put (paste) the line(s) in the buffer into the text after the current line Deleting a character: While you are in insert mode, you can delete a character that you have just typed by using the 'backspace' key Load vi, and go into insert mode. Enter the following text: 'abcdefg'. Then press 'Esc' to return to command mode. Move the cursor back, using the left arrow or 'h' key, until the cursor points to the letter 'd'. Then press 'i' to go back into insert mode, and type 'hijklmn'. Now try to delete some of the characters using the backspace key. You will find that you can delete the characters that you have entered since being insert mode,. So the 'abc' will remain undeleted. So how do we delete any characters that were entered in previous insert mode sessions? Go back into command mode, place the cursor over the character to be deleted, then press the 'x' key. Repeating a command To delete 20 characters from a file, starting from the current position, using the command '20x' type '5l'. Notice how the cursor move 5 places to the right. Deleting a line delete an entire line : with the 'dd' command Load vi, and go into insert mode Enter several lines of text, preferably at least 10 Then return to command mode. Move the cursor up to the top of the screen Inserting or Adding Text *i insert text before cursor, until <Esc> hit I insert text at beginning of current line, until <Esc> hit *a append text after cursor, until <Esc> hit A append text to end of current line, until <Esc> hit *O open and put text in a new line below current line, until <Esc> *O open and put text in a new line above current line, until <Esc> * u UNDO WHATEVER YOU JUST DID; a simple toggle Determining Line Numbers :.= returns line number of current line at bottom of screen := returns the total number of lines at bottom of screen ^g provides the current line number, along with the total number of lines, in the file at the bottom of the screen

Changing Text

Basic vi Commands
What is vi?
The default editor that comes with the UNIX operating system is called vi (visual editor). [Alternate editors for UNIX environments include pico and emacs, a product of GNU.] The UNIX vi editor is a full screen editor and has two modes of operation: 1. Command mode commands which cause action to be taken on the file, and 2. Insert mode in which entered text is inserted into the file. In the command mode, every character typed is a command that does something to the text file being edited; a character typed in the command mode may even cause the vi editor to enter the insert mode. In the insert mode, every character typed is added to the text in the file; pressing the <Esc> (Escape) key turns off the Insert mode. While there are a number of vi commands, just a handful of these is usually sufficient for beginning vi users. To assist such users, this Web page contains a sampling of basic vi commands. The most basic and useful commands are marked with an asterisk (* or star) in the tables below. With practice, these commands should become automatic. NOTE: Both UNIX and vi are case-sensitive. Be sure not to use a capital letter in place of a lowercase letter; the results will not be what you expect.

To Get Into and Out Of vi


To Start vi To use vi on a file, type in vi filename. If the file named filename exists, then the first page (or screen) of the file will be displayed; if the file does not exist, then an empty file and screen are created into which you may enter text. edit filename starting at line 1 * vi filename

vi -r filename

recover filename that was being edited when system crashed

To Exit vi Usually the new or modified file is saved when you leave vi. However, it is also possible to quit vi without saving the file. Note: The cursor moves to bottom of screen whenever a colon (:) is typed. This type of command is completed by hitting the <Return> (or <Enter>) key. * :x<Return> quit vi, writing out modified file to file named in original invocation
:wq<Return> :q<Return>

quit vi, writing out modified file to file named in original invocation quit (or exit) vi

* :q!<Return> quit vi even though latest changes have not been saved for this vi call

Moving the Cursor


Unlike many of the PC and MacIntosh editors, the mouse does not move the cursor within the vi editor screen (or window). You must use the the key commands listed below. On some UNIX platforms, the arrow keys may be used as well; however, since vi was designed with the Qwerty keyboard (containing no arrow keys) in mind, the arrow keys sometimes produce strange effects in vi and should be avoided. If you go back and forth between a PC environment and a UNIX environment, you may find that this dissimilarity in methods for cursor movement is the most frustrating difference between the two. In the table below, the symbol ^ before a letter means that the <Ctrl> key should be held down while the letter key is pressed. j or <Return> * move cursor down one line [or down-arrow] * k [or up-arrow] move cursor up one line or <Backspace> move cursor left one character [or left-arrow] l or <Space> * move cursor right one character [or right-arrow] * 0 (zero) move cursor to start of current line (the one with the cursor) *
h

* $

move cursor to end of current line w move cursor to beginning of next word b move cursor back to beginning of preceding word :0<Return> or 1G move cursor to first line in file

:n<Return> or nG :$<Return> or G

move cursor to line n move cursor to last line in file

Screen Manipulation
The following commands allow the vi editor screen (or window) to move up or down several lines and to be refreshed. ^f move forward one screen ^b move backward one screen ^d move down (forward) one half screen ^u move up (back) one half screen ^l redraws the screen ^r redraws the screen, removing deleted lines

Adding, Changing, and Deleting Text


Unlike PC editors, you cannot replace or delete text by highlighting it with the mouse. Instead use the commands in the following tables. Perhaps the most important command is the one that allows you to back up and undo your last action. Unfortunately, this command acts like a toggle, undoing and redoing your most recent action. You cannot go back more than one step. * u UNDO WHATEVER YOU JUST DID; a simple toggle The main purpose of an editor is to create, add, or modify text for a file. Inserting or Adding Text The following commands allow you to insert and add text. Each of these commands puts the vi editor into insert mode; thus, the <Esc> key must be pressed to terminate the entry of text and to put the vi editor back into command mode. * i insert text before cursor, until <Esc> hit
I

insert text at beginning of current line, until <Esc> hit append text to end of current line, until <Esc> hit

* a append text after cursor, until <Esc> hit


A

* o open and put text in a new line below current line, until <Esc> hit * O open and put text in a new line above current line, until <Esc> hit

Changing Text The following commands allow you to modify text. replace single character under cursor (no <Esc> needed) replace characters, starting with current cursor position, until <Esc> hit change the current word with new text, starting with the character under cursor, until <Esc> hit change N words beginning with character under cursor, until <Esc> hit; e.g., c5w changes 5 words change (replace) the characters in the current line, until <Esc> hit change (replace) the entire current line, stopping when <Esc> is hit or cNc change (replace) the next N lines, starting with the current line, stopping when <Esc> is hit

* r
R cw cNw C cc Ncc

Deleting Text The following commands allow you to delete text. * x delete single character under cursor Nx delete N characters, starting with character under cursor dw delete the single word beginning with character under cursor delete N words beginning with character under cursor; dNw e.g., d5w deletes 5 words delete the remainder of the line, starting with current cursor position * dd delete entire current line delete N lines, beginning with the current line; Ndd or dNd e.g., 5dd deletes 5 lines
D

Cutting and Pasting Text The following commands allow you to copy and paste text. yy copy (yank, cut) the current line into the buffer Nyy or yNy copy (yank, cut) the next N lines, including the current line, into the buffer
p

put (paste) the line(s) in the buffer into the text after the current line

Other Commands
Searching Text

A common occurrence in text editing is to replace one word or phase by another. To locate instances of particular sets of characters (or strings), use the following commands. /string search forward for occurrence of string in text
?string n N

search backward for occurrence of string in text move to next occurrence of search string move to next occurrence of search string in opposite direction

Determining Line Numbers Being able to determine the line number of the current line or the total number of lines in the file being edited is sometimes useful. :.= returns line number of current line at bottom of screen := returns the total number of lines at bottom of screen provides the current line number, along with the total number of lines, ^g in the file at the bottom of the screen

Saving and Reading Files


These commands permit you to input and output files other than the named file with which you are currently working.
:r filename<Return> :w<Return> :w newfile<Return> :12,35w smallfile<Return> :w! prevfile<Return>

read file named filename and insert after current line (the line with cursor) write current contents to file named in original vi call write current contents to a new file named newfile write the contents of the lines numbered 12 through 35 to a new file named smallfile write current contents over a pre-existing file named
prevfile

Comments:

You might also like