Write the script so that it will do the following, no matter in which directory it is run. (To test your script while you're developing it, you'll need to create some files to test it with in the ``unixtest'' directory. However, when we check your work, we'll test it with different files in a different directory.) Suppose that your script is being run in a directory D:
* Cat every file (in D) whose name starts with ``test'' into a file (in D) called ``bigtest'' (you'll have to redirect output). (Hint: You might want to review the ``Wildcards'' section in the ``Unix Shell Commands'' lesson.)
* Copy every line of a file (in D) called ``dogfile.txt'' that has the word ``dog'' (lower-case letters only) in it into a file (in D) called ``doglines.txt''.
* Write every line containing the word ``delete'' produced by ``man mail'' into a file called ``delete''
My test directory is: /home/unixtest
input directory is same
Unix Programming assignment?
That shouldn't be too hard to do...BTW, I'm going to use KORN. You will need to modify it for CSH.
#! /bin/ksh
TARGET_DIR=$1
cat ${TARGET_DIR}/test* %26gt; ${TARGET_DIR}/bigtest
grep dog ${TARGET_DIR}/dogfile.txt %26gt; ${TARGET_DIR}/doglines.txt
man mail | grep delete
From what you have, the problem with the bigtest is that you need to cat, not copy. The doglines might just be that there are no lines with 'dog' in them. It looks right to me.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment