<?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>Do Know Evil - A Blog by Tyler Mulligan &#187; seq</title> <atom:link href="http://www.doknowevil.net/tag/seq/feed/" rel="self" type="application/rss+xml" /><link>http://www.doknowevil.net</link> <description>Tips and Tricks About Computers, Web Development, Linux, the Internet and the Like</description> <lastBuildDate>Sat, 16 Jul 2011 01:25:35 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.0.5</generator> <item><title>Generating sequences of numbers or characters with bash</title><link>http://www.doknowevil.net/2009/08/15/generating-sequences-of-numbers-or-characters-with-bash/</link> <comments>http://www.doknowevil.net/2009/08/15/generating-sequences-of-numbers-or-characters-with-bash/#comments</comments> <pubDate>Sat, 15 Aug 2009 15:14:07 +0000</pubDate> <dc:creator>Tyler Mulligan</dc:creator> <category><![CDATA[Bash]]></category> <category><![CDATA[Computers]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[Software]]></category> <category><![CDATA[Ubuntu]]></category> <category><![CDATA[seq]]></category><guid isPermaLink="false">http://www.doknowevil.net/?p=442</guid> <description><![CDATA[If you ever needed to generate a sequence of characters or numbers, the terminal (using bash) is a quick and easy way to do it. Lets explore some examples bash&#8217;s brace expansion: $ echo {a..z} a b c d e f g h i j k l m n o p q r s t]]></description> <content:encoded><![CDATA[<p>If you ever needed to generate a sequence of characters or numbers, the terminal (using bash) is a quick and easy way to do it.  Lets explore some examples bash&#8217;s brace expansion:</p><pre class="brush:bash">$ echo {a..z}
a b c d e f g h i j k l m n o p q r s t u v w x y z</pre><p>by defining a start and end character with the &#8216;..&#8217; in between, we tell bash to fill in the rest and echo a list for us.  Those are all lowercase, what if you wanted uppercase? simple:</p><pre class="brush:bash">$ echo {A..Z}
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z</pre><p>Or both, with a few extra characters in the mix:</p><pre class="brush:bash">$ echo {A..z}
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [  ] ^ _ ` a b c d e f g h i j k l m n o p q r s t u v w x y z</pre><p>It doesn&#8217;t always have to be a-z though,</p><pre class="brush:bash">$ echo {A..G}
A B C D E F G</pre><p>This also works with numbers:</p><pre class="brush:bash">$ echo {0..9}
0 1 2 3 4 5 6 7 8 9
echo {0..100}
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100</pre><p>Descending as well as ascending</p><pre class="brush:bash">$ echo {9..0}
9 8 7 6 5 4 3 2 1 0</pre><p>There is another method to generate a sequence of numbers from the command line, rightfully called &#8216;seq&#8217;</p><pre class="brush:bash">$ seq 1 5
1
2
3
4
5</pre><p>The difference here is that it&#8217;s delimited by a new line, however, we can override that with the -s (seperator) flag</p><pre class="brush:bash">$ seq -s &quot; &quot; 1 10
1 2 3 4 5 6 7 8 9 10</pre>]]></content:encoded> <wfw:commentRss>http://www.doknowevil.net/2009/08/15/generating-sequences-of-numbers-or-characters-with-bash/feed/</wfw:commentRss> <slash:comments>3</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (enhanced)
Object Caching 382/390 objects using disk

Served from: www.doknowevil.net @ 2012-02-07 07:56:15 -->
