learning the shell : 한파일을 subdirectory에 단번에 추가하자!!!
#!/bin/bash
############# start ##################
# copyright(c)조훈현
#시나리오 : 퇴근시간이 다되었고
#애인과 퇴근 1시간후에 약속이 되어있다.
#그런데 긴급한 상황으로 system에 1000명이 넘는 사용자의
#계정에 특정파일을 패치 해야한다.
#수동으로 한다면 4시간으로도 해결은 불가능하다.
#그러나 간단한 shell 프로그래밍은 애인과의 저녁시간을
#확보시켜준다.
#주의 : 단 사용자의 홈디렉토리가 한디렉토리의
#subdiretory 이어만 한다.
####################################
echo " input target file or directory: "
read target
echo " input destination directory : "
read destination
for dir in `ls -l $destination | grep '\<d' | cut -c 57-100`
do
cp -r $target /$destination/$dir
done
echo "complete copy!!!"
exit 0
############# E N D #############
만약 home디렉토리가 /home의 subdiretory가 아니라면
----------------------------------------------
for dir in `ls -l $destination | grep '\<d' | cut -c 57-100`
do
cp -r $target /$destination/$dir
done
----------------------------------------------
를 아래의
------------------------------------------------------------
for dir in `tail +$(cut -f 1,3 -d: /etc/passwd | grep -n 500 | cut -f 1 -d:) /etc/passwd | cut -f 6 -d:`
do
cp -r $target $dir
done
------------------------------------------------------------
로 치환한다
주의!! 이프로그램 실행으로 일어나는 어떠한 책임도 저작권자는 책임이 없음을 밝힙니다.
학습용으로 사용하시길 권장합니다.~~^^<div class='small'>[이 게시물은 관리자님에 의해 2011-10-31 17:32:05 Linux에서 이동 됨]</div>
############# start ##################
# copyright(c)조훈현
#시나리오 : 퇴근시간이 다되었고
#애인과 퇴근 1시간후에 약속이 되어있다.
#그런데 긴급한 상황으로 system에 1000명이 넘는 사용자의
#계정에 특정파일을 패치 해야한다.
#수동으로 한다면 4시간으로도 해결은 불가능하다.
#그러나 간단한 shell 프로그래밍은 애인과의 저녁시간을
#확보시켜준다.
#주의 : 단 사용자의 홈디렉토리가 한디렉토리의
#subdiretory 이어만 한다.
####################################
echo " input target file or directory: "
read target
echo " input destination directory : "
read destination
for dir in `ls -l $destination | grep '\<d' | cut -c 57-100`
do
cp -r $target /$destination/$dir
done
echo "complete copy!!!"
exit 0
############# E N D #############
만약 home디렉토리가 /home의 subdiretory가 아니라면
----------------------------------------------
for dir in `ls -l $destination | grep '\<d' | cut -c 57-100`
do
cp -r $target /$destination/$dir
done
----------------------------------------------
를 아래의
------------------------------------------------------------
for dir in `tail +$(cut -f 1,3 -d: /etc/passwd | grep -n 500 | cut -f 1 -d:) /etc/passwd | cut -f 6 -d:`
do
cp -r $target $dir
done
------------------------------------------------------------
로 치환한다
주의!! 이프로그램 실행으로 일어나는 어떠한 책임도 저작권자는 책임이 없음을 밝힙니다.
학습용으로 사용하시길 권장합니다.~~^^<div class='small'>[이 게시물은 관리자님에 의해 2011-10-31 17:32:05 Linux에서 이동 됨]</div>
게시판 목록
개발자팁
개발과 관련된 유용한 정보를 공유하세요.
질문은 QA에서 해주시기 바랍니다.
질문은 QA에서 해주시기 바랍니다.
| 번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|---|
| 56 | 기타 | 20년 전 | 6225 | ||
| 55 | 기타 | 20년 전 | 4812 | ||
| 54 | PHP | 20년 전 | 4253 | ||
| 53 | MySQL | 20년 전 | 4828 | ||
| 52 | JavaScript | 20년 전 | 5070 | ||
| 51 | 기타 | 20년 전 | 4084 | ||
| 50 | JavaScript | 20년 전 | 4063 | ||
| 49 | PHP | 20년 전 | 4627 | ||
| 48 | JavaScript | 20년 전 | 3995 | ||
| 47 | 기타 | 20년 전 | 3507 | ||
| 46 | JavaScript | 20년 전 | 4274 | ||
| 45 | JavaScript |
prosper
|
20년 전 | 4035 | |
| 44 | 기타 | 20년 전 | 3783 | ||
| 43 | 기타 | 20년 전 | 4221 | ||
| 42 | 기타 | 20년 전 | 3215 | ||
| 41 | 기타 | 20년 전 | 3412 | ||
| 40 | JavaScript | 20년 전 | 4383 | ||
| 39 | 기타 | 20년 전 | 4114 | ||
| 38 | 기타 | 21년 전 | 7139 | ||
| 37 | 기타 |
prosper
|
21년 전 | 4509 | |
| 36 | JavaScript |
prosper
|
21년 전 | 3570 | |
| 35 | 기타 | 21년 전 | 3721 | ||
| 34 | JavaScript | 21년 전 | 4564 | ||
| 33 | 기타 | 21년 전 | 4318 | ||
| 32 | JavaScript | 21년 전 | 3480 | ||
| 31 | 기타 | 21년 전 | 6429 | ||
| 30 | 기타 | 21년 전 | 5256 | ||
| 29 | JavaScript | 21년 전 | 4609 | ||
| 28 | MySQL |
prosper
|
21년 전 | 4812 | |
| 27 | MySQL | 21년 전 | 8167 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기