Bash script: Difference between revisions

From HPCWIKI
Jump to navigation Jump to search
No edit summary
(Fix unclosed wikitable: close {|/|} + remove orphan Status; stops sections being swallowed into table)
 
(8 intermediate revisions by 2 users not shown)
Line 1: Line 1:
A summary for some important Bash scripts
== Overview ==
{| class="wikitable"
 
|+
Bash script에 대한 기술 문서입니다.
!Command
 
!Description
=== Summary ===
|-
 
|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
* 언제 사용하는가? - 서버 구성, 성능 튜닝, 문제 해결 시
{| class="wikitable"
| -a
|It defines those variables or functions which are created or modified or exported
Example, These variables v1 and v2 can be accessed after executing the script
<code>#!/bin/bash</code>


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


<code>set -a</code>
이 문서가 존재하는 이유


<code>#Initialize three variables</code>
* Goal: Bash script에 대한 기술 정보 제공
* Scope: Bash script의 개념, 사용법, 설정
* Non-goals: 다른 주제로의 확장


<code>v1=78</code>
== Key Concepts ==


<code>v2=50</code>
{| class="wikitable"
! Concept
! Description
! Related
|-
|-
| -b
| Bash script
|It informs the job termination.
| HPC/서버 환경에서 중요한 기술 개념
|-
| [[Linux]], [[Server]]
| -B
|}
|To do the task of the brace expansion.
 
|-
== Detailed Explanation ==
| -C
|It disables the overwriting feature of the existing file
Example,
$ cat > testfile.txt


$ set -C
Bash 스크립트는 Linux/Unix 시스템에서 명령어를 자동화하고 작업을 효율적으로 관리하기 위한 스크립트 언어입니다.
* 무엇인가? Linux/Unix 명령어 자동화 스크립트 언어
* 왜 필요한가? 반복 작업 자동화, 시스템 관리, 배치 처리
* 언제 사용하는가? 서버 설정, 로그 분석, 백업, 배포 등
이 문서가 존재하는 이유
* Goal: Bash 스크립트의 주요 명령어, special parameters, set 옵션 설명 제공
* Scope: set 명령어 옵션, bash special parameters
* Non-goals: Bash 프로그래밍 상세, 함수/배열/제어문
== Best Practices ==


$ cat > testfile.txt.  # Could not overwrite testfile.txt
* 최신 버전 사용 권장
|-
* 공식 문서 참고
| -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
== References ==


myvar="Learn bash programming"
* [https://wiki.hpcmate.com Bash script]


<nowiki>#</nowiki>Set the set command without option and with variable
== Related Pages ==


set -- $myvar
* [[Linux]]
* [[Server]]
* [[Hardware]]
* [[Network]]


<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 12:47, 12 October 2026

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

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

→ Linux → Server → Hardware → Network