<?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>명령어 &#8211; WONIZZ.LOG</title>
	<atom:link href="https://blog.wonizz.com/tag/%EB%AA%85%EB%A0%B9%EC%96%B4/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.wonizz.com</link>
	<description>DEVELOPMENT &#38; LIFE LOG</description>
	<lastBuildDate>Fri, 21 Aug 2026 15:46:39 +0000</lastBuildDate>
	<language>ko-KR</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.2</generator>

<image>
	<url>https://i0.wp.com/blog.wonizz.com/wp-content/uploads/2026/08/wz-siteicon-512.png?fit=32%2C32&#038;ssl=1</url>
	<title>명령어 &#8211; WONIZZ.LOG</title>
	<link>https://blog.wonizz.com</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">152411368</site>	<item>
		<title>[Linux] sed 및 awk 사용법</title>
		<link>https://blog.wonizz.com/2019/03/05/%eb%aa%85%eb%a0%b9%ec%96%b4-sed-%eb%b0%8f-awk-%ec%82%ac%ec%9a%a9%eb%b2%95/</link>
					<comments>https://blog.wonizz.com/2019/03/05/%eb%aa%85%eb%a0%b9%ec%96%b4-sed-%eb%b0%8f-awk-%ec%82%ac%ec%9a%a9%eb%b2%95/#respond</comments>
		
		<dc:creator><![CDATA[워니]]></dc:creator>
		<pubDate>Tue, 05 Mar 2019 04:48:09 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[AWK]]></category>
		<category><![CDATA[sed]]></category>
		<category><![CDATA[명령어]]></category>
		<guid isPermaLink="false">http://blog.wonizz.tk/?p=370</guid>

					<description><![CDATA[<p>The standard Lorem Ipsum passage, used since the 1500s<br />
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."</p>
<p>Section 1.10.32 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC<br />
"Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?"</p>
<p>1914 translation by H. Rackham<br />
"But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?"</p>
<p>Section 1.10.33 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC<br />
"At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat."</p>
<p>1914 translation by H. Rackham<br />
"On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse pains."</p>
<p>sed 및 awk 사용법 에대해서 소개하고 자한다.sed와 awk각각 명령어에 대해서 설명 합니다. sed [-e script][-f script-file][file&#8230;] 기본적인 기능은 ed에서 가져왔다고 한다. 이 기능들은 모두 sed에 적용이 된다. sed는 스트리밍 편집기라고 한다. 대화형 편집기는 입력 및 출력이 하나로 이루어지며, \n을 개행문자로 사용하는 스트리밍 에디터이다. 1. 찾기(search), 출력(print) sed -n '/abd/p' list.txt : list.txt 파일을 한줄씩 읽으면서(-n&#8230;&#160;</p>
<p>The post <a rel="nofollow" href="https://blog.wonizz.com/2019/03/05/%eb%aa%85%eb%a0%b9%ec%96%b4-sed-%eb%b0%8f-awk-%ec%82%ac%ec%9a%a9%eb%b2%95/">[Linux] sed 및 awk 사용법</a> appeared first on <a rel="nofollow" href="https://blog.wonizz.com">WONIZZ.LOG</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>The standard Lorem Ipsum passage, used since the 1500s<br />
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."</p>
<p>Section 1.10.32 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC<br />
"Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?"</p>
<p>1914 translation by H. Rackham<br />
"But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?"</p>
<p>Section 1.10.33 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC<br />
"At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat."</p>
<p>1914 translation by H. Rackham<br />
"On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse pains."</p>

<p class="wp-block-paragraph">sed 및 awk 사용법 에대해서 소개하고 자한다.<br>sed와 awk각각 명령어에 대해서 설명 합니다. </p>



<p class="wp-block-paragraph">sed [-e script][-f script-file][file&#8230;]</p>



<p class="wp-block-paragraph">기본적인 기능은 ed에서 가져왔다고 한다. 이 기능들은 모두 sed에 적용이 된다. sed는 스트리밍 편집기라고 한다. 대화형 편집기는 입력 및 출력이 하나로 이루어지며, \n을 개행문자로 사용하는 스트리밍 에디터이다. </p>



<h4 class="wp-block-heading">1. 찾기(search), 출력(print)</h4>



<pre class="wp-block-preformatted">

sed -n '/abd/p' list.txt : list.txt 파일을 한줄씩 읽으면서(-n : 읽은 것을 출력하지 않음) abd 문자를 찾으면 그 줄을 출력(p)한다.

</pre>



<h4 class="wp-block-heading">2. 치환(substitute)</h4>



<pre class="wp-block-preformatted">sed 's/addrass/address/' list.txt : addrass를 address로 바꾼다. 단, 원본파일을 바꾸지 않고 출력을 바꿔서 한다.
sed 's/addrass/address/' list.txt > list2.txt
sed 's/\t/\ /' list.txt : 탭문자를 엔터로 변환
sed 's/□□*/□/' list.txt : ( *표시: □ 는 공백 문자를 표시한다. ) 위의 구문은 한개이상의 공백문자열을 하나의 공백으로 바꾼다.</pre>



<h4 class="wp-block-heading">3. 추가(insert)</h4>



<pre class="wp-block-preformatted">scriptfile - s/</pre>



<h4 class="wp-block-heading">4. 삭제(delete)</h4>



<pre class="wp-block-preformatted">sed '/TD/d' 1.html : TD 문자가 포함된 줄을 삭제하여 출력한다.
sed '/Src/!d' 1.html : Src 문자가 있는 줄만 지우지 않는다.
sed '1,2d' 1.html : 처음 1줄, 2줄을 지운다.
sed '/^$/d 1.html : 공백라인을 삭제하는 명령이다
파 일 이름만을 뽑아내는 정규식
s/^.*\/\([a-zA-Z0-9.]*\)".*$/\1/ : ^는 라인의 맨 처음, .* 아무문자열, \(, \)은 정규표현식을 그룹화, $ 는 라인의 맨 끝.
( s;^.*\/\([a-zA-Z0-9.]*\)".*$;\1;) \1는 그룹화된 첫번째 요소를 말한다.
[a-zA-Z0-9.] 는 알파벳과 숫자 및 .(콤마)를 표현하는 문자(character)를 말한다.
즉 GF02.jpg와 같은 문자열을 첫번째 그룹화하고 난 다음 라인 전체를 그룹화된 내용으로 바꾸는 것이다. </pre>



<hr class="wp-block-separator is-style-wide"/>



<p class="wp-block-paragraph">awk 명령어</p>



<pre class="wp-block-preformatted">awk '/west/' datafile : west 라는 글이 있는 줄 출력
awk '/^north/' datafile : north로 시작하는 줄 출력
awk '/^(no | so)/' datafile : no 또는 so 로 시작하는 줄 출력
awk '{ print $3, $2 }' datafile : datafile 리스트의 세 번째 와 두 번째 필드를 스페이스로 띄어서 출력
awk '{ print $3 $2 }' datafile : datafile 리스트의 세 번째 와 두 번째 필드를 그냥 붙여서 출력 
awk '{ print "Number of fields : " NF} ' datafile : datafile의 각 줄마다의 필드수를 리턴한다.
awk '$5 ~ /\.[7-9]+/' datafile : 다섯 번째 필드가 마침표 다음엣 7과 9사이 숫자가 하나 이상 나오는 레코드 출력
awk '$2 !~ /E/ { print $1, $2 }' datafile : 두 번째 필드에 E 패턴이 없는 레코드의 첫 번째와 두 번째 필드 출력
awk '$3 ~ /^Joel/{ print $3 " is a nice guy."} ' datafile : 세 번째 필드가 Joel로 시작하면 " is a nice guy"와 함께 출력
awk '$8 ~ /[0-9][0-9]$/ { print $8 }' datafile : 여덟 번째 필드가 두 개의 숫자이면 그 필드가 출력
awk '$4 ~ /Chin$/ { print "The price is $" $8 "." }' datafile : 네 번째 필드가 Chine으로 끝나면 "The price is $" 8번 필드 및 마침표가 출력
awk -F: '{ print $1 } ' datafile : -F 옵션은 입력 필드를 ':'로 구별.
awk -F"[ :]" '{ print $1, $2 } ' datafile : 입력 필드로 스페이스와 ':'를 필드 구별자로 사용
awk -f awk_script.file datafile : -f 옵션은 awk 스크립트 파일 사용할 때 씀.


awk '$7 == 5' datafile : 7번 필드가 5와 같다면 출력
awk '$2 == "CT" { print $1, $2 }' datafile : 2번 필드가 "CT" 문자와 같으면 1, 2 번 필드 출력
awk '$7 < 5 { print $4, $7}' datafile : 7번 필드가 5보다 작다면 4번, 7번 필드 출력
awk '$6 > .9 { print $1, $6}' datafile : 6번 필드가 .9 보다 크다면 1번, 6번 출력
awk '$8 > 10 && $8 < 17 ' datafile 
awk '$2 == "NW" || $1 ~ /south/ { print $1, $2 }' datafile
</pre>



<figure class="wp-block-image is-resized"><a href="https://blog.wonizz.com" target="_blank" rel="noreferrer noopener"><img data-recalc-dims="1" decoding="async" data-attachment-id="26" data-permalink="https://blog.wonizz.com/wonizz_logo-2/" data-orig-file="https://i0.wp.com/blog.wonizz.com/wp-content/uploads/2018/09/wonizz_logo-1.png?fit=257%2C187&amp;ssl=1" data-orig-size="257,187" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="wonizz_logo" data-image-description="&lt;p&gt;워니즈&lt;/p&gt;
" data-image-caption="&lt;p&gt;워니즈&lt;/p&gt;
" data-large-file="https://i0.wp.com/blog.wonizz.com/wp-content/uploads/2018/09/wonizz_logo-1.png?fit=257%2C187&amp;ssl=1" src="https://i0.wp.com/blog.wonizz.com/wp-content/uploads/2018/09/wonizz_logo-1.png?resize=94%2C68&#038;ssl=1" alt="워니즈" class="wp-image-26" width="94" height="68"/></a><figcaption>워니즈</figcaption></figure>

<h2 class="wp-block-heading">함께 보면 좋은 글</h2>
<ul class="wp-block-list"><li><a href="https://blog.wonizz.com/2019/08/07/linux-sed/">[리눅스 명령어] sed 사용법</a></li><li><a href="https://blog.wonizz.com/2019/04/01/linux-apache-tomcat-connect/">[Linux] Apache HTTP 서버와 Tomcat 서버의 연동</a></li><li><a href="https://blog.wonizz.com/2019/08/13/docker-compose/">[Docker] Compose 구성과 사용법</a></li><li><a href="https://blog.wonizz.com/2019/08/09/ansible-jinja2/">[Ansible] 앤서블 Jinja2 필터 사용법</a></li></ul>
<p>The post <a rel="nofollow" href="https://blog.wonizz.com/2019/03/05/%eb%aa%85%eb%a0%b9%ec%96%b4-sed-%eb%b0%8f-awk-%ec%82%ac%ec%9a%a9%eb%b2%95/">[Linux] sed 및 awk 사용법</a> appeared first on <a rel="nofollow" href="https://blog.wonizz.com">WONIZZ.LOG</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.wonizz.com/2019/03/05/%eb%aa%85%eb%a0%b9%ec%96%b4-sed-%eb%b0%8f-awk-%ec%82%ac%ec%9a%a9%eb%b2%95/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">370</post-id>	</item>
	</channel>
</rss>
