<?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; スグブログ</title>
	<atom:link href="https://sugublog.org/tag/%E3%82%B7%E3%82%A7%E3%83%AB%E3%82%B9%E3%82%AF%E3%83%AA%E3%83%97%E3%83%88%E3%80%80%E3%82%B3%E3%83%A1%E3%83%B3%E3%83%88%E3%82%A2%E3%82%A6%E3%83%88/feed/" rel="self" type="application/rss+xml" />
	<link>https://sugublog.org</link>
	<description>ブログ運営について発信中</description>
	<lastBuildDate>Fri, 10 Nov 2023 20:46:01 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://sugublog.org/wp-content/uploads/2021/07/icon_20210703-min-150x150.png</url>
	<title>シェルスクリプト　コメントアウト &#8211; スグブログ</title>
	<link>https://sugublog.org</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>【シェルスクリプト基礎】コメントアウトのやり方！</title>
		<link>https://sugublog.org/syell-script_comment_out/</link>
					<comments>https://sugublog.org/syell-script_comment_out/?noamp=mobile#respond</comments>
		
		<dc:creator><![CDATA[suguru]]></dc:creator>
		<pubDate>Tue, 04 Apr 2023 07:53:52 +0000</pubDate>
				<category><![CDATA[シェルスクリプト]]></category>
		<category><![CDATA[shell script]]></category>
		<category><![CDATA[シェルスクリプト　コメントアウト]]></category>
		<guid isPermaLink="false">https://sugublog.org/?p=5443</guid>

					<description><![CDATA[<p><img src="https://sugublog.org/wp-content/uploads/2021/08/school_08-2-1024x683.jpg" class="webfeedsFeaturedVisual" /></p>シェルスクリプトでコメントを入れたいけど入れ方がわからない。 また複数行コメントアウトできればやりたいといった要望はあると思います。 そこで今回はシェルスクリプトでのコメントアウトのやり方をエンジニアの筆者が教えます！  [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><img src="https://sugublog.org/wp-content/uploads/2021/08/school_08-2-1024x683.jpg" class="webfeedsFeaturedVisual" /></p>
<p><span class="swl-marker mark_orange"><strong>シェルスクリプト</strong>で<strong>コメント</strong></span>を入れたいけど入れ方がわからない。</p>



<p>また<strong>複数行コメントアウトできればやりたい</strong>といった要望はあると思います。</p>



<p>そこで今回は<strong><span class="swl-inline-color has-swl-deep-01-color">シェルスクリプトでのコメントアウトのやり方</span></strong>をエンジニアの筆者が教えます！</p>



<script async="" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<ins class="adsbygoogle ads" style="display:block; text-align:center;" data-ad-layout="in-article" data-ad-format="fluid" data-ad-client="ca-pub-9330904718533231" data-ad-slot="6086594686"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>



<h2 class="wp-block-heading">シェルスクリプトでコメントアウトのやり方</h2>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img decoding="async" width="1024" height="641" src="https://sugublog.org/wp-content/uploads/2021/08/school_08-3-1024x641.jpg" alt="コメントアウト" class="wp-image-4089" srcset="https://sugublog.org/wp-content/uploads/2021/08/school_08-3-1024x641.jpg 1024w, https://sugublog.org/wp-content/uploads/2021/08/school_08-3-300x188.jpg 300w, https://sugublog.org/wp-content/uploads/2021/08/school_08-3-768x481.jpg 768w, https://sugublog.org/wp-content/uploads/2021/08/school_08-3.jpg 1200w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<p><strong><span class="swl-inline-color has-swl-deep-01-color">シェルスクリプトでのコメントアウトのやり方</span></strong>は以下です。</p>



<p class="is-style-big_icon_check">#を付ける事でコメントアウトする事が出来ます。</p>



<p>どこで使用できるかは以下の２つになります。</p>



<div class="swell-block-capbox cap_box is-style-onborder_ttl"><div class="cap_box_ttl"><span>シェルスクリプトのコメントアウトのやり方2選</span></div><div class="cap_box_content">
<ul class="wp-block-list">
<li>行全体をコメントアウトする</li>



<li>行の途中からコメントアウトする</li>
</ul>
</div></div>



<h3 class="wp-block-heading">シェルスクリプトで行全体をコメントアウトする方法</h3>



<p><span class="swl-marker mark_orange"><strong>行の先頭に#を付ける事</strong>でその行は<strong>コメントアウト</strong>する事が出来ます。</span></p>



<div class="hcb_wrap"><pre class="prism line-numbers lang-bash" data-lang="Bash"><code>#!/bin/bash

#コメントアウトになります。</code></pre></div>



<h3 class="wp-block-heading">シェルスクリプトで行の途中からコメントアウトする方法</h3>



<p><span class="swl-marker mark_orange"><strong>行の途中</strong>で<strong>コメントアウト</strong>する事が出来ます。</span></p>



<div class="hcb_wrap"><pre class="prism line-numbers lang-bash" data-lang="Bash"><code>#!/bin/bash

echo コメントアウトしています。 #ココはコメントです。</code></pre></div>



<p>echoコマンドは文字を表示するコマンドです。</p>


<div class="swell-block-postLink">			<div class="p-blogCard -internal" data-type="type1" data-onclick="clickLink">
				<div class="p-blogCard__inner">
					<span class="p-blogCard__caption">あわせて読みたい</span>
					<div class="p-blogCard__thumb c-postThumb"><figure class="c-postThumb__figure"><img decoding="async" src="https://sugublog.org/wp-content/uploads/2021/08/school_08-3-300x188.jpg" alt="" class="c-postThumb__img u-obf-cover" width="320" height="180"></figure></div>					<div class="p-blogCard__body">
						<a class="p-blogCard__title" href="https://sugublog.org/shell-script-echo/">【シェルスクリプト基礎】echoコマンドの使い方！</a>
						<span class="p-blogCard__excerpt">シェルスクリプトのechoコマンドの使い方で疑問に思っている事などないでしょうか？ 思い通りに文字列を表示できなかったりしないでしょうか？ シェルスクリプトでecho&#8230;</span>					</div>
				</div>
			</div>
		</div>


<h3 class="wp-block-heading">シェルスクリプトで行の途中からコメントアウトする時の注意点</h3>



<p class="is-style-big_icon_caution">しかし<strong><span class="swl-inline-color has-swl-deep-01-color">途中からコメントアウトする場合#の前に半角スペースが必要</span></strong>です。</p>



<p>それでは実際にシェルスクリプトを実行してみましょう！以下のファイルを作成してください。</p>



<div class="hcb_wrap"><pre class="prism line-numbers lang-bash" data-lang="Bash"><code>#!/bin/bash

#コメントアウトしています。
echo 行の途中からコメントアウトしています。 #の前は半角スペースです。
echo 行の途中からコメントアウトしています。　#の前は全角スペースです。
echo 空白がない為コメントアウト出来ていません#ココはコメントの想定です。</code></pre></div>



<p>このシェルスクリプトを実行します。「.」でシェルスクリプトを実行する事ができます。</p>


<div class="swell-block-postLink">			<div class="p-blogCard -internal" data-type="type1" data-onclick="clickLink">
				<div class="p-blogCard__inner">
					<span class="p-blogCard__caption">あわせて読みたい</span>
					<div class="p-blogCard__thumb c-postThumb"><figure class="c-postThumb__figure"><img decoding="async" src="https://sugublog.org/wp-content/uploads/2021/08/script_0809-2-300x169.jpg" alt="" class="c-postThumb__img u-obf-cover" width="320" height="180"></figure></div>					<div class="p-blogCard__body">
						<a class="p-blogCard__title" href="https://sugublog.org/shell-script-execution/">【シェルスクリプト基礎】コマンドを実行する様々な方法をご紹介！</a>
						<span class="p-blogCard__excerpt">シェルスクリプトを実行する時に困った事はありませんか？ シェルスクリプトのコマンド実行での失敗メッセージ一覧 「実行権限がありません」 「コマンドが見つかりませ&#8230;</span>					</div>
				</div>
			</div>
		</div>


<p>結果は以下の通りとなりました。</p>


<div class="wp-block-image is-style-desktop">
<figure class="aligncenter size-full"><img decoding="async" width="660" height="76" src="https://sugublog.org/wp-content/uploads/2023/04/shell_script_comment_out.png" alt="シェルスクリプトでコメントアウトした結果" class="wp-image-5450" srcset="https://sugublog.org/wp-content/uploads/2023/04/shell_script_comment_out.png 660w, https://sugublog.org/wp-content/uploads/2023/04/shell_script_comment_out-300x35.png 300w" sizes="(max-width: 660px) 100vw, 660px" /></figure>
</div>


<p><span class="swl-bg-color has-swl-deep-02-background-color">１行目は全てコメントアウトされていますので、行全体が表示されていません。</span></p>



<p><span class="swl-bg-color has-swl-deep-02-background-color">２行目は行の途中からコメントアウトされています。</span></p>



<p class="is-style-big_icon_caution">３，４行目はコメントアウトされていません。</p>



<script async="" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<ins class="adsbygoogle ads" style="display:block; text-align:center;" data-ad-layout="in-article" data-ad-format="fluid" data-ad-client="ca-pub-9330904718533231" data-ad-slot="6086594686"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>



<h2 class="wp-block-heading">業務で使用するコメントアウト術</h2>



<p><span class="swl-marker mark_orange"><strong><span class="swl-inline-color has-swl-deep-01-color">シェルスクリプトでコメントアウト</span></strong>して説明を記述する事は良い事です。</span>後で見た自分や他の人が分かりやすくなるため、コメントアウトでの説明は必須です。</p>



<p>また業務や開発などでは<strong><span class="swl-marker mark_orange">コマンド自体をコメントアウト</span></strong>する事がよくあります。</p>



<p>テストで一部のコマンドは一時実行したくない場合に、コマンドの前に#を入れてコメントアウトしてテストします。コメントアウトも効率よく使用しましょう！</p>



<h2 class="wp-block-heading">シェルスクリプトで複数行コメントアウト出来るか？</h2>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img decoding="async" src="https://sugublog.org/wp-content/uploads/2021/06/89898a7645412c5788d6119425c194f6-1024x534.jpg" alt="失敗" class="wp-image-2928"/></figure>
</div>


<p><strong><span class="swl-marker mark_yellow">シェルスクリプトでは複数行コメントアウトする事はできません</span></strong>。</p>



<p class="has-border -border02">対応策としてはコメントアウトしたい行すべてに#をつけるしかありませんでした。</p>



<p class="is-style-icon_pen">大変ですがスクリプトでコメントは大事ですので、頑張ってコメントつけましょうね。</p>



<h2 class="wp-block-heading">シェルスクリプトでコメントアウトのやり方！複数行も可能か？まとめ</h2>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img decoding="async" width="1024" height="782" src="https://sugublog.org/wp-content/uploads/2021/12/PC教室20211216-8-1024x782.jpg" alt="コメントアウト" class="wp-image-4802" srcset="https://sugublog.org/wp-content/uploads/2021/12/PC教室20211216-8-1024x782.jpg 1024w, https://sugublog.org/wp-content/uploads/2021/12/PC教室20211216-8-300x229.jpg 300w, https://sugublog.org/wp-content/uploads/2021/12/PC教室20211216-8-768x586.jpg 768w, https://sugublog.org/wp-content/uploads/2021/12/PC教室20211216-8.jpg 1200w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<p><strong><span class="swl-inline-color has-swl-deep-01-color">シェルスクリプトでコメントアウトする方法は#を付ける事。</span></strong></p>



<p>どこにつけれるかは２種類ありました。</p>



<div class="swell-block-capbox cap_box is-style-onborder_ttl"><div class="cap_box_ttl"><span>シェルスクリプトのコメントアウトのやり方2選</span></div><div class="cap_box_content">
<ul class="wp-block-list">
<li>行全体をコメントとする</li>



<li>行の途中からコメントにする</li>
</ul>
</div></div>



<p>行全体に着ける場合は行の初めに#をつける</p>



<p><span class="swl-marker mark_orange">行の途中でコメントつけたい場合は半角スペースと#をいれる</span></p>



<p><strong><span class="swl-marker mark_yellow">シェルスクリプトで複数行コメントアウトは出来ない</span></strong>ので、コメントしたい全ての行に#を入れる必要がある。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sugublog.org/syell-script_comment_out/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
