반응형
Original
Reindeer like to eat bananas.
해석
순록은 바나나를 먹는다.
단어
- Reindeer: 순록 (명사)
- like: 좋아하다 (동사)
- to eat: 먹다 (동사)
- bananas: 바나나 (명사)

반응형
Reindeer like to eat bananas.
순록은 바나나를 먹는다.
- Reindeer: 순록 (명사)
- like: 좋아하다 (동사)
- to eat: 먹다 (동사)
- bananas: 바나나 (명사)

간단한 파일 탐색을 위한 스크립트를 작성해보았다.
막강한 명령어인 find를 기반으로 동작하고 몇가지 옵션을 간편하게 적용할 수 있도록 해둔 것으로 이해하면 좋을 것 같다.
사용은 아래와 같다. (script의 이름은 대충 finder라고 지어뒀으니 마음에 드는 이름으로 바꿔서 쓰시길)
./finder.sh 경로이름 -i include -i want -e exclude -e trash -f json -h -o result.txt
여러가지 옵션을 지원하는데 간단하게 설명해보자면
#!/bin/bash
usage() {
echo "Usage: $0 path [-i include]... [-e exclude]... [-o output] [-h] [-f format]"
echo "Options:"
echo " path The directory path to search in."
echo " -i Include keyword in path (can be used multiple times)"
echo " -e Exclude keyword from path (can be used multiple times)"
echo " -o Output file path"
echo " -h Search hidden files"
echo " -f Output format: json or plain (default: plain)"
exit 1
}
declare -a includes
declare -a excludes
output=""
hidden="false"
format="plain"
# Capture the search path first
path="$1"
shift
# If no path or it starts with '-', show usage
if [ -z "$path" ] || [[ "$path" == -* ]]; then
usage
fi
while getopts "i:e:o:hf:" opt; do
case $opt in
i) includes+=("$OPTARG") ;;
e) excludes+=("$OPTARG") ;;
o) output="$OPTARG" ;;
h) hidden="true" ;;
f) format="$OPTARG" ;;
\?) usage ;;
esac
done
# Start constructing the find command
cmd="find '$path'"
# Handle hidden files
if [ "$hidden" != "true" ]; then
cmd="$cmd ! -path '*/.*'"
fi
# Handle include keywords
if [ "${#includes[@]}" -gt 0 ]; then
for keyword in "${includes[@]}"; do
cmd="$cmd -path '*$keyword*'"
done
fi
# Handle exclude keywords
for keyword in "${excludes[@]}"; do
cmd="$cmd ! -path '*$keyword*'"
done
# Add the print command
cmd="$cmd -print"
# Handle format
case "$format" in
json)
cmd="$cmd | sed 's/^/\"/' | sed 's/$/\",/' | (echo '['; cat; echo ']')"
;;
plain)
;; # Nothing to do here, as the default is to just print
*)
;; # Default case: just print
esac
# Handle output
if [ -n "$output" ]; then
cmd="$cmd > '$output'"
fi
eval "$cmd"
| [bash] 파일 크기 순으로 검색 (0) | 2023.12.12 |
|---|---|
| [bash] 명령어 반복 (0) | 2023.09.19 |
| [bash] bash를 이용한 json 파일 파싱 (0) | 2022.08.11 |
| [bash] 특정 길이의 무작위 문자열 획득 (0) | 2022.08.11 |
| [bash] 프로세스 존재 여부 확인 (0) | 2022.08.11 |
In the last 3,500 years, there have been approximately 230 years of peace throughout the civilized world.
지난 3,500년 동안 문명 세계 전체에서 약 230년 동안 평화가 있었습니다.
- last: 지난, 최근의 (형용사)
- approximately: 약 (부사)
- peace: 평화 (명사)
- throughout: ~동안에, ~전체에 걸쳐 (전치사)
- civilized: 문명적인, 교양 있는 (형용사)
- world: 세계 (명사)
