{"id":88929,"date":"2020-10-14T11:00:42","date_gmt":"2020-10-14T08:00:42","guid":{"rendered":"https:\/\/en.buradabiliyorum.com\/how-to-use-the-seq-command-on-linux\/"},"modified":"2020-10-14T11:00:42","modified_gmt":"2020-10-14T08:00:42","slug":"how-to-use-the-seq-command-on-linux","status":"publish","type":"post","link":"https:\/\/buradabiliyorum.com\/en\/how-to-use-the-seq-command-on-linux\/","title":{"rendered":"#How to Use the seq Command on Linux"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_84 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-6a256f751d2e2\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #dd3333;color:#dd3333\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #dd3333;color:#dd3333\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6a256f751d2e2\" checked aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-use-the-seq-command-on-linux\/#The_seq_Command\" >The seq Command<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-use-the-seq-command-on-linux\/#Basic_List_Generation\" >Basic List Generation<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-use-the-seq-command-on-linux\/#Counting_Backward\" >Counting Backward<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-use-the-seq-command-on-linux\/#Counting_With_Decimals\" >Counting With Decimals<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-use-the-seq-command-on-linux\/#The_Speed_of_seq\" >The Speed of seq<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-use-the-seq-command-on-linux\/#Using_a_Separator\" >Using a Separator<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-use-the-seq-command-on-linux\/#Using_Format_Strings\" >Using Format Strings<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-use-the-seq-command-on-linux\/#A_Quick_Way_to_Set_Zero_Padding\" >A Quick Way to Set Zero Padding<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-use-the-seq-command-on-linux\/#Piping_seq_Into_bc\" >Piping seq Into bc<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-use-the-seq-command-on-linux\/#Creating_Files_With_seq\" >Creating Files With seq<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-use-the-seq-command-on-linux\/#Using_seq_in_Bash_Loops\" >Using seq in Bash Loops<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-use-the-seq-command-on-linux\/#Nice_and_Simple\" >Nice and Simple<\/a><\/li><\/ul><\/nav><\/div>\n<p><strong>&#8220;#How to Use the seq Command on Linux&#8221;<\/strong><\/p>\n<div>\n<figure id=\"attachment_442612\" style=\"width: 650px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-442612 size-full\" src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2019\/09\/xstock-lede-linux-see-attribution.png.pagespeed.gp+jp+jw+pj+ws+js+rj+rp+rw+ri+cp+md.ic.rjm91kC_Jl.png\" alt=\"A terminal prompt on a Linux PC.\" width=\"650\" height=\"300\" data-credittext=\"Fatmawati Achmad Zaenuri\/Shutterstock\" data-crediturl=\"https:\/\/www.shutterstock.com\/image-vector\/linux-interface-screen-notebook-world-map-321627716\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><figcaption class=\"wp-caption-text\"><span class=\"imagecredit\"><a rel=\"nofollow noopener noreferrer\" target=\"_blank\" href=\"https:\/\/www.shutterstock.com\/image-vector\/linux-interface-screen-notebook-world-map-321627716\">Fatmawati Achmad Zaenuri\/Shutterstock<\/a><\/span><\/figcaption><\/figure>\n<p>The Linux <code>seq<\/code> command generates lists of numbers in the blink of an eye. But how can this functionality be put to practical use? We\u2019ll show you how seq might come in handy for you.<\/p>\n<h3 id=\"the-seq-command\"><span class=\"ez-toc-section\" id=\"The_seq_Command\"><\/span>The seq Command<br \/>\n<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>At first glance, the Linux <code>seq<\/code> command <a href=\"https:\/\/buradabiliyorum.com\/en\/category\/download-scripts-themes-apps\/\" data-internallinksmanager029f6b8e52c=\"9\" title=\"Download Scripts &amp; Themes &amp; Apps\" target=\"_blank\" rel=\"noopener\">app<\/a>ears to be something of an oddity. It allows you to generate\u00a0<a rel=\"nofollow noopener noreferrer\" target=\"_blank\" href=\"https:\/\/man7.org\/linux\/man-pages\/man1\/seq.1.html\">sequences of numbers<\/a>\u00a0quickly and that\u2019s it! The keyword here, though, is \u201cquickly.\u201d In a moment, you\u2019ll see just how fast this little command can run.<\/p>\n<p>Regardless of how they\u2019re generated, though, how useful is a list of numbers? The <code>seq<\/code> command was added to the\u00a08th edition of Unix\u00a0in 1985. It\u2019s been there ever since, so it must do something worthwhile.<\/p>\n<p>The <a rel=\"nofollow noopener noreferrer\" target=\"_blank\" href=\"https:\/\/en.wikipedia.org\/wiki\/Unix_philosophy\">philosophy of\u00a0Unix<\/a>\u00a0is that it\u2019s full of little utilities that do one thing and do it well. One of the central tenets of this philosophy is to write programs that accept input from other programs. Of course, that also means these programs have to generate output that can be used as input by other programs.<\/p>\n<p>The <code>seq<\/code> command comes into its own when it\u2019s used with other commands that make use of its output, either through pipes or command-line expansion.<\/p>\n<h3 id=\"basic-list-generation\"><span class=\"ez-toc-section\" id=\"Basic_List_Generation\"><\/span>Basic List Generation<br \/>\n<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>If you launch\u00a0<code>seq<\/code> with a single number as a command-line parameter, it counts from one to that number. It then prints the numbers in the terminal window, one number per line, as shown below:<\/p>\n<pre>seq 6<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-693551 size-full\" src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2020\/10\/x1.png.pagespeed.gp+jp+jw+pj+ws+js+rj+rp+rw+ri+cp+md.ic.bkk2ihRnoF.png\" alt=\"The &quot;seq 6&quot; command in a terminal window.\" width=\"646\" height=\"197\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>If you type two numbers on the command line, the first will be the\u00a0start number and the second will be the end\u00a0number, as shown below:<\/p>\n<pre>seq 4 10<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-693552 size-full\" src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2020\/10\/x2.png.pagespeed.gp+jp+jw+pj+ws+js+rj+rp+rw+ri+cp+md.ic.pp3YPRjzQz.png\" alt=\"seq 4 10 in a terminal window.\" width=\"646\" height=\"197\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>You can set a step size by including a third number. It sits between the start and end numbers. We type the following to ask\u00a0<code>seq<\/code> to create a list of numbers that starts with six, ends at 48, and uses a step of six:<\/p>\n<pre>seq 6 6 48<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-693553 size-full\" src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2020\/10\/x3.png.pagespeed.gp+jp+jw+pj+ws+js+rj+rp+rw+ri+cp+md.ic.LpFROiGsiE.png\" alt=\"seq 6 6 48 in a terminal window.\" width=\"646\" height=\"227\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<h3 id=\"counting-backward\"><span class=\"ez-toc-section\" id=\"Counting_Backward\"><\/span>Counting Backward<br \/>\n<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>We can also ask <code>seq<\/code> to create a list of numbers from highest to lowest. To do so, however, we must provide a step that\u2019s\u00a0negative.<\/p>\n<p>The following command produces a list that counts from 24 to 12 in steps of 6 because we type the step as a negative number:<\/p>\n<pre>seq 24 -6 12<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-693555 size-full\" src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2020\/10\/x4.png.pagespeed.gp+jp+jw+pj+ws+js+rj+rp+rw+ri+cp+md.ic.dOmiR44nnQ.png\" alt=\"seq 24 -6 12 in a terminal window.\" width=\"646\" height=\"132\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Counting_With_Decimals\"><\/span>Counting With Decimals<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>The start, end, and step numbers can also be decimals. If any of the numbers is a decimal, the others are also treated as decimals. The following command generates a list of numbers with a step of 0.2:<\/p>\n<pre>seq 1 0.2 2<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-693556 size-full\" src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2020\/10\/x5.png.pagespeed.gp+jp+jw+pj+ws+js+rj+rp+rw+ri+cp+md.ic.JGTXd5ugfr.png\" alt=\"seq 1 0.2 2 in a terminal window.\" width=\"646\" height=\"197\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<h2><span class=\"ez-toc-section\" id=\"The_Speed_of_seq\"><\/span>The Speed of seq<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><code>seq<\/code> is blazingly fast\u2014the only bottleneck is the time it takes you to type the command in the terminal window. To test its speed, let\u2019s ask for a list of 250,000 numbers.<\/p>\n<p>We type the following, using the <a rel=\"nofollow noopener noreferrer\" target=\"_blank\" href=\"https:\/\/man7.org\/linux\/man-pages\/man1\/time.1.html\"><code>time<\/code><\/a> command to see how long the process takes to complete:<\/p>\n<pre>time sqe 250000<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-693557 size-full\" src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2020\/10\/x6.png.pagespeed.gp+jp+jw+pj+ws+js+rj+rp+rw+ri+cp+md.ic.qHSlMkjG4E.png\" alt=\"time seq 250000 in a terminal window.\" width=\"646\" height=\"57\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>The results are displayed below the list. Even on our moderately powered test PC, <code>seq<\/code> is surprisingly fast.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-693559 size-full\" src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2020\/10\/x7.png.pagespeed.gp+jp+jw+pj+ws+js+rj+rp+rw+ri+cp+md.ic.0FsM8kLapU.png\" alt=\"Timing results for the seq 250000 command in a terminal window.\" width=\"646\" height=\"147\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>The entire list was created and written to the screen in about 1\/3 of a second. If we redirect the list into a file, we can even avoid the overhead of typing in the terminal window.<\/p>\n<p>To do so, we type the following:<\/p>\n<pre>time seq 250000 &gt; numbers.txt<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-693584 size-full\" src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2020\/10\/x8.png.pagespeed.gp+jp+jw+pj+ws+js+rj+rp+rw+ri+cp+md.ic.GwDXz-o8tR.png\" alt=\"time seq 250000 &gt; numbers.txt in a terminal window.\" width=\"646\" height=\"147\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>The time it takes to complete the list and create the file is now about 1\/7 of a second.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Using_a_Separator\"><\/span>Using a Separator<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>A new line character is the default character displayed between each number in a list. That\u2019s why they appear as a vertical list, with each number on its own line. If you need to, you can provide another separator.<\/p>\n<p>For example, say you need to create a comma-delimited list, a list divided by colons, or any other punctuation mark or symbol. The delimiter is actually a string, so you can use more than one character.<\/p>\n<p>We\u2019ll use the <code>-s<\/code> (separator) option. The following command will produce a comma-delimited list:<\/p>\n<pre>seq s, 6 6 36<\/pre>\n<p>This command will use a colon (<code>:<\/code>) as the separator:<\/p>\n<pre>seq -s: 6 6 36<\/pre>\n<p>This command tells <code>seq<\/code> to use two hyphens (<code>-<\/code>) as the separator:<\/p>\n<pre>seq -s-- 6 6 36<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-693589 size-full\" src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2020\/10\/x9.png.pagespeed.gp+jp+jw+pj+ws+js+rj+rp+rw+ri+cp+md.ic.l0qenPGYEY.png\" alt=\"seq s, 6 6 36 in a terminal window.\" width=\"646\" height=\"167\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Using_Format_Strings\"><\/span>Using Format Strings<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>The <code>seq<\/code> command also supports <a rel=\"nofollow noopener noreferrer\" target=\"_blank\" href=\"https:\/\/en.wikipedia.org\/wiki\/C_(programming_language)\">C language-style<\/a> format strings. These allow you to format the output with much more control than just specifying a separator. To use a format string, you use the <code>-f<\/code> (format) option.<\/p>\n<p>The following command tells <code>seq<\/code> to use zeroes to pad the output to two characters:<\/p>\n<pre>seq -f \"%02g\" 6<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-693739 size-full\" src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2020\/10\/x11.png.pagespeed.gp+jp+jw+pj+ws+js+rj+rp+rw+ri+cp+md.ic.UgnqirVio_.png\" alt=\"seq -f &quot;%02g&quot; 6 in a terminal window.\" width=\"646\" height=\"197\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>We can format the string with any text we like, and place the number anywhere in the string, as follows:<\/p>\n<pre>seq -f \"Number %02g in a C-like format string\" 6<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-693742 size-full\" src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2020\/10\/x12.png.pagespeed.gp+jp+jw+pj+ws+js+rj+rp+rw+ri+cp+md.ic.3p7n_mazst.png\" alt=\"seq -f &quot;Number %02g in a C-like format string&quot; 6 in a terminal window.\" width=\"646\" height=\"197\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<h2><span class=\"ez-toc-section\" id=\"A_Quick_Way_to_Set_Zero_Padding\"><\/span>A Quick Way to Set Zero Padding<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>The quickest way to set zero padding is to use the\u00a0<code>-w<\/code> (equal width) option. This tells <code>seq<\/code> to use zeroes to pad the numbers, so they\u2019re all the same width as the largest number.<\/p>\n<p>The following command counts from 0 to 1,000 in steps of 100, and all numbers will be padded with zeroes:<\/p>\n<pre>seq -w 0 100 1000<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-693743 size-full\" src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2020\/10\/x13.png.pagespeed.gp+jp+jw+pj+ws+js+rj+rp+rw+ri+cp+md.ic.BGUNe2WPma.png\" alt=\"seq -w 0 100 1000 in a terminal window.\" width=\"646\" height=\"292\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>The longest number takes four characters, so all narrower numbers are padded with zeroes to that width (even 0 is padded to four zeroes).<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Piping_seq_Into_bc\"><\/span>Piping seq Into bc<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>By setting the separator as a mathematical symbol and piping the list into the <code>bc<\/code> command, we can <a rel=\"nofollow noopener noreferrer\" target=\"_blank\" href=\"https:\/\/man7.org\/linux\/man-pages\/man1\/bc.1p.html\">evaluate the numbers in that list<\/a>.<\/p>\n<p>The following command generates a list of numbers separated by asterisks (<code>*<\/code>), starting at one and ending with six:<\/p>\n<pre>seq -s* 6<\/pre>\n<p>If we feed that list into <code>bc<\/code>, it evaluates the list using the asterisks (<code>*<\/code>) as multiplication symbols:<\/p>\n<pre>seq -s* 6 | bc<\/pre>\n<p>We can do this with other symbols, as well. The command below uses a plus sign (<code>+<\/code>) to create a list in which all the numbers are added:<\/p>\n<pre>seq -s+ 5<\/pre>\n<p>We type the following to pipe that into <code>bc<\/code>\u00a0and evaluate the list:<\/p>\n<pre>seq -s+ 5 | bc<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-693592 size-full\" src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2020\/10\/x10.png.pagespeed.gp+jp+jw+pj+ws+js+rj+rp+rw+ri+cp+md.ic.zxcMAefBd_.png\" alt=\"seq -s* 6 in a terminal window.\" width=\"646\" height=\"212\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Creating_Files_With_seq\"><\/span>Creating Files With seq<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>The <code>touch<\/code> command\u00a0<a rel=\"nofollow noopener noreferrer\" target=\"_blank\" href=\"https:\/\/man7.org\/linux\/man-pages\/man1\/touch.1.html\">updates time and date stamps<\/a> on files. If the file doesn\u2019t exist, touch creates it. We can use command-line expansion with <code>touch<\/code> and <code>seq<\/code> to create a collection of thematically-named, but differently numbered files.<\/p>\n<p>We\u2019ll create a set of 10 files with the same base name and a different number (file-1.txt, file-2.txt, and so on). We type the following:<\/p>\n<pre>touch $(seq -f \"file-%g.txt\" 1 10)<\/pre>\n<p>Then, we type the following to check the files:<\/p>\n<pre>ls file*<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-693745 size-full\" src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2020\/10\/x14.png.pagespeed.gp+jp+jw+pj+ws+js+rj+rp+rw+ri+cp+md.ic.t8CaEo89it.png\" alt=\"touch $(seq -f &quot;file-%g.txt&quot; 1 10) in a terminal window.\" width=\"646\" height=\"132\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Using_seq_in_Bash_Loops\"><\/span>Using seq in Bash Loops<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>We can use <code>seq<\/code> in Bash scripts to control loops with decimals.<\/p>\n<p>Type the following text into an editor, and then save it as \u201cloops.sh\u201d:<\/p>\n<pre>#!\/bin\/bash&#13;\n&#13;\n  for val in $(seq 5 0.2 6.6); do&#13;\n&#13;\n  echo \"The value is now: $val\"&#13;\n&#13;\ndone<\/pre>\n<p>Next, we type the following to make our new script executable:<\/p>\n<pre>chmod +x loop.sh<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-693749 size-full\" src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2020\/10\/x15.png.pagespeed.gp+jp+jw+pj+ws+js+rj+rp+rw+ri+cp+md.ic.J6XL2Zau3J.png\" alt=\"chmod +x loop.sh in a terminal window.\" width=\"646\" height=\"57\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>When we run the script, the loop counter is printed in the terminal window. We can then type the following to see the decimal loop counter increase with each iteration of the loop:<\/p>\n<pre>.\/loop.sh<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-693750 size-full\" src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2020\/10\/x16.png.pagespeed.gp+jp+jw+pj+ws+js+rj+rp+rw+ri+cp+md.ic.psdFd85bfz.png\" alt=\".\/loop.sh in a terminal window.\" width=\"646\" height=\"247\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>Remember that <code>seq<\/code> can count backwards, too; you can use that in loops in the same way.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Nice_and_Simple\"><\/span>Nice and Simple<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>One thing about <code>seq<\/code> is there\u2019s not much of a learning curve. It has a\u00a0<a rel=\"nofollow noopener noreferrer\" target=\"_blank\" href=\"https:\/\/man7.org\/linux\/man-pages\/man1\/seq.1.html\">refreshingly short<\/a> <code>man<\/code> page, but you can still use it in interesting ways.<\/p>\n<p>Because we often need to quickly create test files with realistic sizes, we use <code>seq<\/code> with a format string. We then redirect the output to create a file containing as many lines of dummy data as we want.<\/p>\n<\/div>\n<p><script>\n setTimeout(function(){\n  !function(f,b,e,v,n,t,s)\n  {if(f.fbq)return;n=f.fbq=function(){n.callMethod?\n  n.callMethod.apply(n,arguments):n.queue.push(arguments)};\n  if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';\n  n.queue=[];t=b.createElement(e);t.async=!0;\n  t.src=v;s=b.getElementsByTagName(e)[0];\n  s.parentNode.insertBefore(t,s) } (window, document,'script',\n  'https:\/\/connect.facebook.net\/en_US\/fbevents.js');\n   fbq('init', '335401813750447');\n   fbq('track', 'PageView');\n  },3000);\n<\/script><\/p>\n<blockquote>\n<p style=\"text-align: center;\">For forums sites go to <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/forum.buradabiliyorum.com\/\" target=\"_blank\" rel=\"noopener noreferrer\">Forum.BuradaBiliyorum.Com<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\"><strong>If you want to read more like this article, you can visit our <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/en.buradabiliyorum.com\/technology\/\" target=\"_blank\" rel=\"noopener noreferrer\">Technology category.<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<p><span style=\"color: black;\"><a style=\"color: #ff9900;\" href=\"https:\/\/www.howtogeek.com\/693549\/how-to-use-the-seq-command-on-linux\/\" target=\"_blank\" rel=\"noopener noreferrer\">Source<\/a><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8220;#How to Use the seq Command on Linux&#8221; Fatmawati Achmad Zaenuri\/Shutterstock The Linux seq command generates lists of numbers in the blink of an eye. But how can this functionality be put to practical use? We\u2019ll show you how seq might come in handy for you. The seq Command At first glance, the Linux seq&#8230;<\/p>\n","protected":false},"author":1,"featured_media":88930,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"https:\/\/www.howtogeek.com\/thumbcache\/2\/200\/de307e8ccc9856a4b842b6ca4a06c5ef\/wp-content\/uploads\/2019\/09\/stock-lede-linux-see-attribution.png","fifu_image_alt":"","footnotes":""},"categories":[18],"tags":[],"class_list":["post-88929","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technology"],"_links":{"self":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/88929","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/comments?post=88929"}],"version-history":[{"count":0,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/88929\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media\/88930"}],"wp:attachment":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media?parent=88929"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/categories?post=88929"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/tags?post=88929"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}