Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Standard view
Full view
of .
Save to My Library
Look up keyword
Like this
0 of .
Results for:
No results containing your search query
P. 1


Ratings: (0)|Views: 8,305 |Likes:
Published by arthur10892

More info:

Published by: arthur10892 on Jun 01, 2011
Copyright:Attribution Non-commercial


Read on Scribd mobile: iPhone, iPad and Android.
download as TXT, PDF, TXT or read online from Scribd
See more
See less





Chapter 1: Files, Directories and RedirectionFile system commands: ls -[lAa], mkdir, cd, pwd, cp, mv, rmStandard output redirection (>)Viewing files: cat, less, head, tailCommands and their options: touch, cal, wc1. Create a fileCreate a file called "hello.world" (without the quotes). Hint: touchTouch hello.world2. Create a directoryCreate a directory called "otherworld" (not including the quotes).mkdir otherworld3. Store a calendarStore the 2008 calendar produced by the "cal" command in the file "calendar" with no modifications to the output of the "cal" command. Hint: Standard output redirection using ">".cal 2008 > calendar4. List visible filesList all (non-hidden) files in the directory "/usr/local/linuxgym-data/gutenberg" and store this list into a file called "listvis". Ensure that this is exactlythe output of the command "ls".ls /usr/local/linuxgym-data/gutenberg > listvis5. List all filesBy "all files" we refer to every file which is not a directory, including hiddenfiles whose names begin with ".". List all files in the directory "/usr/local/linuxgym-data/gutenberg" and store this list into a file called "allfiles". Ensure that this is exactly the output of the command "ls". (Hint: consider the "all"and "almost-all" options in "man ls")ls –a /usr/local/linuxgym-data/gutenberg > allfiles6. Top of fileThe "cat" function prints out the contents of a file. For example "cat /usr/local/linuxgym-data/census/a-j_malenames.txt" shows you an alphabetically ordered list of male names recorded by the US Census Bureau. Because the list scrolls offthe top of the screen, you can not easily read the first 10 names. The "head" command solves this problem. Experiment with the "head" command and store the first 10 lines from the file a-j_malenames.txt into a file called "first-ten-names.txt". (Hint: Redirect the output using ">")head –n 10 /usr/local/linuxgym-data/census/a-j_malenames.txt > ten-names.txt-n : number of lines7. Merging filesThe "cat" function which prints out the contents of a file, can be used to print
the contents of several files by giving it more than one argument. In the directory /usr/local/linuxgym-data/census/ there are two files: a-j_malenames.txt andk-z_malenames.txt. Use "cat" to print out both of these files and store the output in a file called "a-z_malenames.txt" in the correct order. (Hint: Redirect the output using ">")cat /usr/local/linuxgym-data/census/a-j_malenames > a-z_malenames.txtcat /usr/local/linuxgym-data/census/k-z_malenames >> a-z_malenames.txt>> : merge with existing content8. File sizeLook at the files in the directory /usr/local/linuxgym-data/teeny and indentifywhich is the smallest file. Copy this file into your ch1-fdr directory. (Hint: cp, ls -l)ls –l -s /usr/local/linuxgym-data/teeny (or ls –l –s –S)cp /usr/local/linuxgym-data/teeny/filename filename (smallest) /home/student/….-l : show information for each file-s : size of files-S : arrange from biggest to smallest fileChapter 2: Elementary VIMIn preparation for the exercises in this chapter create a directory called "ch2-vim" in your home directory. Copy the file "/usr/local/linuxgym-data/vimdata/tutor.txt" into your "ch2-vim" directory, change into the directory and start editing the file "tutor.txt" using vim by calling: "vim tutor.txt" and following theinstructions within the file. If anything should go awry, just exit vim by(1) hitting Esc - the button at the top left of your keyboard; and then (2) issuing the command ":q!"To start over again, copy "/usr/local/linuxgym-data/vimdata/tutor.txt" into your"ch2-vim" directory and start editing the file again. For all the questions below, perform the operation on the file indicated and save it before marking the question.1. Insert textWithin your "ch2-vim" directory, create a file called "hw.txt", with only one line of text saying: "hello world" (without the quotes) and save the file.mkdir ch2-vim cd mkdir ch2-vimtouch hw.txt vim hw.txt press “i” toinsert ‘hello world’Esc :wq (to save changes and exit)2. Join linesCopy the file "/usr/local/linuxgym-data/vimdata/wordlist.txt" into your "ch2-vim" directory. Edit the file so that all of the text is on a single line with onlya space (not a newline) between the words.cp /usr/local/linuxgym-data/vimdata/wordlist.txt wordlist.txtvim wordlist.txt3. Delete a wordCopy the file "/usr/local/linuxgym-data/teeny/1mwsm10.txt" into your "ch2-vim" directory. Delete the first word at the beginning of line 6 - and the space whichfollows it - and save the file, making absolutely no other changes (Hint: dw)
cp /usr/local/linuxgym-data/teeny/1mwsm10.txt /home/student/ch2…6G (go to indicated line)esc idw (delete the word where indicated with the space that follows):wq4. Search and line deletionCopy the file "/usr/local/linuxgym-data/gutenberg/07frd10.txt" into your "ch2-vim" directory. Delete the line containing the word "opera-girls" - and save the file, making absolutely no other changes. (Hints: / and dd.)cp /usr/local/linuxgym-data/gutenberg/07frd10.txt 07frd10.txtvim 07frd10.txt: /opera-girls : /
command to search wordsdd dd
delete line:wq5. Deletion by line numbersCopy the file "/usr/local/linuxgym-data/gutenberg/0ws3110.txt" into your "ch2-vim" directory. Starting at line 50 delete 4000 lines (including line 50) - and save the file. Make absolutely no other changes.cp /usr/local/linuxgym-data/gutenberg/0ws3110.txt 0ws3110.txtvim 0ws3110.txt50G G
GO to line number indicated4000dd:wq6. Copy and paste by line numbersCopy the file "/usr/local/linuxgym-data/teeny/3mwsm10.txt" into your "ch2-vim" directory. Delete the first 10 lines and append them to the end of the file. Savethe file and make no other changes.10yy yy
yank command which copies the indicated lines OR10dd dd
delete 10 lines (copies them into cache automatically)GP GP
G command goes to end of the file and P commendpastes7. Delete to the end of a fileCopy the file "/usr/local/linuxgym-data/gutenberg/7wdvn10.txt" into your "ch2-vim" directory. Delete all the lines from line 1024 to the end, including line 1024 and save the file.G1024[Number of lines in file – 1024] dd8. Search and replace stringsIn the next two questions we have to distinguish between words and strings. A string is a sequence of characters, while a word is a sequence of letters within astring, surrounded by non-word characters. For example, the string "This is a t

Activity (14)

You've already reviewed this. Edit your review.
_patmurray liked this
1 thousand reads
1 hundred reads
James Horsburgh liked this
Binaya Roy liked this
Binaya Roy liked this
Binaya Roy liked this
Binaya Roy liked this
Binaya Roy liked this
Binaya Roy liked this

You're Reading a Free Preview

/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->