<?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>Marios Braindump &#187; commandline</title>
	<atom:link href="http://www.mfasold.net/blog/tag/commandline/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mfasold.net/blog</link>
	<description>Just shouting my thoughts out</description>
	<lastBuildDate>Fri, 23 Jul 2010 14:21:22 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Print Particular Lines of a File Using SED</title>
		<link>http://www.mfasold.net/blog/2009/10/print-particular-lines-of-a-file-using-sed/</link>
		<comments>http://www.mfasold.net/blog/2009/10/print-particular-lines-of-a-file-using-sed/#comments</comments>
		<pubDate>Sat, 31 Oct 2009 17:32:56 +0000</pubDate>
		<dc:creator>Mario</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[commandline]]></category>
		<category><![CDATA[english]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[tech]]></category>

		<guid isPermaLink="false">http://www.mfasold.net/blog/?p=394</guid>
		<description><![CDATA[Say you want to print the lines 3 and 7, and all lines from 11 to 15 of a text-file. The following SED one-liner will do for you
sed -n -e '3p' -e '5p' -e '11,15p' textfile.txt
]]></description>
			<content:encoded><![CDATA[<p>Say you want to print the lines 3 and 7, and all lines from 11 to 15 of a text-file. The following SED one-liner will do for you</p>
<blockquote><p><code>sed -n -e '3p' -e '5p' -e '11,15p' textfile.txt</code></p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.mfasold.net/blog/2009/10/print-particular-lines-of-a-file-using-sed/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Working with a List of Tuples in Shell Scripting</title>
		<link>http://www.mfasold.net/blog/2009/10/working-with-a-list-of-tuples-in-shell-scripting/</link>
		<comments>http://www.mfasold.net/blog/2009/10/working-with-a-list-of-tuples-in-shell-scripting/#comments</comments>
		<pubDate>Fri, 02 Oct 2009 13:08:17 +0000</pubDate>
		<dc:creator>Mario</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[commandline]]></category>
		<category><![CDATA[english]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[scripting]]></category>
		<category><![CDATA[tech]]></category>

		<guid isPermaLink="false">http://www.mfasold.net/blog/?p=367</guid>
		<description><![CDATA[Several people have recently asked me whether or not it is possible to use tuples in their shell script. One example is running a program with a varying set of parameters. Since they often did not find a good solution, they began to formulate their problem in a higher-level scripting language like Ruby. Surprisingly, you [...]]]></description>
			<content:encoded><![CDATA[<p>Several people have recently asked me whether or not it is possible to use tuples in their shell script. One example is running a program with a varying set of parameters. Since they often did not find a good solution, they began to formulate their problem in a higher-level scripting language like Ruby. Surprisingly, you can accomplish the same task easily with simple shell scripting (supported by bash, zsh,..). Consider the following (semi-stupid) example</p>
<blockquote><p><code>#!/bin/bash<br />
paramset="foo.txt 1 --with-graphics<br />
bar.txt 8 --no-graphics<br />
flock.txt 4 --with-graphics"</code></p>
<p><code>echo "$du" | while read file p1 p2 ; do<br />
     ./myProgram $file -t $p1 --verbose $p2<br />
done</code></p></blockquote>
<p>We here run the program <code>myProgram</code> three times (for each line in the multi-line string). Every line contains three white-space separated values (words), to which we assign the variable names <code>file, p1, p2</code> in the loop header. Note that the last variable (in this case <code>p2</code>) always contains all remaining words of a given line if there are more words then variables.</p>
<p>The set of parameters can also be stored in a file. In that case, replace the loop header with <code>cat params.txt  | while read file p1 p2 ; do</code>. If the script is not working properly, examine the Input-Field-Separator (IFS) variable, which should be set to <code>IFS=" "</code>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mfasold.net/blog/2009/10/working-with-a-list-of-tuples-in-shell-scripting/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>List Only Subdirectories for Shell Scripting</title>
		<link>http://www.mfasold.net/blog/2009/06/list-only-subdirectories-for-shell-scripting/</link>
		<comments>http://www.mfasold.net/blog/2009/06/list-only-subdirectories-for-shell-scripting/#comments</comments>
		<pubDate>Sun, 07 Jun 2009 12:15:39 +0000</pubDate>
		<dc:creator>Mario</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[commandline]]></category>
		<category><![CDATA[english]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://www.mfasold.net/blog/?p=313</guid>
		<description><![CDATA[I like to have the following snippet in my .zshrc (or .bashrc) for convenience
alias lsd="ls -l&#124;awk '/^d/ {print \$9}'"
It displays all subdirectories underneath the current directory. The goodness in this variant is that it gives you the pure names and that you can use it in loops without hassle :
for d in `lsd`; do
mv $d/resultfile.dat [...]]]></description>
			<content:encoded><![CDATA[<p>I like to have the following snippet in my .zshrc (or .bashrc) for convenience</p>
<blockquote><p><code>alias lsd="ls -l|awk '/^d/ {print \$9}'"</code></p></blockquote>
<p>It displays all subdirectories underneath the current directory. The goodness in this variant is that it gives you the pure names and that you can use it in loops without hassle :</p>
<blockquote><p><code>for d in `lsd`; do<br />
mv $d/resultfile.dat $d_result.dat;<br />
rmdir $d;<br />
done</code></p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.mfasold.net/blog/2009/06/list-only-subdirectories-for-shell-scripting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Activate extended globbing!</title>
		<link>http://www.mfasold.net/blog/2009/01/activate-extended-globbing/</link>
		<comments>http://www.mfasold.net/blog/2009/01/activate-extended-globbing/#comments</comments>
		<pubDate>Fri, 16 Jan 2009 12:11:18 +0000</pubDate>
		<dc:creator>Mario</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[commandline]]></category>
		<category><![CDATA[english]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[tech]]></category>

		<guid isPermaLink="false">http://www.mfasold.net/blog/?p=231</guid>
		<description><![CDATA[This one is for zsh users. As you read this, open your editor at once an add the following line to your .zshrc
setopt extendedglob
This will activate extended globbing and allow you to do even more zsh commandline candy. Here some examples
rm ^important.txt  # remove all files in the current dir but important.txt
rm *.log~apache.log # [...]]]></description>
			<content:encoded><![CDATA[<p>This one is for zsh users. As you read this, open your editor at once an add the following line to your .zshrc</p>
<blockquote><p><code>setopt extendedglob</code></p></blockquote>
<p>This will activate extended globbing and allow you to do even more zsh commandline candy. Here some examples</p>
<blockquote><p><code>rm ^important.txt  # remove all files in the current dir but important.txt<br />
rm *.log~apache.log # remove all .log-files except apache.log<br />
ls (#a1)blu.dat # shows all files with one type error distance to blu.dat, e.g. bla.dat, blu.dot, bl.dat, ...</code></p></blockquote>
<p>More possibilities are shown at <code>man zshexpn | less -p 'Glob Qualifiers'</code> or at the <a href="http://pwet.fr/man/linux/commandes/zsh_lovers">Zsh Lovers Page</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mfasold.net/blog/2009/01/activate-extended-globbing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Moving or Renaming Multiple Files &#8211; The Easy (zsh) Way</title>
		<link>http://www.mfasold.net/blog/2008/11/moving-or-renaming-multiple-files/</link>
		<comments>http://www.mfasold.net/blog/2008/11/moving-or-renaming-multiple-files/#comments</comments>
		<pubDate>Wed, 26 Nov 2008 13:26:43 +0000</pubDate>
		<dc:creator>Mario</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[commandline]]></category>
		<category><![CDATA[english]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[tech]]></category>

		<guid isPermaLink="false">http://www.mfasold.net/blog/?p=193</guid>
		<description><![CDATA[Linux workers like you and me often need to move a bunch of files. For example, you want to rename all *.dat files into *.dat_save, or you want to rename all files foo.* into something like bar.*. This, however, is not easy to do using the move command as 1) &#8220;mv&#8221; only supports a single [...]]]></description>
			<content:encoded><![CDATA[<p>Linux workers like you and me often need to move a bunch of files. For example, you want to rename all <code>*.dat</code> files into <code>*.dat_save</code>, or you want to rename all files <code>foo.*</code> into something like <code>bar.*</code>. This, however, is not easy to do using the move command as 1) &#8220;<code>mv</code>&#8221; only supports a single destination file or directory and 2) the shell tries to expand  patterns like &#8220;<code>*.dat</code>&#8221; into e.g. &#8220;<code>a.dat b.dat c.dat</code>&#8221; before executing the command. The typical workaround is to write a for loop like &#8220;<code>for f in *.dat; do mv $f ${f/dat/dat_save}; done</code>&#8220;. But it goes much easier if you use the power of zsh, which is the superior shell anyway. <img src='http://www.mfasold.net/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Insert the following two lines into your .zshrc</p>
<blockquote><p><code>autoload -U zmv<br />
alias mmv='noglob zmv -W'</code></p></blockquote>
<p>The first line activates the zmv command, an extended move command provided by the zsh. The second line creates an alias for a simplified invocation of that command. All of a sudden, you can write something like &#8220;<code>mmv *.dat *.dat_old</code>&#8221; or &#8220;<code>mmv foo.* bar.*</code>&#8221; into a newly opened terminal and it will do as you expect! You can even invoke &#8220;<code>mmv **/*2008.mp3 **/*2009.mp3</code>&#8221; and all matching files residing in any subdirectory are renamed according to the pattern as well.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mfasold.net/blog/2008/11/moving-or-renaming-multiple-files/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to get an entry out of a tab delimited file</title>
		<link>http://www.mfasold.net/blog/2008/04/how-to-get-an-entry-out-of-a-tab-delimited-file/</link>
		<comments>http://www.mfasold.net/blog/2008/04/how-to-get-an-entry-out-of-a-tab-delimited-file/#comments</comments>
		<pubDate>Fri, 18 Apr 2008 15:02:50 +0000</pubDate>
		<dc:creator>Mario</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[commandline]]></category>
		<category><![CDATA[english]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[tech]]></category>

		<guid isPermaLink="false">http://www.mfasold.net/blog/?p=12</guid>
		<description><![CDATA[Insert the following function into your .bashrc:
# Function that gets a column and row from a tab separated file
tableEntry()
{
sed -n "$1p" $3 &#124; awk '{print $'$2'}'
}
You are then able to write
tableEntry 2 5 file.txt
to get the 2nd row and 5th column from any file.
]]></description>
			<content:encoded><![CDATA[<p>Insert the following function into your .bashrc:</p>
<blockquote><p><code># Function that gets a column and row from a tab separated file<br />
tableEntry()<br />
{<br />
sed -n "$1p" $3 | awk '{print $'$2'}'<br />
}</code></p></blockquote>
<p>You are then able to write</p>
<blockquote><p><code>tableEntry 2 5 file.txt</code></p></blockquote>
<p>to get the 2nd row and 5th column from any file.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mfasold.net/blog/2008/04/how-to-get-an-entry-out-of-a-tab-delimited-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
