<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>개인 공부 저장용 Archives - 어제와 내일의 나 그 사이의 이야기</title>
	<atom:link href="https://lycos7560.com/category/etc/%ea%b0%9c%ec%9d%b8-%ea%b3%b5%eb%b6%80-%ec%a0%80%ec%9e%a5%ec%9a%a9/feed/" rel="self" type="application/rss+xml" />
	<link></link>
	<description>생각의 흐름을 타고 다니며 만드는 블로그</description>
	<lastBuildDate>Tue, 12 May 2026 22:30:47 +0000</lastBuildDate>
	<language>ko-KR</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://lycos7560.com/wp-content/uploads/2022/11/cropped-cropped-cropped-log-1-150x150-1-80x80.png</url>
	<title>개인 공부 저장용 Archives - 어제와 내일의 나 그 사이의 이야기</title>
	<link></link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>POSIX Shell: 환경변수(Environment Variable)</title>
		<link>https://lycos7560.com/etc/posix-shell-%ed%99%98%ea%b2%bd%eb%b3%80%ec%88%98environment-variable/40632/</link>
					<comments>https://lycos7560.com/etc/posix-shell-%ed%99%98%ea%b2%bd%eb%b3%80%ec%88%98environment-variable/40632/#respond</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Tue, 12 May 2026 22:15:59 +0000</pubDate>
				<category><![CDATA[개인 공부 저장용]]></category>
		<category><![CDATA[기타]]></category>
		<category><![CDATA[study]]></category>
		<category><![CDATA[공부]]></category>
		<category><![CDATA[기초]]></category>
		<guid isPermaLink="false">https://lycos7560.com/?p=40632</guid>

					<description><![CDATA[<p>환경변수는 시스템의 설정값이나 실행 경로 등, 운영체제 전반에 걸쳐 공유되어야 하는 정보를 담고 있습니다. 일반 변수 vs 환경 변수 가장 큰 차이점은 &#8216;전파(Inheritance)&#8217;입니다. export 명령어: 환경변수 만들기 일반 변수를 환경변수로 승격시킬 때 export를 사용합니다. 주요 표준 환경변수 POSIX 시스템(Linux, AIX 등)에서 미리 정의되어 자주 쓰이는 변수들입니다. 변수명 설명 $PATH 명령어를 찾을 디렉토리 경로 목록 (콜론 [&#8230;]</p>
<p>The post <a href="https://lycos7560.com/etc/posix-shell-%ed%99%98%ea%b2%bd%eb%b3%80%ec%88%98environment-variable/40632/">POSIX Shell: 환경변수(Environment Variable)</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></description>
										<content:encoded><![CDATA[				<div class="wp-block-uagb-table-of-contents uagb-toc__align-left uagb-toc__columns-1  uagb-block-59c788c2      "
					data-scroll= "1"
					data-offset= "30"
					style=""
				>
				<div class="uagb-toc__wrap">
						<div class="uagb-toc__title">
							목차						</div>
																						<div class="uagb-toc__list-wrap ">
						<ol class="uagb-toc__list"><li class="uagb-toc__list"><a href="#일반-변수-vs-환경-변수" class="uagb-toc-link__trigger">일반 변수 vs 환경 변수</a><li class="uagb-toc__list"><a href="#export-명령어-환경변수-만들기" class="uagb-toc-link__trigger">export 명령어: 환경변수 만들기</a><li class="uagb-toc__list"><a href="#주요-표준-환경변수" class="uagb-toc-link__trigger">주요 표준 환경변수</a><li class="uagb-toc__list"><a href="#실전-예제-path-변수-조작하기" class="uagb-toc-link__trigger">실전 예제: PATH 변수 조작하기</a><li class="uagb-toc__list"><a href="#환경변수-확인법" class="uagb-toc-link__trigger">환경변수 확인법</a><li class="uagb-toc__list"><a href="#주의사항-변수의-수명" class="uagb-toc-link__trigger">주의사항: 변수의 수명</a><li class="uagb-toc__list"><a href="#환경에-따른-분기-case문-결합" class="uagb-toc-link__trigger">환경에 따른 분기 (case문 결합)</a><li class="uagb-toc__list"><a href="#자식에서-export로-변경하면-부모도-영향을-받나" class="uagb-toc-link__trigger">자식에서 export로 변경하면 부모도 영향을 받나?</a><ul class="uagb-toc__list"><li class="uagb-toc__list"><a href="#왜-부모는-영향을-받지-않나" class="uagb-toc-link__trigger">왜 부모는 영향을 받지 않나?</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#예시-코드로-확인하기" class="uagb-toc-link__trigger">예시 코드로 확인하기</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#자식이-부모의-환경을-바꾸고-싶을-땐" class="uagb-toc-link__trigger">자식이 부모의 환경을 바꾸고 싶을 땐?</a></ul></ol>					</div>
									</div>
				</div>
			


<div style="height:50px" aria-hidden="true" class="wp-block-spacer"></div>



<p>환경변수는 시스템의 설정값이나 실행 경로 등, 운영체제 전반에 걸쳐 공유되어야 하는 정보를 담고 있습니다.</p>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">일반 변수 vs 환경 변수</h2>



<p>가장 큰 차이점은 &#8216;전파(Inheritance)&#8217;입니다.</p>



<ul class="wp-block-list">
<li><strong>일반 변수 (Local Variable):</strong> 현재 실행 중인 스크립트 내에서만 유효합니다.</li>



<li><strong>환경 변수 (Environment Variable):</strong> <code>export</code> 명령어를 통해 시스템의 &#8216;환경&#8217;으로 등록되어, 해당 쉘에서 실행하는 다른 스크립트나 프로그램에서도 읽을 수 있습니다.</li>
</ul>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">export 명령어: 환경변수 만들기</h2>



<p>일반 변수를 환경변수로 승격시킬 때 <code>export</code>를 사용합니다.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># 1. 선언과 동시에 export (가장 많이 쓰임)
export MY_APP_HOME="/usr/local/engcross"

# 2. 이미 있는 변수를 export
VERSION="2.1.0"
export VERSION</pre>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">주요 표준 환경변수</h2>



<p>POSIX 시스템(Linux, AIX 등)에서 미리 정의되어 자주 쓰이는 변수들입니다.</p>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><td><strong>변수명</strong></td><td><strong>설명</strong></td></tr></thead><tbody><tr><td><strong><code>$PATH</code></strong></td><td>명령어를 찾을 디렉토리 경로 목록 (콜론 <code>:</code>으로 구분)</td></tr><tr><td><strong><code>$HOME</code></strong></td><td>현재 사용자의 홈 디렉토리 경로</td></tr><tr><td><strong><code>$USER</code></strong></td><td>현재 접속한 사용자 이름</td></tr><tr><td><strong><code>$PWD</code></strong></td><td>현재 작업 디렉토리 (Print Working Directory)</td></tr><tr><td><strong><code>$LANG</code></strong></td><td>시스템 언어 및 인코딩 (예: <code>ko_KR.UTF-8</code>)</td></tr><tr><td><strong><code>$SHELL</code></strong></td><td>현재 사용 중인 쉘의 경로</td></tr></tbody></table></figure>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">실전 예제: PATH 변수 조작하기</h2>



<p>내가 만든 스크립트를 어디서든 파일명만 입력해서 실행하고 싶을 때 <code>$PATH</code>를 수정합니다.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#!/bin/sh

# 현재 PATH 끝에 내 스크립트 폴더 추가
export PATH="$PATH:/home/lycos7560/bin"

# 이제 /home/lycos7560/bin 안에 있는 파일들은 
# 절대 경로 없이 이름만으로 실행 가능합니다.</pre>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">환경변수 확인법</h2>



<ul class="wp-block-list">
<li><code>env</code>: 현재 설정된 모든 환경변수 목록 출력</li>



<li><code>printenv PATH</code>: 특정 환경변수(<code>PATH</code>)의 값만 출력</li>



<li><code>set</code>: 환경변수뿐만 아니라 일반 변수, 함수까지 모두 포함해서 출력</li>
</ul>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">주의사항: 변수의 수명</h2>



<p>스크립트 내부에서 <code>export</code>한 변수는 <strong>그 스크립트가 종료되면 사라집니다.</strong></p>



<ul class="wp-block-list">
<li><strong>부모 쉘(터미널)에 적용하고 싶다면?</strong></li>
</ul>



<p>스크립트를 실행할 때 <code>./script.sh</code>가 아닌 <code>source ./script.sh</code> 또는 <code>. ./script.sh</code>를 사용해야 합니다. (이를 <strong>Sourcing</strong>이라고 합니다.)</p>



<ul class="wp-block-list">
<li><strong>영구히 적용하고 싶다면?</strong></li>
</ul>



<p>사용자의 홈 디렉토리에 있는 <code>.profile</code> (또는 <code>.bash_profile</code>) 파일에 <code>export</code> 구문을 적어두어야 로그인할 때마다 로드됩니다.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">## parent.sh
#!/bin/sh
VAR1="Local"      # 일반 변수
export VAR2="Env" # 환경 변수

./child.sh        # 자식 프로세스 실행

## child.sh
#!/bin/sh
printf "VAR1: %s\n" "$VAR1" # 아무것도 안 나옴 (상속 안 됨)
printf "VAR2: %s\n" "$VAR2" # "Env" 출력 (상속 됨)

[결과]
$ ./parent.sh
VAR1: 
VAR2: Env

추가적으로 중요한 점은 자식이 가방(환경변수) 속 내용을 수정하거나 새 물건을 넣어도, 그 결과가 부모에게 돌아오지 않는다는 것입니다. 
자식이 종료되면 자식이 가졌던 가방 복사본은 그대로 파기되기 때문입니다.</pre>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">환경에 따른 분기 (case문 결합)</h2>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#!/bin/sh

# 실행 환경(USER)에 따라 다른 설정 적용
case "$USER" in
    root)
        export LOG_LEVEL="DEBUG"
        export APP_PATH="/opt/app"
        ;;
    lycos7560)
        export LOG_LEVEL="INFO"
        export APP_PATH="/home/lycos7560/app"
        ;;
    *)
        printf "허용되지 않은 사용자입니다.\n"
        exit 1
        ;;
esac

printf "사용자: %s, 로그레벨: %s\n" "$USER" "$LOG_LEVEL"</pre>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<p>환경변수는 스크립트가 외부 세계와 소통하는 통로입니다. </p>



<p><code>export</code>를 통해 내가 만든 설정값을 하위 프로그램에 전달하고, <code>$PATH</code>나 <code>$USER</code> 같은 시스템 변수를 이용해 상황에 맞는 유연한 스크립트를 작성해 보세요!</p>



<div style="height:50px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">자식에서 export로 변경하면 부모도 영향을 받나?</h2>



<p><strong>아니요. 부모는 전혀 영향을 받지 않습니다.</strong></p>



<p>이것은 쉘 스크립트 시스템의 아주 중요한 철칙인 <strong>&#8216;일방통행 상속&#8217;</strong> 때문입니다.</p>



<h3 class="wp-block-heading">왜 부모는 영향을 받지 않나?</h3>



<p>부모가 자식 프로세스를 만들 때, 부모의 환경변수를 그대로 주는 게 아니라 &#8216;복사본&#8217;을 복사해서 넘겨주기 때문입니다.</p>



<p>자식이 자기 손에 든 복사본 가방 안의 내용을 아무리 고치고 <code>export</code>를 다시 해도, 그것은 <strong>자신의 가방(자식 프로세스의 메모리)</strong> 내에서의 일일 뿐입니다. </p>



<p>부모의 가방(부모 프로세스의 메모리)은 멀리 떨어져서 보호받고 있습니다.</p>



<h3 class="wp-block-heading">예시 코드로 확인하기</h3>



<p>child.sh</p>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#!/bin/sh
export MY_VAL="Changed by Child"
printf "자식: 값을 변경했습니다 -> %s\n" "$MY_VAL"</pre>



<div style="height:10px" aria-hidden="true" class="wp-block-spacer"></div>



<p>parent.sh</p>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#!/bin/sh
export MY_VAL="Original Parent Value"

printf "부모: 실행 전 값 -> %s\n" "$MY_VAL"

# 자식 스크립트 실행
./child.sh

printf "부모: 자식 종료 후 값 -> %s\n" "$MY_VAL"</pre>



<div style="height:10px" aria-hidden="true" class="wp-block-spacer"></div>



<p>실행 결과:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">부모: 실행 전 값 -> Original Parent Value
자식: 값을 변경했습니다 -> Changed by Child
부모: 자식 종료 후 값 -> Original Parent Value</pre>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading">자식이 부모의 환경을 바꾸고 싶을 땐?</h3>



<p>자식 프로세스를 &#8216;별도로&#8217; 띄우지 않고, <strong>부모의 몸 안에서 직접 실행</strong>하게 하면 됩니다. </p>



<p>이것을 <strong>Sourcing(소싱</strong>)이라고 합니다.</p>



<ul class="wp-block-list">
<li><strong>일반 실행 (<code>./child.sh</code>):</strong> 새로운 자식 쉘을 생성 (부모 영향 X)</li>



<li><strong>소싱 실행 (<code>. ./child.sh</code>):</strong> 현재 부모 쉘에서 코드를 그대로 읽어서 실행 (부모 영향 O)</li>
</ul>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<p>이 개념은 보안과 안정성을 위한 개념입니다.</p>



<p>자식 프로그램이 멋대로 부모 시스템의 설정을 변경하면 문제가 되기 때문이죠.</p>



<p></p>
<p>The post <a href="https://lycos7560.com/etc/posix-shell-%ed%99%98%ea%b2%bd%eb%b3%80%ec%88%98environment-variable/40632/">POSIX Shell: 환경변수(Environment Variable)</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://lycos7560.com/etc/posix-shell-%ed%99%98%ea%b2%bd%eb%b3%80%ec%88%98environment-variable/40632/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>POSIX Shell: case 문</title>
		<link>https://lycos7560.com/etc/posix-shell-case-%eb%ac%b8/40629/</link>
					<comments>https://lycos7560.com/etc/posix-shell-case-%eb%ac%b8/40629/#respond</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Tue, 12 May 2026 22:07:50 +0000</pubDate>
				<category><![CDATA[개인 공부 저장용]]></category>
		<category><![CDATA[기타]]></category>
		<category><![CDATA[study]]></category>
		<category><![CDATA[공부]]></category>
		<category><![CDATA[기초]]></category>
		<guid isPermaLink="false">https://lycos7560.com/?p=40629</guid>

					<description><![CDATA[<p>if 문이 &#8220;예/아니오&#8221;라는 논리적 판단에 강하다면, case 문은 &#8220;이 값은 어디에 해당하나?&#8221;라는 패턴 매칭에 최적화되어 있습니다. 코드의 가독성을 높여주는 case 문의 모든 것을 알아봅니다. 기본 구조 case 문은 변수의 값을 여러 패턴과 비교하며, 처음으로 일치하는 블록을 실행합니다. 활용 가능한 패턴 종류 POSIX 표준에서 지원하는 패턴들입니다. 정규표현식과는 조금 다르니 주의하세요! 예제 ① 스크립트 인자(Argument) 처리 : [&#8230;]</p>
<p>The post <a href="https://lycos7560.com/etc/posix-shell-case-%eb%ac%b8/40629/">POSIX Shell: case 문</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></description>
										<content:encoded><![CDATA[				<div class="wp-block-uagb-table-of-contents uagb-toc__align-left uagb-toc__columns-1  uagb-block-66d4106a      "
					data-scroll= "1"
					data-offset= "30"
					style=""
				>
				<div class="uagb-toc__wrap">
						<div class="uagb-toc__title">
							목차						</div>
																						<div class="uagb-toc__list-wrap ">
						<ol class="uagb-toc__list"><li class="uagb-toc__list"><a href="#기본-구조" class="uagb-toc-link__trigger">기본 구조</a><li class="uagb-toc__list"><a href="#활용-가능한-패턴-종류" class="uagb-toc-link__trigger">활용 가능한 패턴 종류</a><li class="uagb-toc__list"><a href="#예제" class="uagb-toc-link__trigger">예제</a><li class="uagb-toc__list"><a href="#사용자-입력yn-대소문자-무시하기" class="uagb-toc-link__trigger">사용자 입력(y/n) 대소문자 무시하기</a><li class="uagb-toc__list"><a href="#고급-bash-전용-기능-주의사항" class="uagb-toc-link__trigger">고급: Bash 전용 기능 주의사항</a><li class="uagb-toc__list"><a href="#if-vs-case-언제-무엇을-쓸까" class="uagb-toc-link__trigger">if vs case: 언제 무엇을 쓸까?</a></ol>					</div>
									</div>
				</div>
			


<div style="height:50px" aria-hidden="true" class="wp-block-spacer"></div>



<p><code>if</code> 문이 &#8220;예/아니오&#8221;라는 논리적 판단에 강하다면, <strong><code>case</code> 문</strong>은 &#8220;이 값은 어디에 해당하나?&#8221;라는 <strong>패턴 매칭</strong>에 최적화되어 있습니다. </p>



<p>코드의 가독성을 높여주는 <code>case</code> 문의 모든 것을 알아봅니다.</p>



<h2 class="wp-block-heading">기본 구조</h2>



<p><code>case</code> 문은 변수의 값을 여러 패턴과 비교하며, 처음으로 일치하는 블록을 실행합니다.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">case "$변수" in
    패턴1)
        명령어
        ;;  # 블록 종료 (C의 break와 유사)
    패턴2|패턴3)
        명령어  # | 로 OR 조건 표현 가능
        ;;
    *)
        명령어  # 일치하는 패턴이 없을 때 (else 역할)
        ;;
esac  # case를 거꾸로 쓴 것</pre>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">활용 가능한 패턴 종류</h2>



<p>POSIX 표준에서 지원하는 패턴들입니다. 정규표현식과는 조금 다르니 주의하세요!</p>



<ul class="wp-block-list">
<li><code>*</code>: 모든 문자열과 일치 (Default 처리용)</li>



<li><code>?</code>: 임의의 문자 <strong>딱 1개</strong>와 일치</li>



<li><code>[abc]</code>: a, b, c 중 하나와 일치</li>



<li><code>[a-z]</code>: 소문자 a부터 z 사이의 문자 하나와 일치</li>



<li><code>pat1|pat2</code>: 패턴1 또는 패턴2 중 하나와 일치 (<strong>OR 조건</strong>)</li>
</ul>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">예제</h2>



<p>① 스크립트 인자(Argument) 처리 : 서비스 관리 스크립트(<code>start</code>, <code>stop</code> 등)를 만들 때 가장 많이 쓰이는 방식입니다.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#!/bin/sh

ACTION="$1"

case "$ACTION" in
    start)
        printf "서비스를 시작합니다...\n"
        ;;
    stop)
        printf "서비스를 중지합니다...\n"
        ;;
    restart|reload)
        printf "재시작/설정 로드를 수행합니다...\n"
        ;;
    status)
        printf "현재 상태를 확인합니다...\n"
        ;;
    *)
        printf "사용법: %s {start|stop|restart|status}\n" "$0"
        exit 1
        ;;
esac</pre>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<p>② 파일 확장자별 분기 처리 : <code>${FILE##*.}</code>와 조합하면 매우 강력해집니다.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#!/bin/sh

FILE="backup.tar.gz"
EXT="${FILE##*.}"

case "$EXT" in
    gz|tgz)
        printf "Gzip 압축 파일입니다. 해제 명령: tar xzf %s\n" "$FILE"
        ;;
    zip)
        printf "Zip 파일입니다. 해제 명령: unzip %s\n" "$FILE"
        ;;
    log)
        printf "로그 파일입니다. 실시간 모니터링을 시작합니다.\n"
        ;;
    *)
        printf "지원하지 않는 파일 형식입니다: %s\n" "$EXT"
        ;;
esac</pre>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">사용자 입력(y/n) 대소문자 무시하기</h2>



<p>사용자로부터 <code>yes</code>, <code>Yes</code>, <code>YES</code> 등을 한 번에 입력받고 싶을 때 대괄호(<code>[]</code>) 패턴이 유용합니다.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#!/bin/sh

printf "계속 진행하시겠습니까? [y/n]: "
read ANSWER

case "$ANSWER" in
    [yY]|[yY][eE][sS])
        printf "진행을 결정하셨습니다.\n"
        ;;
    [nN]|[nN][oO])
        printf "작업을 취소합니다.\n"
        exit 0
        ;;
    *)
        printf "잘못된 입력입니다. y 또는 n을 입력해 주세요.\n"
        exit 1
        ;;
esac</pre>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">고급: Bash 전용 기능 주의사항</h2>



<p>Bash 4.0 이상에서는 <code>;</code> 대신 <code>;&amp;</code> (fall-through)나 <code>;;&amp;</code> 등을 사용할 수 있지만, 이는 <strong>POSIX 표준이 아닙니다.</strong></p>



<ul class="wp-block-list">
<li><strong><code>; &amp;</code></strong>: 다음 패턴의 일치 여부와 상관없이 무조건 다음 블록을 실행합니다.</li>



<li><strong><code>;; &amp;</code></strong>: 다음 패턴들을 계속 검사하여 일치하는 것이 있다면 또 실행합니다.</li>
</ul>



<p><strong>POSIX 팁:</strong> 이식성이 중요한 스크립트에서는 오직 <code><strong>;;</strong></code>만 사용하세요. <code><strong>;</strong></code> 하나만 쓰거나 다른 기호를 섞으면 구형 쉘에서 에러가 납니다.</p>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">if vs case: 언제 무엇을 쓸까?</h2>



<ul class="wp-block-list">
<li><strong><code>if</code> 문이 유리할 때</strong>: 숫자 크기 비교(<code>-gt</code>, <code>-lt</code>), 복잡한 논리 조합(<code>&amp;&amp;</code>, <code>||</code>), 파일 존재 여부 확인 등.</li>



<li><strong><code>case</code> 문이 유리할 때</strong>: 하나의 변수 값이 특정 문자열 패턴 중 무엇인지 분류할 때 (3개 이상의 분기라면 <code>case</code>를 강력 추천).</li>
</ul>



<div style="height:50px" aria-hidden="true" class="wp-block-spacer"></div>



<p><code>case</code> 문을 사용하면 스크립트가 훨씬 읽기 쉬워지고 구조가 명확해집니다. </p>



<p>특히 인자 처리나 사용자 응답 처리에서 <code>case</code>를 활용해 보세요. 여러분의 코드가 한층 더 전문가답게 보일 것입니다!</p>



<p></p>
<p>The post <a href="https://lycos7560.com/etc/posix-shell-case-%eb%ac%b8/40629/">POSIX Shell: case 문</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://lycos7560.com/etc/posix-shell-case-%eb%ac%b8/40629/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>POSIX Shell: 변수(Variables) &#038; 문자열(String)</title>
		<link>https://lycos7560.com/etc/posix-shell-%eb%b3%80%ec%88%98variables-%eb%ac%b8%ec%9e%90%ec%97%b4string/40627/</link>
					<comments>https://lycos7560.com/etc/posix-shell-%eb%b3%80%ec%88%98variables-%eb%ac%b8%ec%9e%90%ec%97%b4string/40627/#respond</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Tue, 12 May 2026 21:50:52 +0000</pubDate>
				<category><![CDATA[개인 공부 저장용]]></category>
		<category><![CDATA[기타]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[study]]></category>
		<category><![CDATA[공부]]></category>
		<category><![CDATA[기초]]></category>
		<guid isPermaLink="false">https://lycos7560.com/?p=40627</guid>

					<description><![CDATA[<p>쉘 스크립트에서 변수는 별도의 선언(형식 지정) 없이 바로 사용할 수 있어 유연하지만, 그만큼 문법이 엄격한 부분도 있습니다. 특히 공백과 따옴표 사용법이 핵심입니다. 변수 선언과 사용 (Variables) Shell 변수는 선언 시 타입을 지정하지 않으며, 공백에 매우 민감합니다. 특수 변수 (Special Variables) 스크립트 실행 시 자동으로 할당되는 예약 변수들입니다. 변수 의미 예시 (./run.sh aix hacmp) $0 스크립트 [&#8230;]</p>
<p>The post <a href="https://lycos7560.com/etc/posix-shell-%eb%b3%80%ec%88%98variables-%eb%ac%b8%ec%9e%90%ec%97%b4string/40627/">POSIX Shell: 변수(Variables) &amp; 문자열(String)</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></description>
										<content:encoded><![CDATA[				<div class="wp-block-uagb-table-of-contents uagb-toc__align-left uagb-toc__columns-1  uagb-block-dfed9df5      "
					data-scroll= "1"
					data-offset= "30"
					style=""
				>
				<div class="uagb-toc__wrap">
						<div class="uagb-toc__title">
							목차						</div>
																						<div class="uagb-toc__list-wrap ">
						<ol class="uagb-toc__list"><li class="uagb-toc__list"><a href="#변수-선언과-사용-variables" class="uagb-toc-link__trigger">변수 선언과 사용 (Variables)</a><li class="uagb-toc__list"><a href="#특수-변수-special-variables" class="uagb-toc-link__trigger">특수 변수 (Special Variables)</a><li class="uagb-toc__list"><a href="#기본값-처리-default-values" class="uagb-toc-link__trigger">기본값 처리 (Default Values)</a><li class="uagb-toc__list"><a href="#패턴-제거-pattern-removal" class="uagb-toc-link__trigger">패턴 제거 (Pattern Removal)</a><li class="uagb-toc__list"><a href="#문자열-치환-및-대소문자-변환-bash-확장" class="uagb-toc-link__trigger">문자열 치환 및 대소문자 변환 (Bash 확장)</a><ul class="uagb-toc__list"><li class="uagb-toc__list"><a href="#문자열-치환" class="uagb-toc-link__trigger">문자열 치환</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#대소문자-변환" class="uagb-toc-link__trigger">대소문자 변환</a></li></ul></li><li class="uagb-toc__list"><a href="#문자열-분리-ifs-활용" class="uagb-toc-link__trigger">문자열 분리 (IFS 활용)</a></ul></ol>					</div>
									</div>
				</div>
			


<div style="height:50px" aria-hidden="true" class="wp-block-spacer"></div>



<p>쉘 스크립트에서 변수는 별도의 선언(형식 지정) 없이 바로 사용할 수 있어 유연하지만, 그만큼 문법이 엄격한 부분도 있습니다. </p>



<p>특히 <strong>공백</strong>과 <strong>따옴표</strong> 사용법이 핵심입니다.</p>



<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">변수 선언과 사용 (Variables)</h2>



<p>Shell 변수는 선언 시 타입을 지정하지 않으며, <strong>공백</strong>에 매우 민감합니다.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># 선언: = 앞뒤 공백 금지 (필수!)
NAME="lycos7560" 
COUNT=42 

# 사용: $ 또는 ${}를 사용
echo "$NAME"       # 일반적인 사용
echo "${NAME}"     # 경계를 명확히 할 때 권장
echo "User_${NAME}_log" # 변수명 뒤에 문자가 붙을 때 필수</pre>



<ul class="wp-block-list">
<li><strong><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/26a0.png" alt="⚠" class="wp-smiley" style="height: 1em; max-height: 1em;" /> 주의:</strong> <code>NAME = value</code>처럼 공백을 넣으면 시스템은 <code>NAME</code>을 변수가 아닌 <strong>명령어</strong>로 인식하여 에러(<code>command not found</code>)를 발생시킵니다</li>
</ul>



<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">특수 변수 (Special Variables)</h2>



<p>스크립트 실행 시 자동으로 할당되는 예약 변수들입니다.</p>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><td><strong>변수</strong></td><td><strong>의미</strong></td><td><strong>예시 (./run.sh aix hacmp)</strong></td></tr></thead><tbody><tr><td><strong><code>$0</code></strong></td><td>스크립트 이름</td><td><code>./run.sh</code></td></tr><tr><td><strong><code>$1</code> ~ <code>$9</code></strong></td><td>위치 매개변수 (인자)</td><td><code>$1</code>은 <code>aix</code>, <code>$2</code>는 <code>hacmp</code></td></tr><tr><td><strong><code>$#</code></strong></td><td>인자 개수</td><td><code>2</code></td></tr><tr><td><strong><code>$@</code></strong></td><td>모든 인자 (각각 분리)</td><td><code>"aix" "hacmp"</code></td></tr><tr><td><strong><code>$?</code></strong></td><td>마지막 명령어 종료 코드</td><td><code>0</code>(성공) 또는 <code>1~255</code>(실패)</td></tr><tr><td><strong><code>$$</code></strong></td><td>현재 프로세스 PID</td><td><code>1234</code></td></tr></tbody></table></figure>



<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">기본값 처리 (Default Values)</h2>



<p>변수가 비어있을 때를 대비한 방어적 코딩 기법입니다.</p>



<ul class="wp-block-list">
<li><strong><code>${VAR:-default}</code></strong>: <code>VAR</code>이 비어있으면 <code>default</code>를 사용 (변수 값은 유지)</li>



<li><strong><code>${VAR:=default}</code></strong>: <code>VAR</code>이 비어있으면 <code>default</code>를 <strong>변수에 대입</strong></li>



<li><strong><code>${VAR:?message}</code></strong>: <code>VAR</code>이 비어있으면 메시지 출력 후 <strong>스크립트 종료</strong></li>
</ul>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># 예시
HOST=""
printf "Connecting to %s...\n" "${HOST:-localhost}"  # localhost 출력</pre>



<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">패턴 제거 (Pattern Removal)</h2>



<p>파일 경로에서 파일명만 추출하거나 확장자를 뗄 때 가장 많이 사용하는 강력한 기능입니다.</p>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><td><strong>문법</strong></td><td><strong>설명</strong></td><td><strong>기억법</strong></td></tr></thead><tbody><tr><td><strong><code>${VAR#패턴}</code></strong></td><td>앞에서부터 <strong>최단</strong> 일치 제거</td><td><code>#</code>은 키보드 왼쪽(앞), 하나는 짧게</td></tr><tr><td><strong><code>${VAR##패턴}</code></strong></td><td>앞에서부터 <strong>최장</strong> 일치 제거</td><td><code>##</code>은 길게</td></tr><tr><td><strong><code>${VAR%패턴}</code></strong></td><td>뒤에서부터 <strong>최단</strong> 일치 제거</td><td><code>%</code>는 키보드 오른쪽(뒤), 하나는 짧게</td></tr><tr><td><strong><code>${VAR%%패턴}</code></strong></td><td>뒤에서부터 <strong>최장</strong> 일치 제거</td><td><code>%%</code>는 길게</td></tr></tbody></table></figure>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">FILE="/var/log/syslog.tar.gz"

echo "${FILE##*/}"  # syslog.tar.gz (경로 제거)
echo "${FILE%.*}"   # /var/log/syslog.tar (최종 확장자 제거)
echo "${FILE%%.*}"  # /var/log/syslog (모든 확장자 제거)
echo "${FILE%/*}"   # /var/log (디렉토리만 추출)

[결과]
$ ./01_hello.sh start
syslog.tar.gz
/var/log/syslog.tar
/var/log/syslog
/var/log</pre>



<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">문자열 치환 및 대소문자 변환 (Bash 확장)</h2>



<p><strong>주의:</strong> 아래 기능들은 <strong>Bash 4.0 이상</strong>에서 지원됩니다. </p>



<p>구형 AIX의 <code>/bin/sh</code>에서는 작동하지 않을 수 있으니 환경을 확인하세요.</p>



<h3 class="wp-block-heading">문자열 치환</h3>



<ul class="wp-block-list">
<li><code>${STR/old/new}</code>: 첫 번째 일치 항목만 치환</li>



<li><code>${STR//old/new}</code>: 모든 일치 항목 치환</li>
</ul>



<h3 class="wp-block-heading">대소문자 변환</h3>



<ul class="wp-block-list">
<li><code>${STR^^}</code>: 전체 대문자</li>



<li><code>${STR,,}</code>: 전체 소문자</li>
</ul>



<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">문자열 분리 (IFS 활용)</h2>



<p><code>IFS</code>(Internal Field Separator)는 쉘이 단어를 나누는 기준 문자입니다. </p>



<p>이를 변경하여 CSV 형태의 데이터를 쉽게 분리할 수 있습니다.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># 콜론(:)으로 구분된 데이터 파싱
LINE="hostname:192.168.1.1:8080"
IFS=":" read -r HOST IP PORT &lt;&lt; EOF
$LINE
EOF

printf "Host: %s, IP: %s, Port: %s\n" "$HOST" "$IP" "$PORT"</pre>



<div style="height:50px" aria-hidden="true" class="wp-block-spacer"></div>



<p>POSIX 표준 변수 처리(<code>${#}</code>, <code>${%}</code>)는 매우 빠르고 효율적입니다. </p>



<p><code>sed</code>나 <code>awk</code> 같은 외부 명령어를 호출하지 않고도 쉘 자체 기능만으로 문자열을 처리하는 습관을 들이면 스크립트의 성능이 비약적으로 향상됩니다!</p>



<p></p>
<p>The post <a href="https://lycos7560.com/etc/posix-shell-%eb%b3%80%ec%88%98variables-%eb%ac%b8%ec%9e%90%ec%97%b4string/40627/">POSIX Shell: 변수(Variables) &amp; 문자열(String)</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://lycos7560.com/etc/posix-shell-%eb%b3%80%ec%88%98variables-%eb%ac%b8%ec%9e%90%ec%97%b4string/40627/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>POSIX Shell: 표준 함수(Function)</title>
		<link>https://lycos7560.com/etc/posix-shell-%ed%91%9c%ec%a4%80-%ed%95%a8%ec%88%98function/40616/</link>
					<comments>https://lycos7560.com/etc/posix-shell-%ed%91%9c%ec%a4%80-%ed%95%a8%ec%88%98function/40616/#respond</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Tue, 12 May 2026 21:27:29 +0000</pubDate>
				<category><![CDATA[개인 공부 저장용]]></category>
		<category><![CDATA[기타]]></category>
		<category><![CDATA[study]]></category>
		<category><![CDATA[공부]]></category>
		<category><![CDATA[기초]]></category>
		<guid isPermaLink="false">https://lycos7560.com/?p=40616</guid>

					<description><![CDATA[<p>스크립트의 규모가 커지면 중복되는 코드를 줄이기 위해 함수(Function)를 사용해야 합니다. POSIX 표준을 따르면서 어디서나 잘 작동하는 함수 작성법을 알아봅니다. 기본 문법 가장 중요한 차이점은 function이라는 키워드를 쓰지 않는다는 것입니다. 인자 전달 (Arguments) 함수로 값을 보낼 때는 별도의 파라미터 이름을 정의하지 않고, 스크립트 실행 인자와 똑같이 위치 매개변수($1, $2, &#8230;)를 사용합니다. 변수 의미 $1, $2 첫 [&#8230;]</p>
<p>The post <a href="https://lycos7560.com/etc/posix-shell-%ed%91%9c%ec%a4%80-%ed%95%a8%ec%88%98function/40616/">POSIX Shell: 표준 함수(Function)</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></description>
										<content:encoded><![CDATA[				<div class="wp-block-uagb-table-of-contents uagb-toc__align-left uagb-toc__columns-1  uagb-block-19f9e4de      "
					data-scroll= "1"
					data-offset= "30"
					style=""
				>
				<div class="uagb-toc__wrap">
						<div class="uagb-toc__title">
							목차						</div>
																						<div class="uagb-toc__list-wrap ">
						<ol class="uagb-toc__list"><li class="uagb-toc__list"><a href="#기본-문법" class="uagb-toc-link__trigger">기본 문법</a><li class="uagb-toc__list"><a href="#인자-전달-arguments" class="uagb-toc-link__trigger">인자 전달 (Arguments)</a><li class="uagb-toc__list"><a href="#지역-변수-local-variables-주의사항" class="uagb-toc-link__trigger">지역 변수 (Local Variables) 주의사항</a><li class="uagb-toc__list"><a href="#반환값-return-value" class="uagb-toc-link__trigger">반환값 (Return Value)</a><ul class="uagb-toc__list"><li class="uagb-toc__list"><a href="#return-종료-상태-코드-반환" class="uagb-toc-link__trigger">① return: 종료 상태 코드 반환</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#printfecho-데이터-결과-반환" class="uagb-toc-link__trigger">② printf/echo: 데이터 결과 반환</a></li></ul></li><li class="uagb-toc__list"><a href="#로깅-함수-만들기" class="uagb-toc-link__trigger">로깅 함수 만들기</a><li class="uagb-toc__list"><a href="#핵심-요약-checklist" class="uagb-toc-link__trigger">핵심 요약 (Checklist)</a><li class="uagb-toc__list"><a href="#주의사항" class="uagb-toc-link__trigger">주의사항</a></ul></ol>					</div>
									</div>
				</div>
			


<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<p>스크립트의 규모가 커지면 중복되는 코드를 줄이기 위해 함수(Function)를 사용해야 합니다. </p>



<p>POSIX 표준을 따르면서 어디서나 잘 작동하는 함수 작성법을 알아봅니다.</p>



<h2 class="wp-block-heading">기본 문법</h2>



<p>가장 중요한 차이점은 <strong><code>function</code>이라는 키워드를 쓰지 않는다</strong>는 것입니다.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># POSIX 표준 방식 (권장 <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/2705.png" alt="✅" class="wp-smiley" style="height: 1em; max-height: 1em;" />)
함수이름() {
    # 실행할 내용
}

# Bash 전용 방식 (POSIX에서는 지양 <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/274c.png" alt="❌" class="wp-smiley" style="height: 1em; max-height: 1em;" />)
# function 함수이름 { ... }</pre>



<ul class="wp-block-list">
<li><strong>함수 정의</strong>: 반드시 함수를 <strong>호출하기 전</strong>에 먼저 정의되어 있어야 합니다. (보통 스크립트 상단에 배치)</li>



<li><strong>호출</strong>: 함수 이름만 적으면 실행됩니다. (괄호 <code>()</code> 없이 이름만 사용)</li>
</ul>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">인자 전달 (Arguments)</h2>



<p>함수로 값을 보낼 때는 별도의 파라미터 이름을 정의하지 않고, 스크립트 실행 인자와 똑같이 위치 매개변수(<code>$1</code>, <code>$2</code>, &#8230;)를 사용합니다.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">greet() {
    printf "안녕하세요, %s님!\n" "$1"
}

greet "홍길동"  # $1에 "홍길동"이 전달됨</pre>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><td><strong>변수</strong></td><td><strong>의미</strong></td></tr></thead><tbody><tr><td><code>$1</code>, <code>$2</code></td><td>첫 번째, 두 번째 인자</td></tr><tr><td><code>$#</code></td><td>함수에 전달된 인자의 총 개수</td></tr><tr><td><code>$@</code></td><td>전달된 모든 인자 목록</td></tr></tbody></table></figure>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">지역 변수 (Local Variables) 주의사항</h2>



<p>이 부분이 POSIX 표준의 가장 큰 제약사항입니다.</p>



<ul class="wp-block-list">
<li><strong>Bash</strong>:</li>
</ul>



<p><code>local</code> 키워드를 사용하여 함수 내부에서만 쓰는 변수를 만들 수 있습니다.</p>



<ul class="wp-block-list">
<li><strong>POSIX (sh)</strong>: </li>
</ul>



<p>표준에는 <strong><code>local</code> 키워드가 없습니다.</strong> </p>



<p>함수 안에서 선언한 변수도 기본적으로 전역 변수(Global)가 되어 스크립트 전체에 영향을 줍니다.</p>



<p><strong>해결책:</strong> 함수 내에서만 쓰는 변수는 <code>_var_name</code>처럼 앞에 언더바를 붙이거나, 이름이 겹치지 않게 주의해서 지어야 합니다.</p>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">반환값 (Return Value)</h2>



<p>함수의 실행 결과를 처리하는 방법은 두 가지입니다.</p>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><td><strong>구분</strong></td><td><strong>종료 상태 코드 (Exit Status)</strong></td><td><strong>표준 출력 (Standard Output)</strong></td></tr></thead><tbody><tr><td><strong>데이터 타입</strong></td><td>0 ~ 255 사이의 <strong>정수</strong></td><td><strong>문자열</strong> (텍스트 데이터)</td></tr><tr><td><strong>확인 방법</strong></td><td><code>$?</code> 변수로 확인</td><td><code>$(함수이름)</code> (명령어 치환)으로 캡처</td></tr><tr><td><strong>주 용도</strong></td><td>성공(0) 또는 실패(그 외) 판별</td><td>처리된 결과값 전달 (이름, 날짜 등)</td></tr><tr><td><strong>비유</strong></td><td>&#8220;내 일 잘 끝냈어!&#8221; (결과 보고서의 합격/불합격 도장)</td><td>&#8220;내가 만든 결과물이야.&#8221; (결과 보고서의 내용물)</td></tr></tbody></table></figure>



<h3 class="wp-block-heading">① <code>return</code>: 종료 상태 코드 반환</h3>



<p>숫자(0~255)만 반환할 수 있으며, 주로 성공(0)과 실패(그 외)를 알리는 용도입니다.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">is_file_exist() {
    if [ -f "$1" ]; then
        return 0 # 성공
    else
        return 1 # 실패
    fi
}</pre>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading">② <code>printf</code>/<code>echo</code>: 데이터 결과 반환</h3>



<p>문자열이나 계산 결과 자체를 받아야 할 때는 출력문을 이용하고 명령어 치환(<code>$()</code>)으로 낚아챕니다.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">get_date() {
    printf "%s" "$(date +%Y-%m-%d)"
}

TODAY=$(get_date)
printf "오늘 날짜: %s\n" "$TODAY"</pre>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<p>간단한 예시</p>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#!/bin/sh

get_user_status() {
    _USER_NAME="TestUser1"  # 실제 사용자 이름을 여기에 설정
    
    if [ "$_USER_NAME" = "TestUser" ]; then
        # 1. 표준 출력으로 문자열을 내보냄 (반환 문자열)
        printf "Active User"
        # 2. 종료 코드로 성공을 알림 (명령어 마지막 실행 결과가 0)
        return 0
    else
        printf "Unknown"
        return 1
    fi
}

# 실행 및 데이터 캡처
STATUS_TEXT=$(get_user_status)  # "Active User"가 변수에 저장됨 , 출력 문자열($()): 함수가 무슨 데이터를 만들었는지 알려줌 (실제 값)
STATUS_CODE=$?                  # 0이 변수에 저장됨

printf "문자열 결과: %s\n" "$STATUS_TEXT"
printf "상태 코드: %d\n" "$STATUS_CODE"</pre>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">로깅 함수 만들기</h2>



<p>실제 프로젝트에서 유용하게 쓸 수 있는 메시지 출력 함수 예시입니다.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#!/bin/sh

# 로깅 함수 정의
log_message() {
    _LEVEL="$1"
    _MSG="$2"
    _TIME=$(date '+%H:%M:%S')

    # 형식: [시간] [로그레벨] 메시지
    printf "[%s] [%s] %s\n" "$_TIME" "$_LEVEL" "$_MSG"
}

# 함수 호출
log_message "INFO" "애플리케이션을 시작합니다."
log_message "WARN" "설정 파일이 없습니다. 기본값을 사용합니다."


if [ "$?" -eq 0 ]; then                                  # 상태 코드($?): 마지막 함수가 어떻게 끝났는지 알려줌 (성공/실패)
    log_message "SUCCESS" "작업이 성공적으로 끝났습니다."
fi</pre>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">핵심 요약 (Checklist)</h2>



<ul class="wp-block-list">
<li><strong><code>function</code> 키워드는 빼자</strong>: 그냥 <code>name() { ... }</code> 형식을 사용하세요.</li>



<li><strong><code>local</code>은 표준이 아니다</strong>: 변수 이름 충돌에 주의하세요.</li>



<li><strong>인자는 <code>$1</code>, <code>$2</code>로</strong>: 함수 호출 시 옆에 나열하면 됩니다.</li>



<li><strong>복잡한 결과는 <code>printf</code>로</strong>: 값을 돌려받고 싶을 땐 출력을 이용하세요.</li>
</ul>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">주의사항</h2>



<p> &#8220;출력되는 모든 것&#8221; : 함수 안에서 <code>printf</code>나 <code>echo</code>로 찍는 <strong>모든 내용</strong>은 밖에서 <code>$( )</code>로 감싸는 순간 하나의 <strong>반환 문자열</strong>로 합쳐집니다.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">my_func() {
    printf "Hello "
    printf "World"
}

RESULT=$(my_func)
# RESULT에는 "Hello World"가 들어갑니다.</pre>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<p><code>$?</code> 사용 시 주의 : <code>$?</code>는 <strong>바로 직전 명령의 상태코드</strong>라서 즉시 변수에 저장하는 습관이 중요해요.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">STATUS_CODE=$?   # 이 줄은 OK

# 하지만 이런 경우 주의!
some_func
echo "결과 출력"   # 이 줄이 실행되면 $?가 덮어씌워짐
echo $?            # some_func의 코드가 아님!</pre>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<p><code>$()</code>와 서브쉘 비용</p>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">RESULT=$(my_func)  # 서브쉘이 생성됨 → 성능 비용 있음</pre>



<p></p>
<p>The post <a href="https://lycos7560.com/etc/posix-shell-%ed%91%9c%ec%a4%80-%ed%95%a8%ec%88%98function/40616/">POSIX Shell: 표준 함수(Function)</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://lycos7560.com/etc/posix-shell-%ed%91%9c%ec%a4%80-%ed%95%a8%ec%88%98function/40616/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>POSIX Shell: if</title>
		<link>https://lycos7560.com/etc/posix-shell-if/40609/</link>
					<comments>https://lycos7560.com/etc/posix-shell-if/40609/#respond</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Tue, 12 May 2026 21:11:09 +0000</pubDate>
				<category><![CDATA[개인 공부 저장용]]></category>
		<category><![CDATA[기타]]></category>
		<category><![CDATA[study]]></category>
		<category><![CDATA[공부]]></category>
		<category><![CDATA[기초]]></category>
		<guid isPermaLink="false">https://lycos7560.com/?p=40609</guid>

					<description><![CDATA[<p>쉘 스크립트에서 if문은 프로그램의 흐름을 결정하는 핵심입니다. 하지만 #!/bin/sh 환경에서는 우리가 흔히 쓰는 Bash 전용 문법([[ ]])을 사용할 수 없습니다. 어디서나 돌아가는 견고한 스크립트를 위한 POSIX 표준 if 문법을 정리합니다. 기본 구조 가장 중요한 것은 if, then, fi의 짝을 맞추는 것입니다. 주의: [ 뒤와 ] 앞에는 반드시 공백이 있어야 합니다. [는 사실 test라는 이름의 명령어이기 [&#8230;]</p>
<p>The post <a href="https://lycos7560.com/etc/posix-shell-if/40609/">POSIX Shell: if</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></description>
										<content:encoded><![CDATA[				<div class="wp-block-uagb-table-of-contents uagb-toc__align-left uagb-toc__columns-1  uagb-block-9a16a507      "
					data-scroll= "1"
					data-offset= "30"
					style=""
				>
				<div class="uagb-toc__wrap">
						<div class="uagb-toc__title">
							목차						</div>
																						<div class="uagb-toc__list-wrap ">
						<ol class="uagb-toc__list"><li class="uagb-toc__list"><a href="#기본-구조" class="uagb-toc-link__trigger">기본 구조</a><li class="uagb-toc__list"><a href="#문자열-비교-string-comparison" class="uagb-toc-link__trigger">문자열 비교 (String Comparison)</a><li class="uagb-toc__list"><a href="#숫자-비교-integer-comparison" class="uagb-toc-link__trigger">숫자 비교 (Integer Comparison)</a><li class="uagb-toc__list"><a href="#파일-상태-확인-file-test" class="uagb-toc-link__trigger">파일 상태 확인 (File Test)</a><li class="uagb-toc__list"><a href="#논리-연산-and-or" class="uagb-toc-link__trigger">논리 연산 (AND, OR)</a><li class="uagb-toc__list"><a href="#사용-예시" class="uagb-toc-link__trigger">사용 예시</a></ol>					</div>
									</div>
				</div>
			


<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<p>쉘 스크립트에서 <code>if</code>문은 프로그램의 흐름을 결정하는 핵심입니다. </p>



<p>하지만 <code>#!/bin/sh</code> 환경에서는 우리가 흔히 쓰는 Bash 전용 문법(<code>[[ ]]</code>)을 사용할 수 없습니다. </p>



<p>어디서나 돌아가는 견고한 스크립트를 위한 <strong>POSIX 표준 if 문법</strong>을 정리합니다.</p>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">기본 구조</h2>



<p>가장 중요한 것은 <strong><code>if</code></strong>, <strong><code>then</code></strong>, <code><strong>fi</strong></code>의 짝을 맞추는 것입니다.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">if [ 조건식 ]; then
    # 조건이 참(True)일 때 실행
elif [ 조건식 ]; then
    # 앞의 조건이 거짓이고, 현재 조건이 참일 때 실행
else
    # 모든 조건이 거짓일 때 실행
fi</pre>



<div style="height:10px" aria-hidden="true" class="wp-block-spacer"></div>



<p><strong>주의:</strong> <code>[</code> 뒤와 <code>]</code> 앞에는 반드시 <strong>공백</strong>이 있어야 합니다. <code>[</code>는 사실 <code>test</code>라는 이름의 명령어이기 때문입니다.</p>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">문자열 비교 (String Comparison)</h2>



<p>문자열을 비교할 때는 <code>=</code>와 <code>!=</code>를 사용합니다.</p>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><td><strong>조건식</strong></td><td><strong>설명</strong></td></tr></thead><tbody><tr><td><code>[ "$A" = "$B" ]</code></td><td>A와 B가 같으면 참</td></tr><tr><td><code>[ "$A" != "$B" ]</code></td><td>A와 B가 다르면 참</td></tr><tr><td><code>[ -z "$A" ]</code></td><td>문자열 A의 길이가 0이면 참 (Empty)</td></tr><tr><td><code>[ -n "$A" ]</code></td><td>문자열 A의 길이가 0이 아니면 참 (Not Empty)</td></tr></tbody></table></figure>



<p><strong>핵심 팁:</strong> 변수는 반드시 <strong>쌍따옴표(<code>" "</code>)</strong>로 감싸세요. </p>



<p>변수가 비어있을 경우 발생할 수 있는 구문 오류를 방지해줍니다.</p>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">숫자 비교 (Integer Comparison)</h2>



<p>숫자는 부등호(<code>&lt;</code>, <code>></code>) 대신 <strong>문자 약어</strong>를 사용합니다.</p>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><td><strong>조건식</strong></td><td><strong>의미</strong></td><td><strong>Full Name</strong></td></tr></thead><tbody><tr><td><code>[ "$A" -eq "$B" ]</code></td><td>같음</td><td><strong>Eq</strong>ual</td></tr><tr><td><code>[ "$A" -ne "$B" ]</code></td><td>다름</td><td><strong>N</strong>ot <strong>E</strong>qual</td></tr><tr><td><code>[ "$A" -gt "$B" ]</code></td><td>초과</td><td><strong>G</strong>reater <strong>T</strong>han</td></tr><tr><td><code>[ "$A" -ge "$B" ]</code></td><td>이상</td><td><strong>G</strong>reater or <strong>E</strong>qual</td></tr><tr><td><code>[ "$A" -lt "$B" ]</code></td><td>미만</td><td><strong>L</strong>ess <strong>T</strong>han</td></tr><tr><td><code>[ "$A" -le "$B" ]</code></td><td>이하</td><td><strong>L</strong>ess or <strong>E</strong>qual</td></tr></tbody></table></figure>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">파일 상태 확인 (File Test)</h2>



<p>쉘 스크립트에서 가장 많이 쓰이는 강력한 기능입니다.</p>



<ul class="wp-block-list">
<li><code>[ -f "file" ]</code>: 일반 <strong>파일</strong>이 존재하면 참</li>



<li><code>[ -d "dir" ]</code>: <strong>디렉토리</strong>가 존재하면 참</li>



<li><code>[ -e "path" ]</code>: 파일이든 디렉토리든 <strong>존재</strong>만 하면 참</li>



<li><code>[ -r "file" ]</code>: 읽기 권한이 있으면 참</li>



<li><code>[ -x "file" ]</code>: 실행 권한이 있으면 참</li>
</ul>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">논리 연산 (AND, OR)</h2>



<p>여러 조건을 조합할 때 POSIX에서는 두 가지 방법을 씁니다.</p>



<p><strong><code>-a</code> (AND), <code>-o</code> (OR)</strong>: 하나의 <code>[ ]</code> 안에서 사용</p>



<ul class="wp-block-list">
<li><code>if [ "$A" = "1" -a "$B" = "2" ]</code></li>
</ul>



<p><strong><code>&amp;&amp;</code>, <code>||</code> 활용</strong>: 여러 개의 <code>[ ]</code>를 연결 (<strong>더 권장됨</strong>)</p>



<ul class="wp-block-list">
<li><code>if [ "$A" = "1" ] &amp;&amp; [ "$B" = "2" ]</code></li>
</ul>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">사용 예시</h2>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#!/bin/sh

APP_NAME="TestApp"
CONFIG_FILE="./config.conf"
DEBUG_MODE="ON"

printf "시스템 체크를 시작합니다...\n"

# 1. 설정 파일 존재 여부 체크 (파일 테스트)
if [ -f "$CONFIG_FILE" ]; then
    printf "[OK] 설정 파일을 찾았습니다.\n"
else
    printf "[Error] %s 파일이 없습니다.\n" "$CONFIG_FILE"
    # exit 1  # 실제 스크립트라면 여기서 종료 가능
fi

# 2. 디버그 모드 확인 (문자열 비교)
if [ "$DEBUG_MODE" = "ON" ]; then
    printf "[Log] 디버그 모드가 활성화되어 있습니다.\n"
fi

# 3. 인자 개수 확인 (숫자 비교)
# $#는 스크립트에 전달된 인자의 개수입니다.
if [ "$#" -lt 1 ]; then
    printf "사용법: %s [start|stop]\n" "$0"
else
    if [ "$1" = "start" ]; then
        printf "%s을 시작합니다...\n" "$APP_NAME"
    elif [ "$1" = "stop" ]; then
        printf "%s을 중지합니다...\n" "$APP_NAME"
    else
        printf "알 수 없는 명령입니다: %s\n" "$1"
    fi
fi





$ ./01_hello.sh start
시스템 체크를 시작합니다...
[OK] 설정 파일을 찾았습니다.
[Log] 디버그 모드가 활성화되어 있습니다.
TestApp을 시작합니다...</pre>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<p></p>
<p>The post <a href="https://lycos7560.com/etc/posix-shell-if/40609/">POSIX Shell: if</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://lycos7560.com/etc/posix-shell-if/40609/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>POSIX Shell: printf</title>
		<link>https://lycos7560.com/etc/posix-bash-printf/40604/</link>
					<comments>https://lycos7560.com/etc/posix-bash-printf/40604/#respond</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Tue, 12 May 2026 20:50:44 +0000</pubDate>
				<category><![CDATA[개인 공부 저장용]]></category>
		<category><![CDATA[기타]]></category>
		<category><![CDATA[study]]></category>
		<category><![CDATA[공부]]></category>
		<category><![CDATA[기초]]></category>
		<guid isPermaLink="false">https://lycos7560.com/?p=40604</guid>

					<description><![CDATA[<p>쉘 스크립트를 작성할 때 단순히 메시지를 출력하기 위해 echo를 자주 사용합니다. 하지만 스크립트가 복잡해지고 여러 환경에서의 이식성(Portability)이 중요해지면 printf를 사용하는 것이 개발자 정신 건강에 좋다. echo 대신 printf? 특징 echo printf 표준 준수 시스템/쉘마다 동작이 다름 (비표준) POSIX 표준 — 어디서나 동일하게 동작 제어 능력 단순 출력에 최적화 포맷 지정자를 통한 세밀한 제어 가능 개행(줄바꿈) [&#8230;]</p>
<p>The post <a href="https://lycos7560.com/etc/posix-bash-printf/40604/">POSIX Shell: printf</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></description>
										<content:encoded><![CDATA[				<div class="wp-block-uagb-table-of-contents uagb-toc__align-left uagb-toc__columns-1  uagb-block-db47f186      "
					data-scroll= "1"
					data-offset= "30"
					style=""
				>
				<div class="uagb-toc__wrap">
						<div class="uagb-toc__title">
							목차						</div>
																						<div class="uagb-toc__list-wrap ">
						<ol class="uagb-toc__list"><li class="uagb-toc__list"><a href="#echo-대신-printf" class="uagb-toc-link__trigger">echo 대신 printf?</a><li class="uagb-toc__list"><a href="#기본-문법" class="uagb-toc-link__trigger">기본 문법</a><li class="uagb-toc__list"><a href="#핵심-포맷-지정자-format-specifiers" class="uagb-toc-link__trigger">핵심 포맷 지정자 (Format Specifiers)</a><li class="uagb-toc__list"><a href="#고급-제어-너비-정렬-정밀도" class="uagb-toc-link__trigger">고급 제어: 너비, 정렬, 정밀도</a><li class="uagb-toc__list"><a href="#실전-예제-코드" class="uagb-toc-link__trigger">실전 예제 코드</a><li class="uagb-toc__list"><a href="#이스케이프-시퀀스-escape-sequences" class="uagb-toc-link__trigger">이스케이프 시퀀스 (Escape Sequences)</a></ol>					</div>
									</div>
				</div>
			


<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>



<p>쉘 스크립트를 작성할 때 단순히 메시지를 출력하기 위해 <code>echo</code>를 자주 사용합니다. </p>



<p>하지만 스크립트가 복잡해지고 여러 환경에서의 이식성(Portability)이 중요해지면 <code>printf</code>를 사용하는 것이 개발자 정신 건강에 좋다.</p>



<h2 class="wp-block-heading">echo 대신 printf?</h2>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><td><strong>특징</strong></td><td><strong>echo</strong></td><td><strong>printf</strong></td></tr></thead><tbody><tr><td><strong>표준 준수</strong></td><td>시스템/쉘마다 동작이 다름 (비표준)</td><td><strong>POSIX 표준</strong> — 어디서나 동일하게 동작</td></tr><tr><td><strong>제어 능력</strong></td><td>단순 출력에 최적화</td><td>포맷 지정자를 통한 세밀한 제어 가능</td></tr><tr><td><strong>개행(줄바꿈)</strong></td><td>자동으로 줄을 바꿈</td><td><code>\n</code>을 명시해야 함 (의도적 제어 가능)</td></tr><tr><td><strong>신뢰도</strong></td><td><code>-e</code>, <code>-n</code> 옵션 등이 환경마다 다름</td><td>일관된 결과 보장 (이식성 높음)</td></tr></tbody></table></figure>



<p><strong>결론:</strong> 단순한 확인용 출력은 <code>echo</code>가 편하지만, 표(Table)를 만들거나 진법 변환, 정교한 텍스트 배치가 필요하다면 <code>printf</code>를 사용하는 것이 좋다.</p>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">기본 문법</h2>



<p><code>printf</code>는 포맷 문자열(Format String)을 먼저 정의하고, 그 뒤에 들어갈 인자(Arguments)를 순서대로 나열하는 문법 체계를 가지고 있다.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">printf "포맷문자열" [인자1] [인자2] ...</pre>



<ul class="wp-block-list">
<li><strong>특징</strong>: 인자의 개수가 포맷 지정자보다 많으면, 포맷 문자열을 <strong>반복</strong>해서 적용합니다.</li>



<li><strong>주의</strong>: 자동으로 줄바꿈을 하지 않으므로 문자열 끝에 <code>\n</code>을 붙여야 합니다</li>
</ul>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">핵심 포맷 지정자 (Format Specifiers)</h2>



<p>인자의 데이터 타입에 맞는 지정자를 사용해야 합니다.</p>



<ul class="wp-block-list">
<li><code>%s</code>: <strong>S</strong>tring (문자열)</li>



<li><code>%d</code>: <strong>D</strong>ecimal (10진수 정수)</li>



<li><code>%f</code>: <strong>F</strong>loat (부동소수점 실수)</li>



<li><code>%x</code>: He<strong>x</strong>adecimal (16진수 소문자)</li>



<li><code>%o</code>: <strong>O</strong>ctal (8진수)</li>



<li><code>%%</code>: <code>%</code> 기호 자체를 출력</li>
</ul>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">고급 제어: 너비, 정렬, 정밀도</h2>



<p><code>printf</code>의 진가는 데이터를 예쁘게 정렬할 때 나타납니다.</p>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><td><strong>포맷</strong></td><td><strong>설명</strong></td></tr></thead><tbody><tr><td><code>%10s</code></td><td>최소 10자 너비 확보, <strong>오른쪽</strong> 정렬</td></tr><tr><td><code>%-10s</code></td><td>최소 10자 너비 확보, <strong>왼쪽</strong> 정렬</td></tr><tr><td><code>%.2f</code></td><td>소수점 아래 <strong>2자리</strong>까지 출력</td></tr><tr><td><code>%8.2f</code></td><td>전체 8칸 확보 후 소수점 2자리 출력</td></tr></tbody></table></figure>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">실전 예제 코드</h2>



<p>기본 출력 및 진법 변환</p>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># 이름과 나이 출력
printf "이름: %s, 나이: %d\n" "Kim" 30

# 10진수 255를 16진수로 변환 (결과: 0xff)
printf "16진수 변환: 0x%x\n" 255

# 퍼센트 기호 출력 (결과: 75%)
printf "CPU 사용률: %d%%\n" 75</pre>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<p>데이터 표(Table) 만들기</p>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#!/bin/sh

# 헤더 출력
printf "%-10s %5s %8s\n" "이름" "점수" "등급"
printf "--------------------------\n"

# 데이터 출력
printf "%-10s %5d %8s\n" "홍길동" 95 "A"
printf "%-10s %5d %8s\n" "김철수" 82 "B"
printf "%-10s %5d %8s\n" "이영희" 100 "A+"</pre>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">이스케이프 시퀀스 (Escape Sequences)</h2>



<p>문자열 내에서 특수 기능을 수행하는 기호들입니다.</p>



<ul class="wp-block-list">
<li><code>\n</code>: 줄바꿈 (Newline)</li>



<li><code>\t</code>: 탭 (Tab)</li>



<li><code>\\</code>: 백슬래시(<code>\</code>) 자체 출력</li>



<li><code>\0NNN</code>: 8진수 숫자로 지정된 ASCII 문자 출력</li>
</ul>



<p></p>
<p>The post <a href="https://lycos7560.com/etc/posix-bash-printf/40604/">POSIX Shell: printf</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://lycos7560.com/etc/posix-bash-printf/40604/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>#include 지시자</title>
		<link>https://lycos7560.com/etc/include-%ec%a7%80%ec%8b%9c%ec%9e%90/40565/</link>
					<comments>https://lycos7560.com/etc/include-%ec%a7%80%ec%8b%9c%ec%9e%90/40565/#respond</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Sun, 05 Apr 2026 18:33:13 +0000</pubDate>
				<category><![CDATA[C++/CPP]]></category>
		<category><![CDATA[개인 공부 저장용]]></category>
		<category><![CDATA[기타]]></category>
		<category><![CDATA[study]]></category>
		<category><![CDATA[공부]]></category>
		<category><![CDATA[기초]]></category>
		<guid isPermaLink="false">https://lycos7560.com/?p=40565</guid>

					<description><![CDATA[<p>C 언어와 C++에서 #include는 소스 코드 파일의 가장 윗부분에서 흔히 볼 수 있는 전처리기 지시자(Preprocessor Directive)입니다. 1. #include의 핵심 역할 #include는 한마디로 &#8220;복사해서 붙여넣기&#8221;입니다. 컴파일러가 실제 코드를 번역하기 전(전처리 단계), 지정한 파일의 내용을 #include 문장이 있는 그 자리에 통째로 가져와서 삽입합니다. 2. 사용법에 따른 차이 ( &#60; &#62; vs " " ) #include를 사용할 때 [&#8230;]</p>
<p>The post <a href="https://lycos7560.com/etc/include-%ec%a7%80%ec%8b%9c%ec%9e%90/40565/">#include 지시자</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></description>
										<content:encoded><![CDATA[				<div class="wp-block-uagb-table-of-contents uagb-toc__align-left uagb-toc__columns-1  uagb-block-537dce7c      "
					data-scroll= "1"
					data-offset= "30"
					style=""
				>
				<div class="uagb-toc__wrap">
						<div class="uagb-toc__title">
							목차						</div>
																						<div class="uagb-toc__list-wrap ">
						<ol class="uagb-toc__list"><li class="uagb-toc__list"><a href="#1-include의-핵심-역할" class="uagb-toc-link__trigger">1. #include의 핵심 역할</a><li class="uagb-toc__list"><a href="#2-사용법에-따른-차이-vs" class="uagb-toc-link__trigger">2. 사용법에 따른 차이 ( &lt; &gt; vs &quot; &quot; )</a><ul class="uagb-toc__list"><li class="uagb-toc__list"><a href="#꺽쇠-괄호" class="uagb-toc-link__trigger">① &lt; &gt; (꺽쇠 괄호)</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#큰따옴표" class="uagb-toc-link__trigger">② &quot; &quot; (큰따옴표)</a></li></ul></li><li class="uagb-toc__list"><a href="#3-왜-헤더-파일을-포함해야-할까" class="uagb-toc-link__trigger">3. 왜 헤더 파일을 포함해야 할까?</a><li class="uagb-toc__list"><a href="#4-주의사항-중복-포함-방지" class="uagb-toc-link__trigger">4. 주의사항: 중복 포함 방지</a><li class="uagb-toc__list"><a href="#5-자주-사용하는-표준-라이브러리-헤더-목록-c" class="uagb-toc-link__trigger">5. 자주 사용하는 표준 라이브러리 헤더 목록 (c)</a><li class="uagb-toc__list"><a href="#요약" class="uagb-toc-link__trigger"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f4a1.png" alt="💡" class="wp-smiley" style="height: 1em; max-height: 1em;" /> 요약</a></ul></ol>					</div>
									</div>
				</div>
			


<div style="height:50px" aria-hidden="true" class="wp-block-spacer"></div>



<p>C 언어와 C++에서 <code>#include</code>는 소스 코드 파일의 가장 윗부분에서 흔히 볼 수 있는 전처리기 지시자(Preprocessor Directive)입니다. </p>



<h2 class="wp-block-heading">1. <code>#include</code>의 핵심 역할</h2>



<p><code>#include</code>는 한마디로 <strong>&#8220;복사해서 붙여넣기&#8221;</strong>입니다. </p>



<p>컴파일러가 실제 코드를 번역하기 전(전처리 단계), 지정한 파일의 내용을 <code>#include</code> 문장이 있는 그 자리에 통째로 가져와서 삽입합니다.</p>



<figure class="wp-block-image size-full"><img fetchpriority="high" decoding="async" width="644" height="299" src="https://lycos7560.com/wp-content/uploads/2026/04/image.png" alt="" class="wp-image-40566" srcset="https://lycos7560.com/wp-content/uploads/2026/04/image.png 644w, https://lycos7560.com/wp-content/uploads/2026/04/image-300x139.png 300w" sizes="(max-width: 644px) 100vw, 644px" /></figure>



<hr class="wp-block-separator has-alpha-channel-opacity is-style-wide" style="margin-top:var(--wp--preset--spacing--30);margin-bottom:var(--wp--preset--spacing--30)"/>



<h2 class="wp-block-heading">2. 사용법에 따른 차이 ( <code>&lt; &gt;</code> vs <code>" "</code> )</h2>



<p><code>#include</code>를 사용할 때 괄호의 모양에 따라 파일을 찾는 위치가 달라집니다.</p>



<h3 class="wp-block-heading">① <code>&lt; &gt;</code> (꺽쇠 괄호)</h3>



<ul class="wp-block-list">
<li><strong>사용 예:</strong> <code>#include &lt;stdio.h&gt;</code></li>



<li><strong>설명:</strong> 시스템의 <strong>표준 라이브러리 경로</strong>에서 파일을 찾습니다.</li>



<li><strong>대상:</strong> 컴파일러 설치 시 기본적으로 제공되는 표준 헤더 파일들을 불러올 때 사용합니다.</li>
</ul>



<h3 class="wp-block-heading">② <code>" "</code> (큰따옴표)</h3>



<ul class="wp-block-list">
<li><strong>사용 예:</strong> <code>#include "my_header.h"</code></li>



<li><strong>설명:</strong> <strong>현재 작업 중인 디렉토리(소스 파일이 있는 곳)</strong>에서 먼저 파일을 찾습니다. 만약 거기서 못 찾으면 시스템 표준 경로를 뒤집니다.</li>



<li><strong>대상:</strong> 개발자가 직접 만든 헤더 파일을 불러올 때 주로 사용합니다.</li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity is-style-wide" style="margin-top:var(--wp--preset--spacing--30);margin-bottom:var(--wp--preset--spacing--30)"/>



<h2 class="wp-block-heading">3. 왜 헤더 파일을 포함해야 할까?</h2>



<p><code>printf</code>나 <code>scanf</code> 같은 함수를 쓸 수 있는 이유는 그 함수들의 <strong>선언(Declaration)</strong>이 <code>stdio.h</code>라는 파일 안에 들어있기 때문입니다.</p>



<ul class="wp-block-list">
<li>컴파일러는 함수를 만나면 &#8220;이 함수가 어떻게 생겼는지(매개변수, 반환 타입 등)&#8221;를 알아야 합니다.</li>



<li>직접 모든 함수를 정의하기엔 양이 너무 많으므로, 미리 정의된 헤더 파일을 <code>#include</code>로 불러와서 정보를 제공하는 것입니다.</li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity is-style-wide" style="margin-top:var(--wp--preset--spacing--30);margin-bottom:var(--wp--preset--spacing--30)"/>



<h2 class="wp-block-heading">4. 주의사항: 중복 포함 방지</h2>



<p>대규모 프로젝트에서는 여러 파일이 서로를 참조하다가 똑같은 헤더 파일을 여러 번 <code>#include</code> 하는 상황이 발생할 수 있습니다. </p>



<p>이는 정의 중복 에러를 일으키므로, 보통 다음과 같은 기법을 사용합니다.</p>



<ul class="wp-block-list">
<li><strong>Header Guard:</strong>C<code>#ifndef MY_HEADER_H #define MY_HEADER_H // 코드 내용 #endif</code></li>



<li><strong>pragma once:</strong>C<code>#pragma once // 코드 내용</code></li>
</ul>



<pre class="EnlighterJSRAW" data-enlighter-language="c" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#ifndef MY_HEADER_H
#define MY_HEADER_H

/* 헤더 파일 내용 */
void say_hello();

#endif</pre>



<hr class="wp-block-separator has-alpha-channel-opacity is-style-wide" style="margin-top:var(--wp--preset--spacing--30);margin-bottom:var(--wp--preset--spacing--30)"/>



<h2 class="wp-block-heading">5. 자주 사용하는 표준 라이브러리 헤더 목록 (c)</h2>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th class="has-text-align-left" data-align="left">헤더 파일</th><th class="has-text-align-left" data-align="left">포함 내용</th><th class="has-text-align-left" data-align="left">대표 함수</th></tr></thead><tbody><tr><td>&lt;stdio.h&gt;</td><td>표준 입출력</td><td>printf, scanf, fopen</td></tr><tr><td>&lt;stdlib.h&gt;</td><td>메모리·변환·난수</td><td>malloc, free, rand</td></tr><tr><td>&lt;string.h&gt;</td><td>문자열 처리</td><td>strcpy, strlen, strcmp</td></tr><tr><td>&lt;math.h&gt;</td><td>수학 함수</td><td>sqrt, pow, sin</td></tr><tr><td>&lt;time.h&gt;</td><td>시간·날짜</td><td>time, clock, difftime</td></tr></tbody></table></figure>



<hr class="wp-block-separator has-alpha-channel-opacity is-style-wide" style="margin-top:var(--wp--preset--spacing--30);margin-bottom:var(--wp--preset--spacing--30)"/>



<h2 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f4a1.png" alt="💡" class="wp-smiley" style="height: 1em; max-height: 1em;" /> 요약</h2>



<p><code>#include</code>는 <strong>외부에 작성된 코드나 함수 선언을 현재 파일로 가져오는 통로</strong>입니다. </p>



<p>시스템 라이브러리는 <code>&lt; &gt;</code>를, 내가 만든 파일은 <code>" "</code>를 사용합니다.</p>



<p></p>
<p>The post <a href="https://lycos7560.com/etc/include-%ec%a7%80%ec%8b%9c%ec%9e%90/40565/">#include 지시자</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://lycos7560.com/etc/include-%ec%a7%80%ec%8b%9c%ec%9e%90/40565/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>POSIX(Portable Operating System Interface)</title>
		<link>https://lycos7560.com/etc/posixportable-operating-system-interface/40514/</link>
					<comments>https://lycos7560.com/etc/posixportable-operating-system-interface/40514/#respond</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Sun, 08 Mar 2026 17:59:02 +0000</pubDate>
				<category><![CDATA[개인 공부 저장용]]></category>
		<category><![CDATA[기타]]></category>
		<guid isPermaLink="false">https://lycos7560.com/?p=40514</guid>

					<description><![CDATA[<p>POSIX Portable Operating System Interface 서로 다른 UNIX 계열 운영체제 간의 애플리케이션 호환성을 높이기 위해 IEEE가 책정한 유닉스 기반의 표준 API 규격으로 &#8216;X&#8217;는 UNIX(유닉스) 호환 운영체제를 의미하는 관습 1. 이름의 탄생 비화 (리처드 스톨먼,  Richard Stallman의 제안) https://en.wikipedia.org/wiki/POSIX 2. 구체적으로 무엇을 정의하는가? 단순히 API 함수 이름만 정하는 것이 아니라 다음 세 가지 핵심 요소를 모두 [&#8230;]</p>
<p>The post <a href="https://lycos7560.com/etc/posixportable-operating-system-interface/40514/">POSIX(Portable Operating System Interface)</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></description>
										<content:encoded><![CDATA[				<div class="wp-block-uagb-table-of-contents uagb-toc__align-left uagb-toc__columns-1  uagb-block-d94b8844      "
					data-scroll= "1"
					data-offset= "30"
					style=""
				>
				<div class="uagb-toc__wrap">
						<div class="uagb-toc__title">
							목차						</div>
																						<div class="uagb-toc__list-wrap ">
						<ol class="uagb-toc__list"><li class="uagb-toc__list"><a href="#posix" class="uagb-toc-link__trigger">POSIX</a><ul class="uagb-toc__list"><li class="uagb-toc__list"><a href="#1-이름의-탄생-비화-리처드-스톨먼-richard-stallman의-제안" class="uagb-toc-link__trigger">1. 이름의 탄생 비화 (리처드 스톨먼,  Richard Stallman의 제안)</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#2-구체적으로-무엇을-정의하는가" class="uagb-toc-link__trigger">2. 구체적으로 무엇을 정의하는가?</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#3-실무에서의-의미-한-번-짜서-어디든-돌린다" class="uagb-toc-link__trigger">3. 실무에서의 의미: &quot;한 번 짜서 어디든 돌린다&quot;</a></ul></ol>					</div>
									</div>
				</div>
			


<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">POSIX</h2>



<p>Portable Operating System Interface</p>



<ul class="wp-block-list">
<li>portable : 이식 가능한</li>



<li>Operationg System : 운영 체제</li>



<li>Interface : 인터페이스</li>



<li>X : POSIX 전체 이름에서 유닉스(UNIX) 계열임을 암시하는 관습적 접미사</li>
</ul>



<p>서로 다른 UNIX 계열 운영체제 간의 애플리케이션 호환성을 높이기 위해 </p>



<p>IEEE가 책정한 유닉스 기반의 표준 API 규격으로 &#8216;X&#8217;는 UNIX(유닉스) 호환 운영체제를 의미하는 관습</p>



<h3 class="wp-block-heading">1. 이름의 탄생 비화 (리처드 스톨먼,  <a href="https://en.wikipedia.org/wiki/Richard_Stallman" target="_blank" rel="noreferrer noopener">Richard Stallman</a>의 제안)</h3>



<p><a href="https://en.wikipedia.org/wiki/POSIX" target="_blank" rel="noreferrer noopener">https://en.wikipedia.org/wiki/POSIX</a></p>



<ul class="wp-block-list">
<li><strong>원래 이름</strong><br>IEEE 내부에서는 원래 <strong>&#8216;IEEE-IX&#8217;</strong>라고 부르려고 했습니다.</li>



<li><strong>스톨먼의 개입</strong><br>자유 소프트웨어 재단(FSF)의 <strong>리처드 스톨먼</strong>이 &#8220;IEEE-IX는 발음하기 너무 어렵다&#8221;며, <br>&#8216;Portable Operating System&#8217;의 약자에 유닉스 느낌의 &#8216;IX&#8217;를 붙인 <strong>POSIX(포직스)</strong>를 제안했습니다.</li>



<li><strong>채택 이유</strong><br>이 이름이 훨씬 부르기 쉽고 기억에 잘 남는다는 이유로 위원회에서 즉시 채택되었습니다.</li>
</ul>



<div style="height:15px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading">2. 구체적으로 무엇을 정의하는가?</h3>



<p>단순히 API 함수 이름만 정하는 것이 아니라 다음 세 가지 핵심 요소를 모두 포함합니다.</p>



<ul class="wp-block-list">
<li><strong>C 언어 API</strong><br><code>open()</code>, <code>read()</code>, <code>write()</code> 같은 시스템 콜의 함수 이름, 인자, 반환 값, 오류 처리 방식까지 동작 전반을 규정합니다.</li>



<li><strong>셸(Shell) 및 유틸리티</strong><br><code>ls</code>, <code>grep</code>, <code>cd</code> 같은 기본 명령어들이 어떤 옵션을 지원하고 어떤 결과를 출력해야 하는지 정의합니다.</li>



<li><strong>파일 시스템 및 프로세스</strong><br><code>/usr</code>, <code>/tmp</code> 같은 파일 경로 구조와 프로세스 생성(<code>fork</code>)·종료 방식 등 OS의 근간이 되는 동작 방식을 표준화 합니다.</li>
</ul>



<div style="height:15px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading">3. 실무에서의 의미: &#8220;한 번 짜서 어디든 돌린다&#8221;</h3>



<ul class="wp-block-list">
<li><strong>개발 효율성</strong><br>POSIX 표준을 준수하여 프로그램을 만들면, 코드를 거의 수정하지 않고도 Linux, macOS, BSD 등 다양한 운영체제에서 바로 컴파일하여 실행할 수 있습니다.</li>



<li><strong>호환성 확인</strong><br>어떤 시스템이 &#8220;POSIX 준수(Compliant)&#8221;라고 하면, 개발자는 &#8220;내 프로그램이 이 OS에서도 문제없이 돌아가겠구나&#8221;라고 신뢰할 수 있게 됩니다.</li>



<li><strong>호환성의 한계</strong><br>다만 Windows는 기본적으로 POSIX를 준수하지 않습니다. <br>WSL(Windows Subsystem for Linux)을 통해 부분적으로 지원하지만, <br>네이티브 Windows 환경에서는 동일한 코드가 동작하지 않을 수 있다는 점을 염두에 두어야 합니다.</li>
</ul>



<p></p>
<p>The post <a href="https://lycos7560.com/etc/posixportable-operating-system-interface/40514/">POSIX(Portable Operating System Interface)</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://lycos7560.com/etc/posixportable-operating-system-interface/40514/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>HBA (Host Bus Adapter) &#8211; Network</title>
		<link>https://lycos7560.com/etc/hba-host-bus-adapter-network/40457/</link>
					<comments>https://lycos7560.com/etc/hba-host-bus-adapter-network/40457/#comments</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Thu, 12 Feb 2026 15:23:36 +0000</pubDate>
				<category><![CDATA[개인 공부 저장용]]></category>
		<category><![CDATA[기타]]></category>
		<guid isPermaLink="false">https://lycos7560.com/?p=40457</guid>

					<description><![CDATA[<p>HBA (Host Bus Adapter) ? 호스트 버스 어댑터 서버와 스토리지 네트워크(Fibre Channel SAN)를 연결해주는 인터페이스 카드입니다. 일반적인 이더넷 네트워크에서 사용하는 NIC(Network Interface Card)가 LAN 연결용이라면, HBA는 스토리지 네트워크 연결을 담당하는 장치라고 보면 됩니다. 즉, 서버가 Storage Array의 LUN에 접근할 수 있도록 통로 역할을 합니다. 기본 개념 서버 내부에는 CPU, 메모리, 디스크 외에도 확장 슬롯(PCIe)이 존재합니다. [&#8230;]</p>
<p>The post <a href="https://lycos7560.com/etc/hba-host-bus-adapter-network/40457/">HBA (Host Bus Adapter) &#8211; Network</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></description>
										<content:encoded><![CDATA[				<div class="wp-block-uagb-table-of-contents uagb-toc__align-left uagb-toc__columns-1  uagb-block-3607df7c      "
					data-scroll= "1"
					data-offset= "30"
					style=""
				>
				<div class="uagb-toc__wrap">
						<div class="uagb-toc__title">
							목차						</div>
																						<div class="uagb-toc__list-wrap ">
						<ol class="uagb-toc__list"><li class="uagb-toc__list"><a href="#hba-host-bus-adapter" class="uagb-toc-link__trigger">HBA (Host Bus Adapter) ?</a><li class="uagb-toc__list"><a href="#기본-개념" class="uagb-toc-link__trigger">기본 개념</a><li class="uagb-toc__list"><a href="#hba의-역할" class="uagb-toc-link__trigger">HBA의 역할</a><ul class="uagb-toc__list"><li class="uagb-toc__list"><a href="#스토리지-연결-제공" class="uagb-toc-link__trigger">스토리지 연결 제공</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#프로토콜-처리" class="uagb-toc-link__trigger">프로토콜 처리</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#wwn-제공" class="uagb-toc-link__trigger">WWN 제공</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#데이터-전송-최적화" class="uagb-toc-link__trigger">데이터 전송 최적화</a></li></ul></li><li class="uagb-toc__list"><a href="#hba-동작-흐름" class="uagb-toc-link__trigger">HBA 동작 흐름</a><li class="uagb-toc__list"><a href="#hba의-특징" class="uagb-toc-link__trigger">HBA의 특징</a><li class="uagb-toc__list"><a href="#구성-예시" class="uagb-toc-link__trigger">구성 예시</a><li class="uagb-toc__list"><a href="#hba와-multipath의-관계" class="uagb-toc-link__trigger">HBA와 Multipath의 관계</a></ul></ol>					</div>
									</div>
				</div>
			


<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="967" height="560" src="https://lycos7560.com/wp-content/uploads/2026/02/image-7-1.jpg" alt="" class="wp-image-40459" style="aspect-ratio:1.7268279043757864;width:463px;height:auto" srcset="https://lycos7560.com/wp-content/uploads/2026/02/image-7-1.jpg 967w, https://lycos7560.com/wp-content/uploads/2026/02/image-7-1-300x174.jpg 300w, https://lycos7560.com/wp-content/uploads/2026/02/image-7-1-768x445.jpg 768w" sizes="(max-width: 967px) 100vw, 967px" /><figcaption class="wp-element-caption">Sun Storage 16GB 광 섬유 채널 PCIe 범용 호스트 버스 어댑터(QLogic)&nbsp;<br><a href="https://docs.oracle.com/cd/E50150_01/html/E41423/z40003111016271.html" target="_blank" rel="noreferrer noopener">https://docs.oracle.com/cd/E50150_01/html/E41423/z40003111016271.html</a></figcaption></figure>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">HBA (Host Bus Adapter) ?</h2>



<p><strong>호스트 버스 어댑터</strong></p>



<ul class="wp-block-list">
<li>Host → 호스트(서버)</li>



<li>Bus → 버스(시스템 내부 데이터 통로)</li>



<li>Adapter → 어댑터</li>
</ul>



<p>서버와 스토리지 네트워크(Fibre Channel SAN)를 연결해주는 인터페이스 카드입니다.</p>



<p>일반적인 <strong>이더넷 네트워크에서 사용하는 NIC(Network Interface Card)가 LAN 연결용</strong>이라면,</p>



<p>HBA는 <strong>스토리지 네트워크 연결을 담당하는 장치</strong>라고 보면 됩니다.</p>



<p>즉, <strong>서버</strong>가 <strong>Storage Array의 LUN에 접근할 수 있도록 통로 역할</strong>을 합니다.</p>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<hr class="wp-block-separator has-alpha-channel-opacity is-style-wide"/>



<h2 class="wp-block-heading">기본 개념</h2>



<p>서버 내부에는 CPU, 메모리, 디스크 외에도 <strong>확장 슬롯(PCIe)</strong>이 존재합니다.</p>



<p>이 슬롯에 HBA 카드를 장착하면 서버는 Fibre Channel Fabric에 연결됩니다.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">Server
 └─ HBA 카드
     └─ FC 케이블
         └─ FC Switch
             └─ Storage Array</pre>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<p>이 구조를 통해 서버는 원격 스토리지를 로컬 디스크처럼 사용할 수 있습니다.</p>



<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<hr class="wp-block-separator has-alpha-channel-opacity is-style-wide"/>



<h2 class="wp-block-heading">HBA의 역할</h2>



<h3 class="wp-block-heading">스토리지 연결 제공</h3>



<p>서버와 SAN(Storage Area Network)을 물리적으로 연결합니다.</p>



<h3 class="wp-block-heading">프로토콜 처리</h3>



<p>SCSI 명령을 Fibre Channel 프레임으로 변환하여 전달합니다.</p>



<p><em>SCSI(Small Computer System Interface) 명령은&nbsp;<strong>컴퓨터와 스토리지 장치(HDD, SSD, 테이프 등) 간에 데이터 입출력을 제어하기 위한 표준화된 명령어 세트</strong>)</em></p>



<h3 class="wp-block-heading">WWN 제공</h3>



<p>각 HBA 포트는 고유한 WWN(World Wide Name)을 가지며 이를 통해 스위치 <strong>Zoning</strong> 및 <strong>LUN 매핑</strong>이 이루어집니다.</p>



<h3 class="wp-block-heading">데이터 전송 최적화</h3>



<p>DMA 등의 기능을 사용하여 CPU 부담을 줄이고 I/O 성능을 향상시킵니다.</p>



<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<hr class="wp-block-separator has-alpha-channel-opacity is-style-wide"/>



<h2 class="wp-block-heading">HBA 동작 흐름</h2>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">Application 
 → File System 
 → OS Block Layer 
 → HBA 
 → FC Switch 
 → Storage Array 
 → LUN</pre>



<p>사용자는 로컬 디스크처럼 사용하지만 실제 데이터는 SAN을 통해 전송됩니다.</p>



<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<hr class="wp-block-separator has-alpha-channel-opacity is-style-wide"/>



<h2 class="wp-block-heading">HBA의 특징</h2>



<p>서버 입장에서는 일반 디스크 인터페이스처럼 보입니다.</p>



<p>Linux에서는 다음과 같이 확인 가능합니다:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">lspci | grep Fibre
systool -c fc_host -v</pre>



<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<p>AIX에서는:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">lsdev -Cc adapter</pre>



<p>각 포트는 WWN을 가지며 스토리지 접근 제어의 기준이 됩니다.</p>



<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<hr class="wp-block-separator has-alpha-channel-opacity is-style-wide"/>



<h2 class="wp-block-heading">구성 예시</h2>



<p>이중화 구성(일반적인 환경):</p>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">Server
 ├─ HBA Port 1 ─ Switch A
 └─ HBA Port 2 ─ Switch B</pre>



<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<p>목적:</p>



<ul class="wp-block-list">
<li>경로 장애 대비</li>



<li>성능 분산</li>



<li>Multipath 구성</li>
</ul>



<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<hr class="wp-block-separator has-alpha-channel-opacity is-style-wide"/>



<h2 class="wp-block-heading">HBA와 Multipath의 관계</h2>



<p>서버에 <strong>여러 HBA 경로가 존재</strong>할 경우 <strong>동일한 LUN이 여러 경로로 인식</strong>됩니다.</p>



<p><strong>Multipath는 이를 하나의 디스크로 통합하여 관리</strong>합니다.</p>



<p>장점:</p>



<ul class="wp-block-list">
<li>장애 시 자동 경로 전환</li>



<li>성능 향상</li>



<li>안정성 확보</li>
</ul>



<p>Linux 예시:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">multipath -ll</pre>



<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<p>이는 SAN 환경에서 거의 필수 구성입니다.</p>



<p>은행, 공공기관, 데이터센터 등 엔터프라이즈 환경에서는 대부분의 서버가 HBA를 통해 SAN에 연결되어 있으며</p>



<p>이를 기반으로 데이터베이스, 가상화, 백업 시스템이 운영됩니다.</p>



<figure class="wp-block-embed is-type-wp-embed"><div class="wp-block-embed__wrapper">
<blockquote class="wp-embedded-content" data-secret="Ght72c8mjF"><a href="https://lycos7560.com/etc/%ea%b0%9c%ec%9d%b8-%ea%b3%b5%eb%b6%80-%ec%a0%80%ec%9e%a5%ec%9a%a9/fcip-fibre-channel-over-ip-network/40437/">FCIP (Fibre Channel over IP) &#8211; Network</a></blockquote><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  title="&#8220;FCIP (Fibre Channel over IP) &#8211; Network&#8221; &#8212; 어제와 내일의 나 그 사이의 이야기" src="https://lycos7560.com/etc/%ea%b0%9c%ec%9d%b8-%ea%b3%b5%eb%b6%80-%ec%a0%80%ec%9e%a5%ec%9a%a9/fcip-fibre-channel-over-ip-network/40437/embed/#?secret=yiJZgi4SgY#?secret=Ght72c8mjF" data-secret="Ght72c8mjF" width="600" height="338" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>
</div></figure>



<figure class="wp-block-embed is-type-wp-embed"><div class="wp-block-embed__wrapper">
<blockquote class="wp-embedded-content" data-secret="nEFpSAGc7u"><a href="https://lycos7560.com/etc/%ea%b0%9c%ec%9d%b8-%ea%b3%b5%eb%b6%80-%ec%a0%80%ec%9e%a5%ec%9a%a9/san-storage-area-network-network/40440/">SAN (Storage Area Network) – Network</a></blockquote><iframe loading="lazy" class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  title="&#8220;SAN (Storage Area Network) – Network&#8221; &#8212; 어제와 내일의 나 그 사이의 이야기" src="https://lycos7560.com/etc/%ea%b0%9c%ec%9d%b8-%ea%b3%b5%eb%b6%80-%ec%a0%80%ec%9e%a5%ec%9a%a9/san-storage-area-network-network/40440/embed/#?secret=zVroYN0Hwi#?secret=nEFpSAGc7u" data-secret="nEFpSAGc7u" width="600" height="338" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>
</div></figure>



<figure class="wp-block-embed is-type-wp-embed"><div class="wp-block-embed__wrapper">
<blockquote class="wp-embedded-content" data-secret="Jg6BRPoQkN"><a href="https://lycos7560.com/etc/lun-logical-unit-number-network/40454/">LUN (Logical Unit Number) – Network</a></blockquote><iframe loading="lazy" class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  title="&#8220;LUN (Logical Unit Number) – Network&#8221; &#8212; 어제와 내일의 나 그 사이의 이야기" src="https://lycos7560.com/etc/lun-logical-unit-number-network/40454/embed/#?secret=u9HRLjBsoq#?secret=Jg6BRPoQkN" data-secret="Jg6BRPoQkN" width="600" height="338" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>
</div></figure>



<p></p>
<p>The post <a href="https://lycos7560.com/etc/hba-host-bus-adapter-network/40457/">HBA (Host Bus Adapter) &#8211; Network</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://lycos7560.com/etc/hba-host-bus-adapter-network/40457/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>LUN (Logical Unit Number) – Network</title>
		<link>https://lycos7560.com/etc/lun-logical-unit-number-network/40454/</link>
					<comments>https://lycos7560.com/etc/lun-logical-unit-number-network/40454/#comments</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Thu, 12 Feb 2026 15:00:21 +0000</pubDate>
				<category><![CDATA[개인 공부 저장용]]></category>
		<category><![CDATA[기타]]></category>
		<guid isPermaLink="false">https://lycos7560.com/?p=40454</guid>

					<description><![CDATA[<p>LUN (Logical Unit Number) ? 논리적 저장장치 식별 번호  스토리지 어레이(Storage Array)  내에서 논리적으로 구분된 저장 공간입니다. 물리적 디스크를 여러 개의 논리적 단위로 나누어 각 서버에 할당하는 개념입니다. 기본 개념 실제 디스크 어레이에는 여러 개의 물리 디스크(Physical Disk)가 있습니다. 이 물리 디스크들을 RAID로 구성하여 보호한 후, 그 위에 논리적으로 공간을 나누어 LUN을 만듭니다. 각 서버는 [&#8230;]</p>
<p>The post <a href="https://lycos7560.com/etc/lun-logical-unit-number-network/40454/">LUN (Logical Unit Number) – Network</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></description>
										<content:encoded><![CDATA[				<div class="wp-block-uagb-table-of-contents uagb-toc__align-left uagb-toc__columns-1  uagb-block-c921b07a      "
					data-scroll= "1"
					data-offset= "30"
					style=""
				>
				<div class="uagb-toc__wrap">
						<div class="uagb-toc__title">
							목차						</div>
																						<div class="uagb-toc__list-wrap ">
						<ol class="uagb-toc__list"><li class="uagb-toc__list"><a href="#lun-logical-unit-number" class="uagb-toc-link__trigger">LUN (Logical Unit Number) ?</a><ul class="uagb-toc__list"><li class="uagb-toc__list"><a href="#기본-개념" class="uagb-toc-link__trigger">기본 개념</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#lun의-특징" class="uagb-toc-link__trigger">LUN의 특징</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#lun-할당의-예시" class="uagb-toc-link__trigger">LUN 할당의 예시</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#lun의-장점" class="uagb-toc-link__trigger">LUN의 장점</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#중요한-제약사항" class="uagb-toc-link__trigger">중요한 제약사항</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#lun과-zoning의-관계" class="uagb-toc-link__trigger">LUN과 Zoning의 관계</a></ul></ol>					</div>
									</div>
				</div>
			


<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image size-full"><img decoding="async" width="1006" height="393" src="https://lycos7560.com/wp-content/uploads/2026/02/image-6.png" alt="" class="wp-image-40455" srcset="https://lycos7560.com/wp-content/uploads/2026/02/image-6.png 1006w, https://lycos7560.com/wp-content/uploads/2026/02/image-6-300x117.png 300w, https://lycos7560.com/wp-content/uploads/2026/02/image-6-768x300.png 768w" sizes="(max-width: 1006px) 100vw, 1006px" /><figcaption class="wp-element-caption"><a href="https://tekmart.co.za/t-blog/logical-unit-number-lun/?srsltid=AfmBOoqKCrkhoJuntboiGOz9-ftQmoueOH05r4sD-BEeD-ZQguheRpIt">https://tekmart.co.za/t-blog/logical-unit-number-lun/?srsltid=AfmBOoqKCrkhoJuntboiGOz9-ftQmoueOH05r4sD-BEeD-ZQguheRpIt</a></figcaption></figure>



<ul class="wp-block-list">
<li>ESXi(VMware 가상화 서버) 여러 개가 각각 다른 LUN에 접근</li>



<li>VMFS(Virtual Machine File System)라는 파일시스템으로 LUN을 포맷<br>(포맷 = 형식을 정한다, 하드드라이브나 저장 장치를 <strong>사용 가능한 상태로 준비하는 과정</strong>, 즉, &#8220;이 공간을 어떤 파일시스템으로 사용할 것인가&#8221;를 정하는 작업)</li>
</ul>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">LUN (Logical Unit Number) ?</h2>



<p><strong>논리적 저장장치 식별 번호</strong></p>



<p> 스토리지 어레이(Storage Array)  내에서 <strong>논리적으로 구분된 저장 공간</strong>입니다.</p>



<p>물리적 디스크를 여러 개의 논리적 단위로 나누어 각 서버에 할당하는 개념입니다.</p>



<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading">기본 개념</h3>



<p>실제 디스크 어레이에는 여러 개의 물리 디스크(Physical Disk)가 있습니다.</p>



<p><strong>이 물리 디스크들을 RAID로 구성하여 보호한 후, 그 위에 논리적으로 공간을 나누어 LUN을 만듭니다.</strong></p>



<p>각 서버는 <strong>자신에게 할당된 LUN을 마치 자신의 로컬 디스크처럼 접근</strong>합니다.</p>



<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading">LUN의 특징</h3>



<p>서버 입장에서는 <strong>LUN을 로컬 하드드라이브처럼 인식</strong>합니다. </p>



<p>예를 들어 Windows 서버에서는 D드라이브, E드라이브처럼 보입니다.</p>



<p>각 LUN은 고유한 번호(0, 1, 2, 3 &#8230;)로 식별되며, 이를 통해 서버는 어떤 저장 공간에 접근할지 구분합니다.</p>



<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading">LUN 할당의 예시</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">Disk Array (물리 용량: 10TB)
│
├─ LUN 0 (2TB) → Server Node 1 에 할당
├─ LUN 1 (2TB) → Server Node 2 에 할당
├─ LUN 2 (3TB) → Server Node 3 에 할당
└─ LUN 3 (3TB) → 백업 시스템에 할당</pre>



<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading">LUN의 장점</h3>



<p>여러 서버가 <strong>같은 물리 디스크를 공유</strong>하면서도 <strong>각자 독립적인 저장 공간을 가질 수 있습니다.</strong></p>



<p>Storage Array에서 한 서버의 LUN을 다른 서버에 재할당할 수 있어 유연한 리소스 관리가 가능합니다.</p>



<p>또한 각 LUN별로 스냅샷, 복제, 백업 등을 독립적으로 관리할 수 있습니다.</p>



<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading">중요한 제약사항</h3>



<p><strong>여러 서버가 같은 LUN을 공유하면 안됨</strong></p>



<p>만약 <strong>Server 1</strong>과 <strong>Server 2</strong>가 같은 <strong>LUN에 동시에 쓰기 작업을 하면 데이터가 손상</strong>됩니다. </p>



<p>따라서 일반적으로 각 <strong>LUN은 하나의 서버에만 할당</strong>됩니다.</p>



<p>다만, 예외가 있습니다. </p>



<p><strong>Cluster 환경</strong>이나 <strong>Shared Disk File System</strong>(예: VMFS, GFS)을 사용하면 여러 서버가 같은 LUN을 공유할 수 있습니다.</p>



<p>이 경우 <strong>운영체제나 특수 소프트웨어가 동시 접근을 제어</strong>합니다.</p>



<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading">LUN과 Zoning의 관계</h3>



<p>LUN 할당만으로는 보안이 완벽하지 않습니다.</p>



<p><strong>Zoning</strong>은 <strong>Fibre Channel 스위치 레벨</strong>에서 특정 서버가 특정 스토리지만 접근하도록 제한합니다.</p>



<p>(TCP/IP 계층의 레벨이 아님 &#8211; TCP/IP 스택을 쓰지 않음 ㅋㅋ)</p>



<p>만약, Server 1은 LUN 0에만 접근 가능하도록 Zoning을 설정하면, 실수로 LUN 1에 접근하려고 해도 FC 스위치가 차단합니다.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">은행의 데이터베이스 서버는 LUN 0(금융거래 DB용), 웹 서버는 LUN 1(웹 콘텐츠용)을 할당받습니다. 
각 LUN은 독립적으로 백업되고 관리됩니다. 
만약 웹 서버가 추가되면, Storage Array에서 기존 LUN 2의 일부를 새 LUN으로 생성하여 할당할 수 있습니다.</pre>



<p></p>
<p>The post <a href="https://lycos7560.com/etc/lun-logical-unit-number-network/40454/">LUN (Logical Unit Number) – Network</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://lycos7560.com/etc/lun-logical-unit-number-network/40454/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
	</channel>
</rss>
