[완료]빈 파일 찾는 스크립트
글쓴이: intercrime / 작성시간: 목, 2009/04/30 - 1:37오후
스크립트에 입문하는 초보 입니다.
/test/ 경로에 시간마다 txt파일을 생성하고 있는데, 가끔씩 파일 생성이 누락되어
누락된 파일이 있는지 체크하는 스크립트를 작성하려고 합니다.
생성되는 파일명은 시간단위로 00.txt 01.txt 02.txt 03.txt ~ 23.txt 형식으로 파일이 생성됩니다.
어떤게 스크립트를 짜야 할지 난감하네요..도움 부탁 드립니다.
Forums:


-s
for f in *; do if [ ! -s $f ]; then echo $f is empty fi done같은 식으로 하면 됩니다.
bash script
#!/bin/bash for hour in {0,1}{0..9} 2{0..3}; do filename=${hour}.txt if [ ! -e $filename ]; then echo "$filename does not exist."; continue fi if [ ! -s $filename ]; then echo "$filename is empty file."; fi done참고:
http://www.gnu.org/software/bash/manual/bashref.html#Brace-Expansion
http://www.gnu.org/software/bash/manual/bashref.html#Bash-Conditional-Expressions
--------------------Signature--------------------
Light a candle before cursing the darkness.
댓글 달기