- This topic has 3개 답변, 2명 참여, and was last updated 14 years, 11 months 전에 by
태랑. This post has been viewed 885 times
-
-
설명을 만족하는 junk라는 유틸리티를 작성하시오.
Utility: junk [-lp] v filename
junk ~ rm 유틸리티와 비슷하다. 단, 파일을 제거하는 것이 아니라, 홈 디렉토리에 “junk”라는 서브디렉토리로 파일을 옮긴다. 만약 “junk”라는 디렉토리가 존재하지 않으면 자동적으로 생성 시킨다. –l 옵션은 “junk” 디렉토리의 현재 내용을 보여주고 -p옵션은 “junk” 디렉토리를 비운다.
예) 다음은 junk 작업의 한 예이다.
# ls –l test.c
-rw-r--r-- 1 kim 2580 May 25 12:10 test.c
# junk test.c
# ls –l test.c
test.c not found
# junk samp.c
# junk –l
-rw-r--r-- 1 kim 58 Aug 8 02:42 samp.c
-rw-r--r-- 1 kim 2580 May 25 12:10 test.c
# junk –p … junk 디렉토리에 있는 파일 제거
# junk –l … junk 디렉토리 내용표시
요런식인데
만들려고 하니까 자꾸 막히네요 ㅠ
junk test.c 하면 bash : junk : command not found 뜨고 진전이 안되네요
밑에 소스 보시고 도와주세요 ㅠ
1 #!/bin/sh
2
3 echo make a junk utility
4
5 # JUNK 디렉토리의 유무 조사 후 없으면 생성
6 if test ! -d JUNK
7 then
8 echo make JUNK directory
9 mkdir ./JUNK
10 else
11 echo JUNK directory is existed
12 fi
13
14 # -p 옵션은 junk 디렉토리를 비운다
15 if [ $1 = "-p" ]
16 then
17 echo delete file in JUNK directory
18 cd JUNK
19 rm -rf *
20 # -l 옵션은 junk 디렉토리의 내용을 출력
21 elif [ $1 = "-l" ]
22 then
23 echo list of direcrory
24 ls ./JUNK
25 else
26 # 삭제할 파일의 존재 파악
27 if test -r $1
28 # junk 디렉토리로 옮긴다
29 then
30 echo move file $1
31 mv $1 ./JUNK
32 # 파일이 존재하지 않을 경우
33 else
34 echo file is not existed
35 echo unnomal exit
이번에 공부하게 되었는데
페도라 리눅스에 대해 관심이 있어서 들어왔어요~
- 답변은 로그인 후 가능합니다.