2021년 10월 24일 일요일

디렉토리 및 파일 동시 생성

윈도우
C:\log>for /l %i in (1001, 1, 1023) do (mkdir %i && echo %i > %i\%i.log)
C:\log>dir /s/b *.log
C:\log\1001\1001.log
C:\log\1002\1002.log
C:\log\1003\1003.log
C:\log\1004\1004.log
C:\log\1005\1005.log
C:\log\1006\1006.log
C:\log\1007\1007.log
C:\log\1008\1008.log
C:\log\1009\1009.log
C:\log\1010\1010.log
C:\log\1011\1011.log
C:\log\1012\1012.log
C:\log\1013\1013.log
C:\log\1014\1014.log
C:\log\1015\1015.log
C:\log\1016\1016.log
C:\log\1017\1017.log
C:\log\1018\1018.log
C:\log\1019\1019.log
C:\log\1020\1020.log
C:\log\1021\1021.log
C:\log\1022\1022.log
C:\log\1023\1023.log

리눅스
root@MHKANG:/mnt/c/log# for((i=1001;i<1024;i++))
> do mkdir $i && echo $i > $i/$i.log
> done
root@MHKANG:/mnt/c/log# ll ./*/*.log
-rwxrwxrwx 1 root root 7 Oct 24 14:10 ./1001/1001.log*
-rwxrwxrwx 1 root root 7 Oct 24 14:10 ./1002/1002.log*
-rwxrwxrwx 1 root root 7 Oct 24 14:10 ./1003/1003.log*
-rwxrwxrwx 1 root root 7 Oct 24 14:10 ./1004/1004.log*
-rwxrwxrwx 1 root root 7 Oct 24 14:10 ./1005/1005.log*
-rwxrwxrwx 1 root root 7 Oct 24 14:10 ./1006/1006.log*
-rwxrwxrwx 1 root root 7 Oct 24 14:10 ./1007/1007.log*
-rwxrwxrwx 1 root root 7 Oct 24 14:10 ./1008/1008.log*
-rwxrwxrwx 1 root root 7 Oct 24 14:10 ./1009/1009.log*
-rwxrwxrwx 1 root root 7 Oct 24 14:10 ./1010/1010.log*
-rwxrwxrwx 1 root root 7 Oct 24 14:10 ./1011/1011.log*
-rwxrwxrwx 1 root root 7 Oct 24 14:10 ./1012/1012.log*
-rwxrwxrwx 1 root root 7 Oct 24 14:10 ./1013/1013.log*
-rwxrwxrwx 1 root root 7 Oct 24 14:10 ./1014/1014.log*
-rwxrwxrwx 1 root root 7 Oct 24 14:10 ./1015/1015.log*
-rwxrwxrwx 1 root root 7 Oct 24 14:10 ./1016/1016.log*
-rwxrwxrwx 1 root root 7 Oct 24 14:10 ./1017/1017.log*
-rwxrwxrwx 1 root root 7 Oct 24 14:10 ./1018/1018.log*
-rwxrwxrwx 1 root root 7 Oct 24 14:10 ./1019/1019.log*
-rwxrwxrwx 1 root root 7 Oct 24 14:10 ./1020/1020.log*
-rwxrwxrwx 1 root root 7 Oct 24 14:10 ./1021/1021.log*
-rwxrwxrwx 1 root root 7 Oct 24 14:10 ./1022/1022.log*
-rwxrwxrwx 1 root root 7 Oct 24 14:10 ./1023/1023.log*

하위 디렉토리 로그 취합

윈도우
C:\log>for /f %i in ('dir /b/s ^| find ".log"') do (type %i >> all.log)
C:\log>type all.log
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023

리눅스
root@MHKANG:/mnt/c/log# for i in `find . -name *.log`
> do cat $i >> all.log
> done
root@MHKANG:/mnt/c/log# cat all.log
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023

안 쓰니 다 까먹네. 

관련 글

댓글 없음:

댓글 쓰기

크리에이티브 커먼즈 라이선스