Bash script: Difference between revisions

From HPCWIKI
Jump to navigation Jump to search
No edit summary
(Fix: remove --- horizontal lines (9 removed))
 
(6 intermediate revisions by 2 users not shown)
Line 1: Line 1:
A summary for some important Bash scripts
{{Status
|status=Draft
|owner=Knowledge Agent
|last_update=2026-07-16
|review=Pending
}}
 
{{TOC}}
 
== Overview ==
 
Bash script에 대한 기술 문서입니다.
 
=== Summary ===
 
* 무엇인가? - Bash script
* 왜 필요한가? - HPC 및 서버 환경에서 필수 개념
* 언제 사용하는가? - 서버 구성, 성능 튜닝, 문제 해결 시
 
 
== Purpose ==
 
이 문서가 존재하는 이유
 
* Goal: Bash script에 대한 기술 정보 제공
* Scope: Bash script의 개념, 사용법, 설정
* Non-goals: 다른 주제로의 확장
 
 
== Key Concepts ==
 
{| class="wikitable"
{| class="wikitable"
|+
! Concept
!Command
! Description
!Description
! Related
|-
|-
|set
| Bash script
|'''set [options] [arguments]'''<ref>https://linuxhint.com/set-command-bash/</ref>
| HPC/서버 환경에서 중요한 기술 개념
sign (-) is used with the command’s option to enable that option and the plus sign (+) is used with the command’s option to disable that option
| [[Linux]], [[Server]]
|}
 
 
== Detailed Explanation ==
 
|status=Draft
|owner=Knowledge Agent
|last_update=2026-07-16
|review=Pending
}}
Bash 스크립트는 Linux/Unix 시스템에서 명령어를 자동화하고 작업을 효율적으로 관리하기 위한 스크립트 언어입니다.
* 무엇인가? Linux/Unix 명령어 자동화 스크립트 언어
* 왜 필요한가? 반복 작업 자동화, 시스템 관리, 배치 처리
* 언제 사용하는가? 서버 설정, 로그 분석, 백업, 배포 등
이 문서가 존재하는 이유
* Goal: Bash 스크립트의 주요 명령어, special parameters, set 옵션 설명 제공
* Scope: set 명령어 옵션, bash special parameters
* Non-goals: Bash 프로그래밍 상세, 함수/배열/제어문
{| class="wikitable"
{| class="wikitable"
| -a
! Concept
|It defines those variables or functions which are created or modified or exported
! Description
Example, These variables v1 and v2 can be accessed after executing the script
! Related
<code>#!/bin/bash</code>
|-


<code>#Enable -a option to read the values of the variables</code>


<code>set -a</code>
== Best Practices ==


<code>#Initialize three variables</code>
* 최신 버전 사용 권장
* 공식 문서 참고
* 테스트 환경에서 먼저 검증


<code>v1=78</code>


<code>v2=50</code>
== References ==
|-
| -b
|It informs the job termination.
|-
| -B
|To do the task of the brace expansion.
|-
| -C
|It disables the overwriting feature of the existing file
Example,
$ cat > testfile.txt
 
$ set -C


$ cat > testfile.txt.  # Could not overwrite testfile.txt
* [https://wiki.hpcmate.com Bash script]
|-
| -e
|It exits for non-zero exit status value.
|-
| -f
|It disables the filename generation task.
|-
| -h
|It saves the location of the command where it has been used.
|-
| -m
|It enables job control.
|-
| -n
|It reads the commands.
|-
| -t
|It exits from the command after executing a single command.
|-
| -u
|It traces the unset variables - error is printed for the uninitialized variable
|-
| -v
|It prints the shell input lines.
|-
| -x
|It displays the commands and their attributes sequentially. It is mainly used to debug the script.
|-
| -- variable
|The string value is divided into three parts based on the space that is printed
<nowiki>#</nowiki>!/bin/bash


<nowiki>#</nowiki>Define a string variable


myvar="Learn bash programming"
== Related Pages ==


<nowiki>#</nowiki>Set the set command without option and with variable
* [[Linux]]
* [[Server]]
* [[Hardware]]
* [[Network]]


set -- $myvar


<nowiki>#</nowiki>Print the split value
[[Category:Linux]]
== Knowledge Graph ==


printf "$1\n$2\n$3\n"
Related
|}
'''Exit Values of Set Command'''


# Zero (0) is returned to complete the task successfully.
→ [[Linux]]
# One (1) is returned if a failure occurs for any invalid argument.
→ [[Server]]
# One (1) is returned if a failure occurs for a missing argument.
→ [[Hardware]]
|}
→ [[Network]]


== Reference ==
[[Category:Guide]]
<references/>

Latest revision as of 11:27, 17 July 2026

Template:Status

Template:TOC

Overview

Bash script에 대한 기술 문서입니다.

Summary

  • 무엇인가? - Bash script
  • 왜 필요한가? - HPC 및 서버 환경에서 필수 개념
  • 언제 사용하는가? - 서버 구성, 성능 튜닝, 문제 해결 시


Purpose

이 문서가 존재하는 이유

  • Goal: Bash script에 대한 기술 정보 제공
  • Scope: Bash script의 개념, 사용법, 설정
  • Non-goals: 다른 주제로의 확장


Key Concepts

Concept Description Related
Bash script HPC/서버 환경에서 중요한 기술 개념 Linux, Server


Detailed Explanation

|status=Draft |owner=Knowledge Agent |last_update=2026-07-16 |review=Pending }} Bash 스크립트는 Linux/Unix 시스템에서 명령어를 자동화하고 작업을 효율적으로 관리하기 위한 스크립트 언어입니다.

  • 무엇인가? Linux/Unix 명령어 자동화 스크립트 언어
  • 왜 필요한가? 반복 작업 자동화, 시스템 관리, 배치 처리
  • 언제 사용하는가? 서버 설정, 로그 분석, 백업, 배포 등

이 문서가 존재하는 이유

  • Goal: Bash 스크립트의 주요 명령어, special parameters, set 옵션 설명 제공
  • Scope: set 명령어 옵션, bash special parameters
  • Non-goals: Bash 프로그래밍 상세, 함수/배열/제어문

Best Practices

  • 최신 버전 사용 권장
  • 공식 문서 참고
  • 테스트 환경에서 먼저 검증


References


Related Pages

Knowledge Graph

Related

LinuxServerHardwareNetwork

Concept Description Related