{"id":3314,"date":"2024-02-22T21:15:53","date_gmt":"2024-02-22T15:45:53","guid":{"rendered":"https:\/\/smarttech101.com\/?p=3314"},"modified":"2024-03-11T22:15:52","modified_gmt":"2024-03-11T16:45:52","slug":"printf-command-in-linux-with-examples-and-their-outputs","status":"publish","type":"post","link":"https:\/\/smarttech101.com\/printf-command-in-linux-with-examples-and-their-outputs\/","title":{"rendered":"Printf Command in Linux with Examples and their Outputs"},"content":{"rendered":"\n<p class=\"\">The printf command in Linux is used to format and print data. It is similar to the <code>printf<\/code> function in the C programming language. This command allows you to format strings, numbers, and other types of data according to a specified format.<\/p>\n\n\n\n<p class=\"\">Most of these formats, special characters are going to work with other similar commands like <a href=\"https:\/\/smarttech101.com\/echo-with-examples\/\">echo<\/a>, gawk.<\/p>\n\n\n\n<p class=\"\"><strong>Note: <\/strong>the following examples are based on standard POSIX compliant printf command. That means they are definitely going to work with <code>dash<\/code> shell (in Ubuntu, this is <code>sh<\/code> shell). Some of these might not work with Bash and Zsh. All these variations mentioned.<\/p>\n\n\n\n<p class=\"\"><div id=\"ez-toc-container\" class=\"ez-toc-v2_0_69_1 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title \" >Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/smarttech101.com\/printf-command-in-linux-with-examples-and-their-outputs\/#Commands_and_Outputs\" title=\"Commands and Outputs\">Commands and Outputs<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/smarttech101.com\/printf-command-in-linux-with-examples-and-their-outputs\/#Printing_a_Simple_String\" title=\"Printing a Simple String\">Printing a Simple String<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/smarttech101.com\/printf-command-in-linux-with-examples-and-their-outputs\/#Printing_Special_Characters_using_printf_Command_in_Linux\" title=\"Printing Special Characters using printf Command in Linux\">Printing Special Characters using printf Command in Linux<\/a><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/smarttech101.com\/printf-command-in-linux-with-examples-and-their-outputs\/#Double_Quote\" title=\"Double Quote\">Double Quote<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/smarttech101.com\/printf-command-in-linux-with-examples-and-their-outputs\/#Backslash\" title=\"Backslash\">Backslash<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/smarttech101.com\/printf-command-in-linux-with-examples-and-their-outputs\/#Alert_BEL\" title=\"Alert (BEL)\">Alert (BEL)<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/smarttech101.com\/printf-command-in-linux-with-examples-and-their-outputs\/#Backspace\" title=\"Backspace\">Backspace<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/smarttech101.com\/printf-command-in-linux-with-examples-and-their-outputs\/#Form_Feed\" title=\"Form Feed\">Form Feed<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/smarttech101.com\/printf-command-in-linux-with-examples-and-their-outputs\/#New_Line\" title=\"New Line\">New Line<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/smarttech101.com\/printf-command-in-linux-with-examples-and-their-outputs\/#Carriage_Return\" title=\"Carriage Return\">Carriage Return<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/smarttech101.com\/printf-command-in-linux-with-examples-and-their-outputs\/#Horizontal_Tab\" title=\"Horizontal Tab\">Horizontal Tab<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/smarttech101.com\/printf-command-in-linux-with-examples-and-their-outputs\/#Vertical_Tab\" title=\"Vertical Tab\">Vertical Tab<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-13\" href=\"https:\/\/smarttech101.com\/printf-command-in-linux-with-examples-and-their-outputs\/#Octal_Value\" title=\"Octal Value\">Octal Value<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-14\" href=\"https:\/\/smarttech101.com\/printf-command-in-linux-with-examples-and-their-outputs\/#Hexadecimal_Value\" title=\"Hexadecimal Value\">Hexadecimal Value<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-15\" href=\"https:\/\/smarttech101.com\/printf-command-in-linux-with-examples-and-their-outputs\/#Unicode_Character_4_Digits\" title=\"Unicode Character (4 Digits)\">Unicode Character (4 Digits)<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-16\" href=\"https:\/\/smarttech101.com\/printf-command-in-linux-with-examples-and-their-outputs\/#Unicode_Character_8_Digits\" title=\"Unicode Character (8 Digits)\">Unicode Character (8 Digits)<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-17\" href=\"https:\/\/smarttech101.com\/printf-command-in-linux-with-examples-and-their-outputs\/#Percent_Sign\" title=\"Percent Sign\">Percent Sign<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-18\" href=\"https:\/\/smarttech101.com\/printf-command-in-linux-with-examples-and-their-outputs\/#Formatting_with_Flags\" title=\"Formatting with Flags\">Formatting with Flags<\/a><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-19\" href=\"https:\/\/smarttech101.com\/printf-command-in-linux-with-examples-and-their-outputs\/#Interpret_Backslash_Escapes\" title=\"Interpret Backslash Escapes\">Interpret Backslash Escapes<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-20\" href=\"https:\/\/smarttech101.com\/printf-command-in-linux-with-examples-and-their-outputs\/#Shell-Input_Format\" title=\"Shell-Input Format\">Shell-Input Format<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-21\" href=\"https:\/\/smarttech101.com\/printf-command-in-linux-with-examples-and-their-outputs\/#Formatting_Numbers\" title=\"Formatting Numbers\">Formatting Numbers<\/a><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-22\" href=\"https:\/\/smarttech101.com\/printf-command-in-linux-with-examples-and-their-outputs\/#Integer\" title=\"Integer\">Integer<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-23\" href=\"https:\/\/smarttech101.com\/printf-command-in-linux-with-examples-and-their-outputs\/#Unsigned_Integer\" title=\"Unsigned Integer\">Unsigned Integer<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-24\" href=\"https:\/\/smarttech101.com\/printf-command-in-linux-with-examples-and-their-outputs\/#Octal_Integer\" title=\"Octal Integer\">Octal Integer<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-25\" href=\"https:\/\/smarttech101.com\/printf-command-in-linux-with-examples-and-their-outputs\/#Hexadecimal_Integer_Lowercase\" title=\"Hexadecimal Integer (Lowercase)\">Hexadecimal Integer (Lowercase)<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-26\" href=\"https:\/\/smarttech101.com\/printf-command-in-linux-with-examples-and-their-outputs\/#Hexadecimal_Integer_Uppercase\" title=\"Hexadecimal Integer (Uppercase)\">Hexadecimal Integer (Uppercase)<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-27\" href=\"https:\/\/smarttech101.com\/printf-command-in-linux-with-examples-and-their-outputs\/#Floating_Point_Lowercase\" title=\"Floating Point (Lowercase)\">Floating Point (Lowercase)<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-28\" href=\"https:\/\/smarttech101.com\/printf-command-in-linux-with-examples-and-their-outputs\/#Floating_Point_Uppercase\" title=\"Floating Point (Uppercase)\">Floating Point (Uppercase)<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-29\" href=\"https:\/\/smarttech101.com\/printf-command-in-linux-with-examples-and-their-outputs\/#Scientific_Notation_Lowercase\" title=\"Scientific Notation (Lowercase)\">Scientific Notation (Lowercase)<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-30\" href=\"https:\/\/smarttech101.com\/printf-command-in-linux-with-examples-and-their-outputs\/#Scientific_Notation_Uppercase\" title=\"Scientific Notation (Uppercase)\">Scientific Notation (Uppercase)<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-31\" href=\"https:\/\/smarttech101.com\/printf-command-in-linux-with-examples-and-their-outputs\/#Shortest_Representation\" title=\"Shortest Representation\">Shortest Representation<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-32\" href=\"https:\/\/smarttech101.com\/printf-command-in-linux-with-examples-and-their-outputs\/#Shortest_Representation_Uppercase\" title=\"Shortest Representation (Uppercase)\">Shortest Representation (Uppercase)<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-33\" href=\"https:\/\/smarttech101.com\/printf-command-in-linux-with-examples-and-their-outputs\/#String\" title=\"String\">String<\/a><\/li><\/ul><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-34\" href=\"https:\/\/smarttech101.com\/printf-command-in-linux-with-examples-and-their-outputs\/#Conclusion\" title=\"Conclusion\">Conclusion<\/a><\/li><\/ul><\/nav><\/div>\n<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Commands_and_Outputs\"><\/span>Commands and Outputs<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Printing_a_Simple_String\"><\/span>Printing a Simple String<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p class=\"\">Command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>printf \"Hello, World!\\n\"<\/code><\/pre>\n\n\n\n<p class=\"\">Output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Hello, World!<\/code><\/pre>\n\n\n\n<p class=\"\">Explanation:<br>Prints the string &#8220;Hello, World!&#8221; followed by a new line character.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Printing_Special_Characters_using_printf_Command_in_Linux\"><\/span>Printing Special Characters using printf Command in Linux<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Double_Quote\"><\/span>Double Quote<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p class=\"\">Command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>printf \"Quote: \\\"\\n\"<\/code><\/pre>\n\n\n\n<p class=\"\">Output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Quote: \"<\/code><\/pre>\n\n\n\n<p class=\"\">Explanation:<br>Prints the double quote character using the escape sequence <code>\\\"<\/code>.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Backslash\"><\/span>Backslash<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p class=\"\">Command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>printf \"Backslash: \\\\\"<\/code><\/pre>\n\n\n\n<p class=\"\">Output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Backslash: \\<\/code><\/pre>\n\n\n\n<p class=\"\">Explanation:<br>Prints the backslash character using the escape sequence <code>\\\\<\/code>.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Alert_BEL\"><\/span>Alert (BEL)<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p class=\"\">Command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>printf \"Alert: \\a\\n\"<\/code><\/pre>\n\n\n\n<p class=\"\">Output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Alert: (alert sound)<\/code><\/pre>\n\n\n\n<p class=\"\">Explanation:<br>Triggers an alert (bell) sound using the escape sequence <code>\\a<\/code>.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Backspace\"><\/span>Backspace<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p class=\"\">Command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>printf \"Backspace: \\bX\\n\"<\/code><\/pre>\n\n\n\n<p class=\"\">Output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Backspace:X<\/code><\/pre>\n\n\n\n<p class=\"\">Explanation:<br>Demonstrates the backspace character by moving the cursor back one space and overwriting with <code>X<\/code>.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Form_Feed\"><\/span>Form Feed<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p class=\"\">Command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>printf \"Form feed: \\f\\n\"<\/code><\/pre>\n\n\n\n<p class=\"\">Output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Form feed: \n<\/code><\/pre>\n\n\n\n<p class=\"\">Explanation:<br>Prints the form feed character using the escape sequence <code>\\f<\/code>.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"New_Line\"><\/span>New Line<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p class=\"\">Command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>printf \"New line: \\n\\n\"<\/code><\/pre>\n\n\n\n<p class=\"\">Output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>New line:\n<\/code><\/pre>\n\n\n\n<p class=\"\">Explanation:<br>Prints two new line characters, creating an empty line.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Carriage_Return\"><\/span>Carriage Return<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p class=\"\">Command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>printf \"Carriage return: \\rCarriage\\n\"<\/code><\/pre>\n\n\n\n<p class=\"\">Output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Carriage return: <\/code><\/pre>\n\n\n\n<p class=\"\">Explanation:<br>Uses the carriage return to move the cursor to the beginning of the line and overwrite the text.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Horizontal_Tab\"><\/span>Horizontal Tab<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p class=\"\">Command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>printf \"Horizontal tab: \\tTab\\n\"<\/code><\/pre>\n\n\n\n<p class=\"\">Output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Horizontal tab:         Tab<\/code><\/pre>\n\n\n\n<p class=\"\">Explanation:<br>Prints a horizontal tab character, moving the cursor to the next tab stop.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Vertical_Tab\"><\/span>Vertical Tab<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p class=\"\">Command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>printf \"Vertical tab: \\vVertical\\n\"<\/code><\/pre>\n\n\n\n<p class=\"\">Output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Vertical tab: \n              Vertical<\/code><\/pre>\n\n\n\n<p class=\"\">Explanation:<br>Prints a vertical tab character, which may not have a visible effect in modern terminals.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Octal_Value\"><\/span>Octal Value<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p class=\"\">Command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>printf \"Octal value: \\101\\n\"<\/code><\/pre>\n\n\n\n<p class=\"\">Output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Octal value: A<\/code><\/pre>\n\n\n\n<p class=\"\">Explanation:<br>Prints the character corresponding to the octal value <code>101<\/code> (capital <code>A<\/code>).<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Hexadecimal_Value\"><\/span>Hexadecimal Value<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p class=\"\">Command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>printf \"Hexadecimal value: \\x41\\n\"<\/code><\/pre>\n\n\n\n<p class=\"\">Output in bash (not in dash):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Hexadecimal value: A<\/code><\/pre>\n\n\n\n<p class=\"\">Explanation:<br>Prints the character corresponding to the hexadecimal value <code>41<\/code> (capital <code>A<\/code>).<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Unicode_Character_4_Digits\"><\/span>Unicode Character (4 Digits)<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p class=\"\">Command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>printf \"Unicode character (4 digits): \\u03B1\\n\"<\/code><\/pre>\n\n\n\n<p class=\"\">Output in bash:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Unicode character (4 digits): \u03b1<\/code><\/pre>\n\n\n\n<p class=\"\">Explanation:<br>Prints the Unicode character for the Greek small letter alpha using a 4-digit hex code.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Unicode_Character_8_Digits\"><\/span>Unicode Character (8 Digits)<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p class=\"\">Command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>printf \"Unicode character (8 digits): \\U000003B1\\n\"<\/code><\/pre>\n\n\n\n<p class=\"\">Output in bash:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Unicode character (8 digits): \u03b1<\/code><\/pre>\n\n\n\n<p class=\"\">Explanation:<br>Prints the Unicode character for the Greek small letter alpha using an 8-digit hex code.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Percent_Sign\"><\/span>Percent Sign<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p class=\"\">Command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>printf \"Percent sign: %%\\n\"<\/code><\/pre>\n\n\n\n<p class=\"\">Output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Percent sign: %<\/code><\/pre>\n\n\n\n<p class=\"\">Explanation:<br>Prints a literal percent sign by escaping it with another percent sign.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Formatting_with_Flags\"><\/span>Formatting with Flags<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Interpret_Backslash_Escapes\"><\/span>Interpret Backslash Escapes<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p class=\"\">Command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>printf \"%b\\n\" \"String with new line \\n\"<\/code><\/pre>\n\n\n\n<p class=\"\">Output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>String with new line<\/code><\/pre>\n\n\n\n<p class=\"\">Explanation:<br>Interprets backslash escapes in the argument, printing a new line where <code>\\n<\/code> is present.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Shell-Input_Format\"><\/span>Shell-Input Format<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p class=\"\">Command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>printf \"%q\\n\" \"String with $ and '\"<\/code><\/pre>\n\n\n\n<p class=\"\">Output in bash:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>String\\ with\\ \\$\\ and\\ \\'<\/code><\/pre>\n\n\n\n<p class=\"\">Explanation:<br>Formats the argument for safe reuse as shell input, escaping special characters.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Formatting_Numbers\"><\/span>Formatting Numbers<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Integer\"><\/span>Integer<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p class=\"\">Command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>printf \"Integer: %d\\n\" 42<\/code><\/pre>\n\n\n\n<p class=\"\">Output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Integer: 42<\/code><\/pre>\n\n\n\n<p class=\"\">Explanation:<br>Prints an integer in decimal format.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Unsigned_Integer\"><\/span>Unsigned Integer<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p class=\"\">Command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>printf \"Unsigned integer: %u\\n\" 42<\/code><\/pre>\n\n\n\n<p class=\"\">Output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Unsigned integer: 42<\/code><\/pre>\n\n\n\n<p class=\"\">Explanation:<br>Prints an unsigned integer in decimal format.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Octal_Integer\"><\/span>Octal Integer<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p class=\"\">Command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>printf \"Octal integer: %o\\n\" 42<\/code><\/pre>\n\n\n\n<p class=\"\">Output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Octal integer: 52<\/code><\/pre>\n\n\n\n<p class=\"\">Explanation:<br>Prints an integer in octal format.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Hexadecimal_Integer_Lowercase\"><\/span>Hexadecimal Integer (Lowercase)<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p class=\"\">Command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>printf \"Hexadecimal integer (lowercase): %x\\n\" 42<\/code><\/pre>\n\n\n\n<p class=\"\">Output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Hexadecimal integer (lowercase): 2a<\/code><\/pre>\n\n\n\n<p class=\"\">Explanation:<br>Prints an integer in hexadecimal format using lowercase letters.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Hexadecimal_Integer_Uppercase\"><\/span>Hexadecimal Integer (Uppercase)<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p class=\"\">Command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>printf \"Hexadecimal integer (uppercase): %X\\n\" 42<\/code><\/pre>\n\n\n\n<p class=\"\">Output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Hexadecimal integer (uppercase): 2A<\/code><\/pre>\n\n\n\n<p class=\"\">Explanation:<br>Prints an integer in hexadecimal format using uppercase letters.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Floating_Point_Lowercase\"><\/span>Floating Point (Lowercase)<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p class=\"\">Command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>printf \"Floating point (lowercase): %f\\n\" 42.42<\/code><\/pre>\n\n\n\n<p class=\"\">Output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Floating point (lowercase): 42.420000<\/code><\/pre>\n\n\n\n<p class=\"\">Explanation:<br>Prints a floating-point number in decimal format with six digits after the decimal point.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Floating_Point_Uppercase\"><\/span>Floating Point (Uppercase)<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p class=\"\">Command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>printf \"Floating point (uppercase): %F\\n\" 42.42<\/code><\/pre>\n\n\n\n<p class=\"\">Output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Floating point (uppercase): 42.420000<\/code><\/pre>\n\n\n\n<p class=\"\">Explanation:<br>Similar to <code>%f<\/code>, but uses uppercase letters for scientific notation.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Scientific_Notation_Lowercase\"><\/span>Scientific Notation (Lowercase)<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p class=\"\">Command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>printf \"Scientific notation (lowercase): %e\\n\" 42.42<\/code><\/pre>\n\n\n\n<p class=\"\">Output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Scientific notation (lowercase): 4.242000e+01<\/code><\/pre>\n\n\n\n<p class=\"\">Explanation:<br>Prints a floating-point number in scientific notation with lowercase <code>e<\/code>.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Scientific_Notation_Uppercase\"><\/span>Scientific Notation (Uppercase)<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p class=\"\">Command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>printf \"Scientific notation (uppercase): %E\\n\" 42.42<\/code><\/pre>\n\n\n\n<p class=\"\">Output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Scientific notation (uppercase): 4.242000E+01<\/code><\/pre>\n\n\n\n<p class=\"\">Explanation:<br>Prints a floating-point number in scientific notation with uppercase <code>E<\/code>.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Shortest_Representation\"><\/span>Shortest Representation<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p class=\"\">Command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>printf \"Shortest representation: %g\\n\" 42.42<\/code><\/pre>\n\n\n\n<p class=\"\">Output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Shortest representation: 42.42<\/code><\/pre>\n\n\n\n<p class=\"\">Explanation:<br>Prints a floating-point number in the shortest format, either normal or scientific notation.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Shortest_Representation_Uppercase\"><\/span>Shortest Representation (Uppercase)<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p class=\"\">Command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>printf \"Shortest representation (uppercase): %G\\n\" 42.42<\/code><\/pre>\n\n\n\n<p class=\"\">Output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Shortest representation (uppercase): 42.42<\/code><\/pre>\n\n\n\n<p class=\"\">Explanation:<br>Similar to <code>%g<\/code>, but uses uppercase letters for scientific notation.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"String\"><\/span>String<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p class=\"\">Command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>printf \"String: %s\\n\" \"Hello, World!\"<\/code><\/pre>\n\n\n\n<p class=\"\">Output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>String: Hello, World!<\/code><\/pre>\n\n\n\n<p class=\"\">Explanation:<br>Prints the string &#8220;Hello, World!&#8221; as is.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"\">The <code>printf<\/code> command is a powerful tool for formatting output in Linux. By using various format specifiers and escape sequences, you can control the appearance of your output and make it suitable for different purposes. This makes it highly useful in writing scripts. <a href=\"https:\/\/smarttech101.com\/how-to-create-shell-scripts-in-linux-unix\/\">To learn about scripts, look here. <\/a>Whether you&#8217;re formatting strings, numbers, or special characters, <code>printf<\/code> provides a flexible way to present data in your scripts and terminal sessions.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The printf command in Linux is used to format and print data. It is similar to the printf function in the C programming language. This command allows you to format strings, numbers, and other types of data according to a specified format. Most of these formats, special characters are going to work with other similar [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":3317,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"set","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[17],"tags":[18,35],"class_list":["post-3314","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-command-line-tools","tag-command-line-tools","tag-core-linux-utilities"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v23.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Printf Command in Linux with Examples and their Outputs | SmartTech101<\/title>\n<meta name=\"description\" content=\"Here I will talk about printf command in Linux with as many example along their outputs. This will cover all special characters, and formats.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/smarttech101.com\/printf-command-in-linux-with-examples-and-their-outputs\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Printf Command in Linux with Examples and their Outputs | SmartTech101\" \/>\n<meta property=\"og:description\" content=\"Here I will talk about printf command in Linux with as many example along their outputs. This will cover all special characters, and formats.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/smarttech101.com\/printf-command-in-linux-with-examples-and-their-outputs\/\" \/>\n<meta property=\"og:site_name\" content=\"SmartTech101\" \/>\n<meta property=\"article:published_time\" content=\"2024-02-22T15:45:53+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-03-11T16:45:52+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/smarttech101.com\/wp-content\/uploads\/2024\/02\/printf-command-in-Linux-with-examples.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1280\" \/>\n\t<meta property=\"og:image:height\" content=\"720\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Ajay\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@ajay_yadav\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Ajay\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/smarttech101.com\/printf-command-in-linux-with-examples-and-their-outputs\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/smarttech101.com\/printf-command-in-linux-with-examples-and-their-outputs\/\"},\"author\":{\"name\":\"Ajay\",\"@id\":\"https:\/\/smarttech101.com\/#\/schema\/person\/2edfee738a82f9c963210f8cdb438334\"},\"headline\":\"Printf Command in Linux with Examples and their Outputs\",\"datePublished\":\"2024-02-22T15:45:53+00:00\",\"dateModified\":\"2024-03-11T16:45:52+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/smarttech101.com\/printf-command-in-linux-with-examples-and-their-outputs\/\"},\"wordCount\":667,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/smarttech101.com\/#\/schema\/person\/e8d5aebc510d698e11e9df6291381633\"},\"image\":{\"@id\":\"https:\/\/smarttech101.com\/printf-command-in-linux-with-examples-and-their-outputs\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2024\/02\/printf-command-in-Linux-with-examples.png?fit=1280%2C720&ssl=1\",\"keywords\":[\"Command Line Tools\",\"core linux utilities\"],\"articleSection\":[\"Command Line Tools\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/smarttech101.com\/printf-command-in-linux-with-examples-and-their-outputs\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/smarttech101.com\/printf-command-in-linux-with-examples-and-their-outputs\/\",\"url\":\"https:\/\/smarttech101.com\/printf-command-in-linux-with-examples-and-their-outputs\/\",\"name\":\"Printf Command in Linux with Examples and their Outputs | SmartTech101\",\"isPartOf\":{\"@id\":\"https:\/\/smarttech101.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/smarttech101.com\/printf-command-in-linux-with-examples-and-their-outputs\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/smarttech101.com\/printf-command-in-linux-with-examples-and-their-outputs\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2024\/02\/printf-command-in-Linux-with-examples.png?fit=1280%2C720&ssl=1\",\"datePublished\":\"2024-02-22T15:45:53+00:00\",\"dateModified\":\"2024-03-11T16:45:52+00:00\",\"description\":\"Here I will talk about printf command in Linux with as many example along their outputs. This will cover all special characters, and formats.\",\"breadcrumb\":{\"@id\":\"https:\/\/smarttech101.com\/printf-command-in-linux-with-examples-and-their-outputs\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/smarttech101.com\/printf-command-in-linux-with-examples-and-their-outputs\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/smarttech101.com\/printf-command-in-linux-with-examples-and-their-outputs\/#primaryimage\",\"url\":\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2024\/02\/printf-command-in-Linux-with-examples.png?fit=1280%2C720&ssl=1\",\"contentUrl\":\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2024\/02\/printf-command-in-Linux-with-examples.png?fit=1280%2C720&ssl=1\",\"width\":1280,\"height\":720,\"caption\":\"Here I will talk about printf command in Linux with as many example as possible. This will cover all special characters, and formats.\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/smarttech101.com\/printf-command-in-linux-with-examples-and-their-outputs\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/smarttech101.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Printf Command in Linux with Examples and their Outputs\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/smarttech101.com\/#website\",\"url\":\"https:\/\/smarttech101.com\/\",\"name\":\"SmartTech101\",\"description\":\"Do Everything in Linux\",\"publisher\":{\"@id\":\"https:\/\/smarttech101.com\/#\/schema\/person\/e8d5aebc510d698e11e9df6291381633\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/smarttech101.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/smarttech101.com\/#\/schema\/person\/e8d5aebc510d698e11e9df6291381633\",\"name\":\"Ajay Yadav\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/smarttech101.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2022\/09\/cropped-ST101_logo.png?fit=180%2C60&ssl=1\",\"contentUrl\":\"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2022\/09\/cropped-ST101_logo.png?fit=180%2C60&ssl=1\",\"width\":180,\"height\":60,\"caption\":\"Ajay Yadav\"},\"logo\":{\"@id\":\"https:\/\/smarttech101.com\/#\/schema\/person\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/smarttech101.com\/#\/schema\/person\/2edfee738a82f9c963210f8cdb438334\",\"name\":\"Ajay\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/smarttech101.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/6eea348caae2173954765a7cdf6cd107?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/6eea348caae2173954765a7cdf6cd107?s=96&d=mm&r=g\",\"caption\":\"Ajay\"},\"sameAs\":[\"https:\/\/x.com\/ajay_yadav\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Printf Command in Linux with Examples and their Outputs | SmartTech101","description":"Here I will talk about printf command in Linux with as many example along their outputs. This will cover all special characters, and formats.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/smarttech101.com\/printf-command-in-linux-with-examples-and-their-outputs\/","og_locale":"en_US","og_type":"article","og_title":"Printf Command in Linux with Examples and their Outputs | SmartTech101","og_description":"Here I will talk about printf command in Linux with as many example along their outputs. This will cover all special characters, and formats.","og_url":"https:\/\/smarttech101.com\/printf-command-in-linux-with-examples-and-their-outputs\/","og_site_name":"SmartTech101","article_published_time":"2024-02-22T15:45:53+00:00","article_modified_time":"2024-03-11T16:45:52+00:00","og_image":[{"width":1280,"height":720,"url":"https:\/\/smarttech101.com\/wp-content\/uploads\/2024\/02\/printf-command-in-Linux-with-examples.png","type":"image\/png"}],"author":"Ajay","twitter_card":"summary_large_image","twitter_creator":"@ajay_yadav","twitter_misc":{"Written by":"Ajay","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/smarttech101.com\/printf-command-in-linux-with-examples-and-their-outputs\/#article","isPartOf":{"@id":"https:\/\/smarttech101.com\/printf-command-in-linux-with-examples-and-their-outputs\/"},"author":{"name":"Ajay","@id":"https:\/\/smarttech101.com\/#\/schema\/person\/2edfee738a82f9c963210f8cdb438334"},"headline":"Printf Command in Linux with Examples and their Outputs","datePublished":"2024-02-22T15:45:53+00:00","dateModified":"2024-03-11T16:45:52+00:00","mainEntityOfPage":{"@id":"https:\/\/smarttech101.com\/printf-command-in-linux-with-examples-and-their-outputs\/"},"wordCount":667,"commentCount":0,"publisher":{"@id":"https:\/\/smarttech101.com\/#\/schema\/person\/e8d5aebc510d698e11e9df6291381633"},"image":{"@id":"https:\/\/smarttech101.com\/printf-command-in-linux-with-examples-and-their-outputs\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2024\/02\/printf-command-in-Linux-with-examples.png?fit=1280%2C720&ssl=1","keywords":["Command Line Tools","core linux utilities"],"articleSection":["Command Line Tools"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/smarttech101.com\/printf-command-in-linux-with-examples-and-their-outputs\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/smarttech101.com\/printf-command-in-linux-with-examples-and-their-outputs\/","url":"https:\/\/smarttech101.com\/printf-command-in-linux-with-examples-and-their-outputs\/","name":"Printf Command in Linux with Examples and their Outputs | SmartTech101","isPartOf":{"@id":"https:\/\/smarttech101.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/smarttech101.com\/printf-command-in-linux-with-examples-and-their-outputs\/#primaryimage"},"image":{"@id":"https:\/\/smarttech101.com\/printf-command-in-linux-with-examples-and-their-outputs\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2024\/02\/printf-command-in-Linux-with-examples.png?fit=1280%2C720&ssl=1","datePublished":"2024-02-22T15:45:53+00:00","dateModified":"2024-03-11T16:45:52+00:00","description":"Here I will talk about printf command in Linux with as many example along their outputs. This will cover all special characters, and formats.","breadcrumb":{"@id":"https:\/\/smarttech101.com\/printf-command-in-linux-with-examples-and-their-outputs\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/smarttech101.com\/printf-command-in-linux-with-examples-and-their-outputs\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/smarttech101.com\/printf-command-in-linux-with-examples-and-their-outputs\/#primaryimage","url":"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2024\/02\/printf-command-in-Linux-with-examples.png?fit=1280%2C720&ssl=1","contentUrl":"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2024\/02\/printf-command-in-Linux-with-examples.png?fit=1280%2C720&ssl=1","width":1280,"height":720,"caption":"Here I will talk about printf command in Linux with as many example as possible. This will cover all special characters, and formats."},{"@type":"BreadcrumbList","@id":"https:\/\/smarttech101.com\/printf-command-in-linux-with-examples-and-their-outputs\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/smarttech101.com\/"},{"@type":"ListItem","position":2,"name":"Printf Command in Linux with Examples and their Outputs"}]},{"@type":"WebSite","@id":"https:\/\/smarttech101.com\/#website","url":"https:\/\/smarttech101.com\/","name":"SmartTech101","description":"Do Everything in Linux","publisher":{"@id":"https:\/\/smarttech101.com\/#\/schema\/person\/e8d5aebc510d698e11e9df6291381633"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/smarttech101.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/smarttech101.com\/#\/schema\/person\/e8d5aebc510d698e11e9df6291381633","name":"Ajay Yadav","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/smarttech101.com\/#\/schema\/person\/image\/","url":"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2022\/09\/cropped-ST101_logo.png?fit=180%2C60&ssl=1","contentUrl":"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2022\/09\/cropped-ST101_logo.png?fit=180%2C60&ssl=1","width":180,"height":60,"caption":"Ajay Yadav"},"logo":{"@id":"https:\/\/smarttech101.com\/#\/schema\/person\/image\/"}},{"@type":"Person","@id":"https:\/\/smarttech101.com\/#\/schema\/person\/2edfee738a82f9c963210f8cdb438334","name":"Ajay","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/smarttech101.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/6eea348caae2173954765a7cdf6cd107?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/6eea348caae2173954765a7cdf6cd107?s=96&d=mm&r=g","caption":"Ajay"},"sameAs":["https:\/\/x.com\/ajay_yadav"]}]}},"jetpack_featured_media_url":"https:\/\/i0.wp.com\/smarttech101.com\/wp-content\/uploads\/2024\/02\/printf-command-in-Linux-with-examples.png?fit=1280%2C720&ssl=1","_links":{"self":[{"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/posts\/3314"}],"collection":[{"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/comments?post=3314"}],"version-history":[{"count":3,"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/posts\/3314\/revisions"}],"predecessor-version":[{"id":3318,"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/posts\/3314\/revisions\/3318"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/media\/3317"}],"wp:attachment":[{"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/media?parent=3314"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/categories?post=3314"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/smarttech101.com\/wp-json\/wp\/v2\/tags?post=3314"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}