<?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>Felipe Barriga Richards &#187; Bash</title>
	<atom:link href="http://blog.felipebarriga.cl/tag/bash/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.felipebarriga.cl</link>
	<description>Blog personal de Felipe Barriga Richards</description>
	<lastBuildDate>Sat, 17 Jul 2010 23:52:35 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Listing and deleting files in a terminal (bash)</title>
		<link>http://blog.felipebarriga.cl/otros/listing-and-deleting-files-in-a-terminal-bash/</link>
		<comments>http://blog.felipebarriga.cl/otros/listing-and-deleting-files-in-a-terminal-bash/#comments</comments>
		<pubDate>Wed, 05 May 2010 19:03:37 +0000</pubDate>
		<dc:creator>fbarriga</dc:creator>
				<category><![CDATA[Otros]]></category>
		<category><![CDATA[Bash]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://blog.felipebarriga.cl/?p=313</guid>
		<description><![CDATA[There are infinite ways of doing the following commands but here you can find some examples. They can be very useful when you need to manage a lot of files in different directories. Using &#8216;find&#8217; Delete empty files using find: felipe@funstation:$ find dir/ -type f -empty -print0 &#124; xargs rm -f Or create an script [...]]]></description>
			<content:encoded><![CDATA[<p>There are infinite ways of doing the following commands but here you can find some examples. They can be very useful when you need to manage a lot of files in different directories.<br />
<u><br />
<h3><strong>Using &#8216;find&#8217;</strong></h3>
<p></u></p>
<p>Delete empty files using find:</p>

<div class="wp-terminal">felipe@funstation:$ find dir/ -type f -empty -print0 | xargs rm -f<br/></div>

<p><span id="more-313"></span><br />
Or create an script (to watch it before deleting those files):</p>

<div class="wp-terminal">felipe@funstation:$ find dir/ -type f -empty -print0 | xargs -0 echo rm -f > delete_script.sh<br/></div>

<p><u><br />
<h3><strong>Using &#8216;du&#8217;</strong></h3>
<p></u></p>
<p>List with size all *.txt files on a tree dir:</p>

<div class="wp-terminal">felipe@funstation:$ du -ha dir/ | grep \.txt<br/></div>

<p><br/></p>
<p>Also that doesn&#8217;t match an specific size (256K):</p>

<div class="wp-terminal">felipe@funstation:$ du -ha dir/ | grep \.txt | grep -v "256K"<br/></div>

<p><br/></p>
<p>Also add another possible value (256K or 512K):</p>

<div class="wp-terminal">felipe@funstation:$ du -ha dir/ | grep \.txt | grep -v "256K" | grep -v "512K"<br/></div>

<p>or:</p>

<div class="wp-terminal">felipe@funstation:$ du -ha dir/ | grep \.txt | grep -v "256K\|512K"<br/></div>

<p><br/></p>
<p>Count how many they are:</p>

<div class="wp-terminal">felipe@funstation:$ du -ha dir/ | grep \.txt | grep -v "256K\|512K" | wc -l<br/></div>

<p><br/></p>
<p>Get only the filenames:</p>

<div class="wp-terminal">felipe@funstation:$ du -ha dir/ | grep \.txt | grep -v "256K\|512K" | cut -f 2<br/></div>

<p><br/></p>
<p>All in one line (remove trailing newline character):</p>

<div class="wp-terminal">felipe@funstation:$ du -ha dir/ | grep \.txt | grep -v "256K\|512K" | cut -f 2 | tr "\n" " "<br/></div>

<p><br/></p>
<p>Delete Them:</p>

<div class="wp-terminal">felipe@funstation:$ du -ha dir/ | grep \.txt | grep -v "256K\|512K" | cut -f 2 | tr "\n" " " | xargs rm -f<br/></div>

<p><br/></p>
<p><strong>Notes:</strong> You can get errors with grep because it won&#8217;t distinct if the string is in the size or in the filename<br />
<br/></p>
<p><strong>Related in spanish:</strong> <a href="http://systemadmin.es/2009/04/uso-de-xargs-herramientas-unix-ii">http://systemadmin.es/2009/04/uso-de-xargs-herramientas-unix-ii</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.felipebarriga.cl/otros/listing-and-deleting-files-in-a-terminal-bash/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Acortando el Path en el prompt del terminal (bash)</title>
		<link>http://blog.felipebarriga.cl/otros/acortando-el-path-en-el-prompt-del-terminal-bash/</link>
		<comments>http://blog.felipebarriga.cl/otros/acortando-el-path-en-el-prompt-del-terminal-bash/#comments</comments>
		<pubDate>Sat, 05 Sep 2009 23:42:44 +0000</pubDate>
		<dc:creator>fbarriga</dc:creator>
				<category><![CDATA[Otros]]></category>
		<category><![CDATA[Bash]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://blog.felipebarriga.cl/?p=61</guid>
		<description><![CDATA[A mas de alguno le habra pasado que cuando estan en un directorio con muchos niveles de profundidad del tipo: /home/user/mis_archivos/personal/documentos/documentos-importantes/ Les ocupa la mitad de la linea del terminal. Para solucionar eso solo necesitan cambiar la variable PS1. La variable original que viene con mi distro (Gentoo) es: user@computer:$ PS1='\[\033[01;32m\]\u@\h\[\033[01;34m\] \w \$\[\033[00m\]' Y decidi [...]]]></description>
			<content:encoded><![CDATA[<p>A mas de alguno le habra pasado que cuando estan en un directorio con muchos niveles de profundidad del tipo:<br />
<strong><em>/home/user/mis_archivos/personal/documentos/documentos-importantes/</em></strong><br />
Les ocupa la mitad de la linea del terminal. Para solucionar eso solo necesitan cambiar la variable PS1.<br />
<span id="more-61"></span><br />
La variable original que viene con mi distro (Gentoo) es:</p>

<div class="wp-terminal">user@computer:$ PS1='\[\033[01;32m\]\u@\h\[\033[01;34m\] \w \$\[\033[00m\]'<br/></div>

<p>Y decidi reemplazarla por esta que restringe el tamaño del path a mostrar:</p>

<div class="wp-terminal">user@computer:$ PS1='\[\033[01;32m\]\u@\h\[\033[01;34m\] ${PWD/????????????????????????????*/...${PWD:${#PWD}-30}} \$\[\033[00m\]'<br/></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.felipebarriga.cl/otros/acortando-el-path-en-el-prompt-del-terminal-bash/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
