<?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>tar &#8211; 良的世界</title>
	<atom:link href="https://www.lemonary.cn/tag/tar/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.lemonary.cn</link>
	<description></description>
	<lastBuildDate>Fri, 13 Dec 2024 01:53:37 +0000</lastBuildDate>
	<language>zh-Hans</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://www.lemonary.cn/wp-content/uploads/2024/12/profile-150x150.jpg</url>
	<title>tar &#8211; 良的世界</title>
	<link>https://www.lemonary.cn</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Linux中自定义命令实现随时随地归档目录</title>
		<link>https://www.lemonary.cn/linux%e4%b8%ad%e8%87%aa%e5%ae%9a%e4%b9%89%e5%91%bd%e4%bb%a4%e5%ae%9e%e7%8e%b0%e9%9a%8f%e6%97%b6%e9%9a%8f%e5%9c%b0%e5%bd%92%e6%a1%a3%e7%9b%ae%e5%bd%95/</link>
					<comments>https://www.lemonary.cn/linux%e4%b8%ad%e8%87%aa%e5%ae%9a%e4%b9%89%e5%91%bd%e4%bb%a4%e5%ae%9e%e7%8e%b0%e9%9a%8f%e6%97%b6%e9%9a%8f%e5%9c%b0%e5%bd%92%e6%a1%a3%e7%9b%ae%e5%bd%95/#respond</comments>
		
		<dc:creator><![CDATA[shine]]></dc:creator>
		<pubDate>Fri, 13 Dec 2024 01:51:10 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[tar]]></category>
		<guid isPermaLink="false">https://www.lemonary.cn/?p=1040</guid>

					<description><![CDATA[将上述命令添加到环境变量中，保存退出，使其生效source .bash_profile。便可使用tarthis [&#8230;]]]></description>
										<content:encoded><![CDATA[
<pre class="wp-block-code"><code>alias tarthis='( ( D=`builtin pwd`; F=$(date +$HOME/`sed "s,&#91;/ ],#,g" &lt;&lt;&lt; ${D/${HOME}/}`#-%F.tgz); tar --ignore-failed-read --transform "s,^${D%/*},`date +${D%/*}.%F`,S" -czPf "$F" "$D" &amp;>/dev/null ) &amp; )'</code></pre>



<p class="wp-block-paragraph">将上述命令添加到环境变量中，保存退出，使其生效<code>source .bash_profile</code>。便可使用tarthis命令归档当前目录。</p>



<p class="wp-block-paragraph">验证：</p>



<pre class="wp-block-code"><code>&#91;root@dameng linuxscript]# pwd
/root/linuxscript
&#91;root@dameng linuxscript]# tarthis 
&#91;root@dameng linuxscript]# cd
&#91;root@dameng ~]# ll \#linuxscript#-2024-12-13.tgz 
-rw-r--r-- 1 root root 21505 Dec 13 09:48 '#linuxscript#-2024-12-13.tgz'
&#91;root@dameng ~]# tar -zxvf \#linuxscript#-2024-12-13.tgz 
tar: Removing leading `/' from member names
/root.2024-12-13/linuxscript/
/root.2024-12-13/linuxscript/newfile.sh
/root.2024-12-13/linuxscript/nmap-bootstrap.xsl
/root.2024-12-13/linuxscript/list-cronjobs.sh
/root.2024-12-13/linuxscript/user-cpu.sh
/root.2024-12-13/linuxscript/test.txt
/root.2024-12-13/linuxscript/autobak.sh
/root.2024-12-13/linuxscript/demo.sh
/root.2024-12-13/linuxscript/qmql/
/root.2024-12-13/linuxscript/qmql/danshu.tar
/root.2024-12-13/linuxscript/qmql/shuangshu.tar
/root.2024-12-13/linuxscript/~ip.txt
/root.2024-12-13/linuxscript/invoke.sh
/root.2024-12-13/linuxscript/file_size_distribution.sh
/root.2024-12-13/linuxscript/demo.log
/root.2024-12-13/linuxscript/scan.xml
/root.2024-12-13/linuxscript/backup.sh
/root.2024-12-13/linuxscript/demo.sh.crypt
/root.2024-12-13/linuxscript/cpu.sh
/root.2024-12-13/linuxscript/maclist
/root.2024-12-13/linuxscript/hosts
/root.2024-12-13/linuxscript/firewall-audit</code></pre>



<p class="wp-block-paragraph">执行效果图：</p>



<figure class="wp-block-image size-full"><img fetchpriority="high" decoding="async" width="797" height="689" src="https://www.lemonary.cn/wp-content/uploads/2024/12/image-63.png" alt="" class="wp-image-1041" srcset="https://www.lemonary.cn/wp-content/uploads/2024/12/image-63.png 797w, https://www.lemonary.cn/wp-content/uploads/2024/12/image-63-300x259.png 300w, https://www.lemonary.cn/wp-content/uploads/2024/12/image-63-768x664.png 768w" sizes="(max-width: 797px) 100vw, 797px" /></figure>



<p class="wp-block-paragraph">执行 tarthis 即可在 $HOME 目录中生成当前目录的压缩包。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.lemonary.cn/linux%e4%b8%ad%e8%87%aa%e5%ae%9a%e4%b9%89%e5%91%bd%e4%bb%a4%e5%ae%9e%e7%8e%b0%e9%9a%8f%e6%97%b6%e9%9a%8f%e5%9c%b0%e5%bd%92%e6%a1%a3%e7%9b%ae%e5%bd%95/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
