Shared Flashcard Set

Details

Ch 9 Basic File Processing
Unix The Textbook 2nd Edition
53
Computer Science
Undergraduate 2
11/01/2014

Additional Computer Science Flashcards

 


 

Cards

Term
Concatenate/display the files in file-list on standard ouput
Definition
cat [options] file-list
- n Put line numbers with the displayed line
Term
Command to display file(s) have line numbers.
Definition
nl file-list
Term
Command to display file(s) with time stamp and page numbers and also partitions the file into pages and insert a header for each page.
Definition
pr file-list
Term
Concatenate/display the files in the file-list on standard output a screenful at a time
Definition
more [options] file-list
Term
Give two commands for displaying a file named 'grades' with line numbers
Definition
cat -n grades
nl grades
Term
Give the command for displaying all C program files in the ~/courses/programs directory a page at a time with 20 lines per page
Definition
more -20 ~/courses/programs/*.c
Term
Command used to identify the type of data stored in a file. The command to display the beginning portions of files in the file-list.
Definition
head [options] file list
-N Display first N lines (default is 10)
Term
Give the command for displaying the first 20 lines of the sample file by using the head command. Can you use any other command to perform the same operation? If yes, show the command line.
Definition
head -20 sample
more -20 sample
Term
Command used to display the last portions of the files in the file-list
Definition
tail [options] file-list
Term
follow the growth of the file after displaying the last line of a file, and display lines are they are appended to the file - this option is terminated with
Definition
tail -f
Term
Start n lines from the beginning of the file for +n, and n lines before the end of file or n units before the end of file. By default, -n is -10.
Definition
tail -(+/-n)
Term
Display the lines in revers order(last line first)
Definition
tail -r
Term
Give the command line for displaying the tail of the sample file starting with line 28.
Definition
tail -28 sample
Term
Shw the command that displays the lat five lines of the file 'sample' in reverse order
Definition
tail -5r sample
Term
Show the command to display the last 10 iines of file 'sim.data' and displays new lines as they are appended to the file
Definition
tail -f sim.data
Term
Command to copy file1 to file2; if file2 is a directory, make a copy of file1 in this directory
Definition
cp [options] file1 file2
You must have permission to read file1 and to execute(search) the directories that contain file1 and file2 and write permission to file2.
Term
Command used to copy both the data and attributes of the source file.
Definition
cp -fp file1 file2
Term
Command to copy a complete directory to another directory.
Definition
cp -r dir1 dir2
Term
4. Show the command line for copying all C program files in the ~/courses/programs directory into the ~/backups/programs directory. If a source files already exists in the destination directory, prompt the user before overwriting.
Definition
cp –ir ~/courses/programs/*.c ~/backups/programs
Term
For the cp file1 directory/file2 command to be successfully executed, what privileges are required for file1, file2, and directory?
Definition
The user must have read permission for file1 and write/execute permission for the directory. If file2 already exists then the user must have write permission on the file.
Term
A directory hierarchy with its own root stored on a disk or disk partition, mounted under a directory.
Definition
filesystem
Term
Command to move file1 to file2 or rename file 1 as file2
Definition
mv [options] file1 file2
Term
Command to move all the files in file-list to a directory
Definition
mv [options] file-list directory
Term
Command to force move regardless of the permissions of the destination file
Definition
mv -f file1 file2
Term
Command to prompt the users before overwriting the destination
Definition
mv -i dir1/* dir2
Term
6. Assume that there is a directory hierarchy, dir1, and a directory new_dir1. Give the command line for moving everything under dir1 to new_dir1.
Definition
mv dir1/* to new_dir1
This command will fail if new_dir1 is not a directory, if it does not exist, or if you do not have write and execute permissions for it.
Term
Command to remove files in the file-list from the file structure (and disk)
Definition
rm [options] file-list
Term
command to force remove regardless of the permissions for file-list
Definition
rm -f file1
Term
command to prompt the user before removing the files in file-list
Definition
remove -i file-list
Term
Command to recursively remove the files in the directory, which is passed as an arugment
Definition
rm -r dir1
Term
7. Give the command line for recursively and interactively removing an unwanted directory, NotNeededDirectory in your home directory.
Definition
rm –ir N NotNeededDirectory
Term
8. Assume that you have two files, f1 and f2, that you want to concatenate and store in a file called f1nf2. Show the cat command needed to perform this task.
Definition
cat f1 f2 > f1nf2
Term
Show the command needed to put your name, taken from the keyboard, as the last line of f1nf2.
Definition
Cat >> f1nf2
Raul Zuniga
Ctrl+d
Term
Command to display sizes of the files in file-list as number lines, words, and characters
Definition
wc [options] file-list
Term
command to display only the number of characters of the files in file-list
Definition
wc -c file-list
Term
command to display only the number of lines of the files in file-list
Definition
wc -l file-list
Term
command to display only the number of words of the files in file-list
Definition
wc -w file-list
Term
Use the wc command to confirm that you have concatenated files f1 and f1 into file f1nf2.
Definition
 wc –lwc f1 f2 f1nf2
The results of these commands should match.
Term
Show the command for displaying the contents of textfile named A*R*T*H*U*R, in a directory called funstuff in your home directory.
Definition
more ~/funstuff/A*R*T*H*U*R
Term
Command to append the contents of the files in file-list at the end of destination-file
Definition
cat file-list >> desitination file
Term
Command to combine file in the file-list and put them in destination-file
Definition
cat file-list > destination-file
Term
Command to compare file1 with file2 line-by-line and display differences between them as a series of commands that can be used to convert file1 to file2 or vice versa
Definition
diff [options] file1 file2
note: file1 & file2 can be directories which compares all pairs fo files with the same names
Term
command to remove repetitious lines from the sorted input-file and send unique lines to the output file.
Definition
unique [options] [+N] [input-file][output-file]
Term
If file1 is a file and dir1 is an empty directory then the cp file1 dir1 command creates a new file dir1/file1, provided you have read permission for file1 and write permission for dir1.
Definition
True
Term
If the file sample has its permissions set to 340 then the cp sample sample.new command will create a new file sample.new, if sample.new does not exist and you have write permission for the current directory or sample.new exists and you have write access for it.
Definition
True
Term
The mv sample dir1 command will execute successfully if permissions on sample are set to 440 and on dir1 are set to 544.
Definition
False
Term
The head -5 sample command is equivalent to the head +5 sample command.
Definition
False
Term
The head -5 sample command is equivalent to the tail +5 sample command.
Definition
False
Term
The tail –f sample command runs until terminated explicitly (e.g., by pressing ) and displays the new data appended to the sample file.
Definition
True
Term
The wc –lw sample memo lab command displays three lines, one each for sample, memo, and lab, containing line count, word count, and file name.
Definition
True (plus the total)
Term
The cat sample example >> ample and cat sample
example > ample commands are equivalent if ample is empty or does not exist.
Definition
True
Term
The uniq –u sample command displays repeated lines in the sample file.
Definition
False
Term
How can you see the long listing of a lengthy directory one page at a time?
Definition
ls -al| more
Supporting users have an ad free experience!