Commit 37138bf4 authored by platyhouse's avatar platyhouse

.

parent 2b37a47a
This diff is collapsed.
#!/bin/sh
# ptyFileRename: rename files from <SRC_GLOB> to <DST_GLOB> safely (no argv explosion)
# 사용법: ptyFileRename "*.sucess.body" "*.success"
# 규칙: SRC/DST 패턴 각각 정확히 하나의 '*'를 포함해야 하며, '*'의 내용은 그대로 치환됩니다.
set -eu
if [ $# -ne 2 ]; then
echo "사용법: $0 \"<SRC_GLOB>\" \"<DST_GLOB>\"" >&2
echo "예시 : $0 \"*.sucess.body\" \"*.success\"" >&2
exit 1
fi
SRC_GLOB=$1
DST_GLOB=$2
DRY_RUN=${DRY_RUN:-0} # DRY_RUN=1 ptyFileRename "*.sucess.body" "*.success"
# 각 패턴이 '*'를 정확히 1개 포함하는지 확인
count_star() { printf '%s' "$1" | tr -cd '*' | wc -c | tr -d ' '; }
[ "$(count_star "$SRC_GLOB")" = "1" ] || { echo "SRC_GLOB은 '*'를 정확히 1개 포함해야 합니다: $SRC_GLOB" >&2; exit 1; }
[ "$(count_star "$DST_GLOB")" = "1" ] || { echo "DST_GLOB은 '*'를 정확히 1개 포함해야 합니다: $DST_GLOB" >&2; exit 1; }
# 패턴을 prefix/suffix로 분해
SRC_PREFIX=${SRC_GLOB%%\**}
SRC_SUFFIX=${SRC_GLOB#*\*}
DST_PREFIX=${DST_GLOB%%\**}
DST_SUFFIX=${DST_GLOB#*\*}
# 재귀적으로 검색(글롭 확장은 find가 처리; 쉘 글롭 확장은 없음)
find . -type f -name "$SRC_GLOB" -print0 |
while IFS= read -r -d '' path; do
dir=${path%/*}
base=${path##*/}
# base = SRC_PREFIX + MID + SRC_SUFFIX 에서 MID 추출
MID=${base#"$SRC_PREFIX"}
MID=${MID%"$SRC_SUFFIX"}
new_base="${DST_PREFIX}${MID}${DST_SUFFIX}"
new_path="$dir/$new_base"
# 동일 파일명 존재 시 덮어쓰기 방지
if [ -e "$new_path" ] && [ "$new_path" != "$path" ]; then
echo "SKIP (exists): $new_path" >&2
continue
fi
if [ "$DRY_RUN" = "1" ]; then
echo "DRY-RUN: mv -- $path -> $new_path"
else
echo "mv: $path -> $new_path"
mv -- "$path" "$new_path"
fi
done
#!/bin/bash
find . -type f -exec grep "$1" {} +
#!/bin/bash
ps -ax | grep "$1"
#!/bin/bash
# ptyTmuxRunMulti
# 사용법: ./ptyTmuxRunMulti "<실행 커맨드>" <세션개수> "<세션 프리픽스>"
# 예: ./ptyTmuxRunMulti "php 3_embedding.php" 30 "chunks_"
# 인자 확인
if [ $# -ne 3 ]; then
echo "사용법: $0 \"<실행 커맨드>\" <세션개수> \"<세션 프리픽스>\""
exit 1
fi
CMD="$1"
NUM_SESSIONS="$2"
PREFIX="$3"
echo "=== ${NUM_SESSIONS}개의 tmux 세션을 '${PREFIX}1' ~ '${PREFIX}${NUM_SESSIONS}' 생성 ==="
for ((i=0; i<NUM_SESSIONS; i++)); do
SESSION_NAME="${PREFIX}${i}"
# 기존 세션 종료
if tmux has-session -t "$SESSION_NAME" 2>/dev/null; then
echo "세션 ${SESSION_NAME} 이미 존재 - 종료 후 재시작"
tmux kill-session -t "$SESSION_NAME"
fi
# 새 세션 생성 후 명령 실행
tmux new-session -d -s "$SESSION_NAME"
tmux send-keys -t "$SESSION_NAME" "$CMD $i $NUM_SESSIONS" C-m
echo "✅ 세션 ${SESSION_NAME} 시작됨"
sleep 0.1
done
echo ""
echo "=== 모든 세션 시작 완료 ==="
echo ""
echo "세션 목록 확인: tmux ls"
echo "예시 접속: tmux attach -t ${PREFIX}1"
echo "모든 세션 종료:"
echo "for i in \$(seq 1 ${NUM_SESSIONS}); do tmux kill-session -t ${PREFIX}\${i}; done"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment