<?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>Bash Shell &#8211; WilliamKyle&#039;s Home</title>
	<atom:link href="https://www.williamkyle.com.cn/archives/tag/bash-shell/feed" rel="self" type="application/rss+xml" />
	<link>https://www.williamkyle.com.cn</link>
	<description>不积跬步，无以至千里；不积小流，无以成江海。</description>
	<lastBuildDate>Fri, 08 Apr 2022 14:25:00 +0000</lastBuildDate>
	<language>zh-CN</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.9.3</generator>
	<item>
		<title>一些常用到的 Bash 小语句</title>
		<link>https://www.williamkyle.com.cn/archives/40.html</link>
					<comments>https://www.williamkyle.com.cn/archives/40.html#respond</comments>
		
		<dc:creator><![CDATA[WilliamKyle]]></dc:creator>
		<pubDate>Thu, 09 Feb 2012 07:57:48 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Bash Shell]]></category>
		<guid isPermaLink="false">http://www.williamkyle.com.cn/?p=40</guid>

					<description><![CDATA[以后的工作将会与 Linux 打交道了，所以脚本必须得会用，这篇文章记录一下常用的一些 Bash 语句，以方便 &#8230; <a href="https://www.williamkyle.com.cn/archives/40.html" class="more-link">继续阅读<span class="screen-reader-text">一些常用到的 Bash 小语句</span></a>]]></description>
										<content:encoded><![CDATA[
<p>以后的工作将会与 Linux 打交道了，所以脚本必须得会用，这篇文章记录一下常用的一些 Bash 语句，以方便自己查阅。</p>



<h5>检测当前脚本运行用户是否具有 root 权限</h5>



<pre class="wp-block-code has-dark-gray-color has-text-color"><code lang="bash" class="language-bash">#!/bin/bash
if [ $(id -u) != "0" ]; then
	echo "Sorry, you must run this as root. You can cry sudo " $0
	exit 1
else
	echo "You are root"
fi
</code></pre>



<h5>按照当前日期组织文件名</h5>



<pre class="wp-block-code has-dark-gray-color has-text-color"><code lang="bash" class="language-bash">$(date +%Y%m%d).log
#Tips: 在用于 crontab 的计划任务时，由于% 在 crontab 里面有其他的意义，所以必须转义
$(date +\%Y\%m\%d).log</code></pre>
]]></content:encoded>
					
					<wfw:commentRss>https://www.williamkyle.com.cn/archives/40.html/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
