[ShellScript] 기초 템플릿
2023. 2. 28. 17:35ㆍDevelopers 공간 [Shorts]/Software Basic
광고
광고
728x90
반응형
<분류>
A. 수단
- OS/Platform/Tool : Linux, Kubernetes(k8s), Docker, AWS
- Package Manager : node.js, yarn, brew,
- Compiler/Transpillar : React, Nvcc, gcc/g++, Babel, Flutter
- Module Bundler : React, Webpack, Parcel
B. 언어
- C/C++, python, Javacsript, Typescript, Go-Lang, CUDA, Dart, HTML/CSS
C. 라이브러리 및 프레임워크 및 SDK
- OpenCV, OpenCL, FastAPI, PyTorch, Tensorflow, Nsight
1. What? (현상)
Shell Script 기초 템플릿이 필요합니다.
2. Why? (원인)
- 하기에 미리 만들어 놓고자 합니다.
3. How? (해결책)
- shell.sh
#/bin/bash # USAGE : shell.sh -user A export PARAMETER="mode1" export PARAMETER4=false PARAMETER_LIST=("A", "B", "C", "D") if [ $# -eq 0 ] then echo "Usage: ./shell.sh [options]" echo " " echo "options:" echo "-h, --help show brief help" echo "-user show user" exit 0 fi while test $# -gt 0; do case "$1" in -h|--help) echo "Usage: ./shell.sh [options]" echo " " echo "options:" echo "-user show user" exit 0 ;; -user) export PARAMETER2="$2" shift shift ;; *) break ;; esac done case "$PARAMETER" in "mode1") export PARAMETER3="TKAY_A100_TEMP_B000_000/abc" export PARAMETER4=true ;; *) echo "mode not supported1." exit 0 ;; esac SAVE_IFS=$IFS case "$PARAMETER" in "mode1") if $PARAMETER4; then if [[ $PARAMETER3 == TKAY_A[0-9][0-9][0-9]_*_B[0-9][0-9][0-9]_[0-9][0-9][0-9]/* ]]; then IFS='/' read -a vStr <<< $PARAMETER3 # Saparate with / IFS='_' read -a vStr2 <<< "${vStr[0]}" # Saparate with _ IFS=$SAVE_IFS NAME="${vStr2[0]}" VERSION="${vStr2[1]//A}" PARAMETER5="${NAME}+${VERSION}"; elif [[ $PARAMETER3 == TKOY_A[0-9][0-9][0-9]_*_M[0-9][0-9][0-9]_[0-9][0-9][0-9]/* ]]; then PARAMETER5="${PARAMETER}/${PARAMETER3}"; else PARAMETER5=" "; fi else echo "param not supported2." exit 0 fi ;; *) echo "mode not supported3." exit 0 ;; esac echo "This is $PARAMETER5" python3 file.py \ --param5=$PARAMETER5
728x90
반응형
'Developers 공간 [Shorts] > Software Basic' 카테고리의 다른 글
[Bash] Process 실행 후에 시간이 지난 후 진행이 안될 때 (0) | 2023.03.07 |
---|---|
[CMake] 기초 템플릿 (0) | 2023.03.01 |
[Terminology] WebApp, HybridApp, Responsive App, Platform, Framework... (0) | 2023.02.26 |
[Makefile] 기초 템플릿 (0) | 2023.02.16 |
[Git] src refspec BRANCH does not match any 에러 (0) | 2023.02.15 |