unix 2
The file(s) that will be executed by shell before prompt string is displayed is
.profile
The command ls ?? matches the filename(s)
AB and ab
What is the content of the Xfile after the following command is executed? cat Afile Bfile > Xfile a: Afile and
Bfile
The command to change the prompt to the string "Next? " is
PS1="Next? "
The command mv xxx yyy
The i-node number remains the same, only the filename is changed
To quotation marks used for command substitution (executing a command) is
` command ` (single back quotation marks - grave accent)
What is the content of the Xfile after the following command is executed? pr Afile > Xfile
a formatted copy of the Afile
The command cat xxx >> zzz
all of the above
The command rm [a-c]Report
all of the above
The command cat Afile >> Xfile
appends the Afile to Xfile
The command cp -i Afile Xfile
asks for confirmation before copying the files
The command to copy the file called Xfile to Zfile is
cat Xfile>Zfile
The command to copy xxx and yyy files into zzz file is
cat xxx yyy>>zzz
2. cat cw >> xxx
copies wc to xxx
1. cp wc yyy
copies wc to yyy
5. cp -i wc yyy
copies wc to yyy and asks for confirmation if yyy exists
4. wc -cw wc >> xxx
counts the words and characters in wc and saves them in xxx
The command to copy the file called Xfile to Zfile is
cp Xfile Zfile
The command cp xxx yyy
creates a new i-node number for yyy
The command ln xxx yyy
creates no new i-node number
The command to count number of lines in xyz is
d.wc -l xyz
7. rm *
deletes all the files in the current directory
The cut command is used to
display specified columns of fields from a file
3. cat < xxx
displays a file called xxx
9. ls [Aa]*
displays all the filenames that begin with a or A
6. ls *[a-d]
displays all the filenames that end with the letter a, b, c, or d
The command head -5 Xfile Zfile
displays the first 5 lines of the Xfile and Zfile files
The command cut -f 1,3 Xfile
displays the first and third fields in the Xfile
The command to display the word UNIX in quotation marks is: X
echo " \"UNIX\" "
The command to display your home directory pathname is
echo $HOME
The command to display the string "? is >> * \" is
echo \? is \>> \* \\
Shell programs must be compiled like other high-level languages.
f
Startup files are a set of programs that are executed whenever you change directories.
f
The HISTSIZE is a variable used by the vi editor.
f
The HOME standard variable is set to the root directory pathname.
f
The IFS standard variable is set to a list of characters that are used as the separator of the command line items.
f
The alias command is used to rename files
f
The command cat Xfile creates the Xfile and accepts input to file from the keyboard.
f
The command ln links each file to a physical block on your disk.
f
The command tail +20 xyz displays the first 20 lines of the file xyz
f
The export command is used to send files from one terminal to another.
f
The find command is used to find a field in a file.
f
The find command is used to locate specified files.
f
The grep command is used to look for a specific filename
f
The history command is used to back up files.
f
The mv and cp commands are the same. Both copy file(s) from one place to another.
f
The noclobber option removes clobber from directories
f
The paste command is used to append files.
f
The shell standard variables are called metacharacters
f
The tee command is used to save a file in two different locations
f
UNIX assigns a process number to each process in the system.
f
You can use the view command to edit files just like the vi editor.
f
The command find . -name Xfile -print
finds and displays all the files named xfile
The command find . -atime 10 -print
finds and displays files accessed exactly 10 days ago
The command G
goes to the first command in the history file
The command to find the word UNIX in files called File1, File2 and File3 is
grep UNIX File?
The paste command is used to
join files together line by line
The command ln Xfile Zfile
links Xfile to Zfile
What is the content of the Xfile after the following command is executed? ls [Aa]* > Xfile
list of all the files that start with letter A or a
What is the content of the Xfile after the following command is executed? ls A?A > Xfile
list of files such as: AAA ABA AZA
What is the content of the Xfile after the following command is executed? ls > Xfile
list of the filenames in the current directory
8. ls .*
lists only the invisible files
The command to display all the single capital letter filenames is
ls [A-z]
The command to list all the files that have filenames that starts with letter a and ends with a number from 1to 5 is
ls a*[1-5]
The command to display Xfile one screen at a time is
more Xfile
The command to rename the file called Xfile to Zfile is
mv Xfile Zfile
The command to prevent the termination of a background process after the user is logged off is:
nohup sort xyz &
The command sort +1 xyz sorts the xyz file
on the second field
10. mv xxx yyy
renames the file named xxx to yyy
The command find / -name "file?" -print
searches from the home directory
The command to set the option to prevent accidental log off when using [Ctrl-d] key is
set -o ignoreeof
The command to set the option to prevent overwriting an existing file is
set -o noclobber
The statement HISTSIZE=100
sets the number of entries for HISTFILE to 100
The statement PS1="! $"
sets the prompt sign to show the last event number from
The command more xyz
shows xyz file one page at the time
The command to sort the xyz file in the background is
sort xyz&
The command sort -r -o yourfile myfile
sorts yourfile in reverse order and saves it in myfile
The command find / -name "*" -atime -5 -print
start from the root directory amd finds all files last accessed less than 5 days ago
The command find . -name "first.cpp" -exec rm {}\;
starts from the current directory and deletes all instances of first.cpp
The command find . -name "?" -print
starts from the home directory, and finds all files with filename?
Metacharacters are usually used in part of the filename to create a search pattern.
t
Preceding a metacharacter with a backslash (\) removes its special meaning.
t
Shell language is a command language
t
The >> sign is the output redirection symbol
t
The command cat > Xfile displays the content of the Xfile.
t
The command wc -l filename displays the number of lines in the filename.
t
The echo command is used to echo the input from keyboard
t
The ignoreeof option prevents accidental log off when using the [Ctrl-d] key
t
The kill command is used to terminate a running program.
t
The more command is used to read files one screen at a time.
t
The ps command is used to obtain process status.
t
The r (redo) command is used to repeat the last vi editing job.
t
The shell command line editor works on the current command line and the history file
t
The shell contains several build-in commands
t
The tail command is used to display the last 10 lines of the specified file.
t
UNIX shell has its own built-in programming language
t
You can read a large file using vi with the -R option.
t
The command kill -9 0
terminates all processes including your login shell
The command to display the number of lines in a file and also save the count in a file is:
wc-lxyz?/tee outfile