Upload
shubham
View
231
Download
0
Embed Size (px)
DESCRIPTION
well this is it
Citation preview
Page 1 of 4
Birla Institute of Technology & Science, Pilani , K. K. BIRLA Goa Campus
Computer Programming (CS F111)
Second Semester 2013-2014
Lab-01
Exercise #1
1) Create a file named MyFile using VI editor. Write the following two lines into the file
Spades take up leaves
No better than spoons,
Save the file and exit the VI editor.
2) Open MyFile and insert the following two lines after the last line of the file and save the file
as MyFile2
But the mountains I raise
Elude my embrace,
3) Add the following statement in the last line [After comma] and save the file as MyFile3
Flowing over my arms
4) Insert the following lines after line 2 [before line 3] and save the file as MyFile4
And bags full of leaves
Are light as balloons.
I make a great noise
Of rustling all day
5) Insert the following line after line 5, save MyFile without exiting from VI editor.
And into my face.
6) Copy (Yank) the current line and paste it in a new line after the last line. Save the file as
MyFile6.
7) Delete the 5th line from the last. Save the file and exit from the VI editor.
8) Copy the first two lines of MyFile file and paste them thrice after the 4th line. Save the file as
MyFile8 and exit the VI editor.
9) Cut the 3rd to 6
th lines from the file and paste them before the 4
th line of your file. Save the file
as MyFile9
10) Join the 5th and 6
th line using vi editor commands. Join 6
th line to 9
th line by using only one
join operation [using vi editor command] and save the file as MyFile10.
11) Delete lines 5 to 9. Save the file as FinalFile and exit the VI editor.
Page 2 of 4
Exercise #2
1) Create a file named MyFile using VI editor. Write the following three lines into the file
Next to nothing for weight,
And since they grew duller
Next to nothing for use.
Save the file and exit the VI editor.
2) Open MyFile and insert the following two lines after line 2 of the file and save the file as
MyFile2
From contact with earth,
Next to nothing for color.
3) Move the cursor to the 5th line of the file [without using arrow keys] and write the following
lines there. Save the file as MyFile3
And who's to say where
The harvest shall stop?
4) Delete last character of the first line and repeat the same action for all other lines [from
command mode] and save the file as MyFile4.
5) Replace the last word of the 5th line by USE and insert the following line after the 5
th line
But a crop is a crop
Save the file and exit the VI editor.
6) Copy the 3rd to 6
th lines of the MyFile and paste them twice after line 4. Save the file as
MyFile6.
7) Delete all occurrences of the string Next to nothing from the file. Save the file as MyFile7.
8) Convert the first character of the first word [first line] into uppercase and repeat the action for
each word. Save the file as MyFile8.
9) Join the 2nd and 3
rd line by using vi editor command. From the resultant line, delete the last
three words and save the file as MyFile9.
10) Cut 5th line to 8
th line of MyFile and paste them (using :put) before the first line . Save the
file and exit the VI editor.
Page 3 of 4
Exercise #3
1) Create a file named MyFile using VI editor. Write the following three lines into the file
As long as it takes to pass
A ship keeps raising its hull;
The wetter ground like glass
Save the file and exit the VI editor.
2) Open MyFile and insert the following three lines in the beginning of the file and save the file
as MyFile2
The people along the sand
All turn and look one way.
They turn their back on the land.
3) Delete the first 2 words of the 4th line and insert the following line after the 3
rd line. Save the
file as MyFile3.
They look at the sea all day.
4) Move the cursor to the last line [without using arrow keys]. Add the following line as the
second last line and save the file as MyFile4
Reflects a standing gull
5) Delete the last two words of first line and repeat the action for each line. Save the file as
MyFile5
6) Replace the last word of the first line with ###. Repeat this action for last word of each line.
Save the file as MyFile6
7) Convert the first character of first word into uppercase and repeat the action for each word.
Save the file as MyFile7.
8) Copy 4th line to 7
th line using n1,n2y and paste them after the 2
nd line and 8
th line. Delete the
7th line to 9
th line. Save the file as MyFile8.
9) Copy the first two lines of MyFile and paste it in MyFile4 thrice after the last line. Save the
file as MyFile9.
10) Copy the last 2 lines from MyFile and paste them before the first line in MyFile2. Save the
file as MyFile10.
11) Delete all the lines of MyFile which has the word the in it. Save the file as FinalFile and
exit from the VI editor.
Page 4 of 4
Exercise #4
1) Create a file named MyFile using VI editor. Write the following three lines into the file
The water comes ashore,
And the people look at the sea.
They cannot look out far.
Save the file and exit the VI editor.
2) Copy(Yank) last two lines of the file and paste it after the last line. Delete the last two words
of the 4th line and save the file as MyFile2
3) Write the string in deep from the current cursor position in append mode. Delete the next
line in command mode. Save the file as MyFile3.
4) Insert the following lines before the first line and save the file as MyFile4.
The land may vary more;
But wherever the truth may be -
5) Copy the 4th line to 6
th line and paste it after the last line (use put). Copy the current line and
paste it after the 2nd line. Save this as MyFile5 and exit MyFile from VI editor without saving
these changes.
6) Open MyFile5 in VI editor and delete the first two words of each line using d0. Save the file
as MyFile6.
7) Join the two consecutive lines (ex. Join line 1 and 2, 3 and 4 and so on) of MyFile5. Save the
file as MyFile7.
8) Delete 2nd line to 4
th line using only one command and paste the deleted contents before the
last line. Save the file as MyFile8.
9) Replace the first word of the first line with the word First using 'Replace Command' and
repeat this action for next two lines. Save the file without exiting from VI editor.
10) Copy (Yank) the current line and paste it before 3rd line without moving the cursor from its
current location.
11) Copy the 2nd to 5
th lines of MyFile5 and paste it in MyFile7 thrice before the first line. Save
the file as MyFile11.
12) Copy the last 2 lines from MyFile and paste them before the first line in MyFile2 and
MyFile8. Save these files.
13) Delete all the lines of MyFile11 which has the word at in it. Save the file as FinalFile and
exit from the VI editor.