Unix Individual Assignment
Words: 275
Pages: 1
68
68
DownloadUnix Individual Assignment
Student’s Name
Institution
Unix Individual Assignment
1. I am now in $HOME/sales/east directory. I want to have my login shell display me today’s date whenever I login every time by telnet.
For this, what steps I have to do? (1/2)
A. $ vi .profile
Type one line : echo “Today’s date is `date`”
$ chmod +x .profile
$ . .profile
B. $ cd ../..
$ vi .profile
Type one line : echo “Today’s date is `date`”
$ export .profile
$ .profile
C. $ cd $HOME
$ vi .profile
Type one line : echo “Today’s date is `date`”
$ . .profile
D. $ vi ~/.profile
Type one line : echo “Today’s date is “date”
$ . .profile
Ans: The answer is D
2A. Why I am getting this error when I assign like this ? (1/2)
$ FIRST-NAME=smith
ksh: FIRST-NAME=smith: not found.
Ans: The error is obtained because dash is never allowed to be used in variable name
2B. Under ksh or bash shell environments, what is the problem here ? (1/2)
$ export PATH=/usr/bin /usr/local/bin /usr/ucb/bin
Ans: export path=usr/bin:/usr/local/bin:/usr/ucb/bin
3. Executing cp temp/temp1 temp1.txt it will result in… (1/2)
A. Error since the same filename is usedB. Error since an extension is used for the second temp1C. It will move the contents of temp1 from directory temp to temp1 of current directory, and when finished it will erase the contents of temp1 of temp directory
D. It will copy temp1 from directory temp to temp1.txt of current directory
Ans: The answer is D
4.
Wait! Unix Individual Assignment paper is just an example!
What kind of files will be matched by the following when you list by ls command: (3)
For Ex :
$ ls [a-z][0-9]
Ans: It matches any file that has two characters where the first is a lower case letter whereas the second is a number that is between 0 and 9 (Palmer, 2007)
A. ls [0-9][a-z][0-9][A-Z] — Note : there are no spaces anywhere.
Ans: It matches any file that has four characters, where the first is the character and second a lower case letter, the third is a number, and the fourth is an uppercase letter
B. ls [A-Z0-9_][A-Za-z_0-9] — Note : there are no spaces anywhere.
Ans: It matches files with two characters the first being an underscore, a number or an uppercase letter and the second being a number, underscore, small case letter, or an uppercase letter
C. ls [0-9]Z[0-9]
Ans: It matches a three characters file name where the first is a number, the second is a Z character whereas the third is a number
5. What is the command to list files in a directory: (2) A. Having only three alphabets:
Ans: ls [A-Za-z_0-9][A-Za-z_0-9][A-Za-z_0-9]B. Starting with a digit and ending with a digit
Ans: ls [0-9]*[0-9]
6. There are many C programs in my directory which have an extension of .c (ex: first.c, second.c, etc). How can I concatenate all C files into one file called “myC_files (1) Ans : You concatenate for filename in `ls *.c`; do cat $filename >>myC_files;done
7. How do you sort first 15 lines in a file called ‘datafile”? (1) (You need to use a pipe)Ans: head -15 datafile | sort
8. How do you add a line to the end of an existing file “myfile” with a date stamp? (1)
Ans : echo “Today’s date is `date`” >>myfile
References
Palmer, M. (2007). Guide to UNIX using Linux (4th ed.). Boston, MA ; Australia: Cengage Learning.
Subscribe and get the full version of the document name
Use our writing tools and essay examples to get your paper started AND finished.