How to redirect sqlite3 output to a file

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












4















I installed sqlite3 and want to use it to recover information from stylish.sqlite which is located in my Firefox profile folder and is generated by the Stylish extension:



$ cd ~/.mozilla/firefox/w4wcp85s.default
$ sqlite3 stylish.sqlite
SQLite version 3.7.17 2013-05-20 00:56:22
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> .tables
style_meta styles
sqlite> SELECT * FROM styles;
6||||YouTube|/* AGENT_SHEET */
/* ▓▓ NIGHTSHIFT - eye care: ▓▓
▓▓_http://userstyles.org/styles/18192/nightshift-eye-care_▓▓ */

@namespace url(http://www.w3.org/1999/xhtml);
@-moz-document regexp("https?://www.youtube.com/.*") {
body,html min-height: 100%!important;
html, bodybackground-color:#111!important
body>*:not(:empty)background-color:#222!important
body>*>*:not(:empty)background-color:#222!important
body>*>*>*:not(:empty)background-color:#282828!important
...


My question is this: how can I capture the output of sqlite> SELECT * FROM styles; to a file? (I know I can select the output in the terminal and copy it to a file.)










share|improve this question


























    4















    I installed sqlite3 and want to use it to recover information from stylish.sqlite which is located in my Firefox profile folder and is generated by the Stylish extension:



    $ cd ~/.mozilla/firefox/w4wcp85s.default
    $ sqlite3 stylish.sqlite
    SQLite version 3.7.17 2013-05-20 00:56:22
    Enter ".help" for instructions
    Enter SQL statements terminated with a ";"
    sqlite> .tables
    style_meta styles
    sqlite> SELECT * FROM styles;
    6||||YouTube|/* AGENT_SHEET */
    /* ▓▓ NIGHTSHIFT - eye care: ▓▓
    ▓▓_http://userstyles.org/styles/18192/nightshift-eye-care_▓▓ */

    @namespace url(http://www.w3.org/1999/xhtml);
    @-moz-document regexp("https?://www.youtube.com/.*") {
    body,html min-height: 100%!important;
    html, bodybackground-color:#111!important
    body>*:not(:empty)background-color:#222!important
    body>*>*:not(:empty)background-color:#222!important
    body>*>*>*:not(:empty)background-color:#282828!important
    ...


    My question is this: how can I capture the output of sqlite> SELECT * FROM styles; to a file? (I know I can select the output in the terminal and copy it to a file.)










    share|improve this question
























      4












      4








      4


      1






      I installed sqlite3 and want to use it to recover information from stylish.sqlite which is located in my Firefox profile folder and is generated by the Stylish extension:



      $ cd ~/.mozilla/firefox/w4wcp85s.default
      $ sqlite3 stylish.sqlite
      SQLite version 3.7.17 2013-05-20 00:56:22
      Enter ".help" for instructions
      Enter SQL statements terminated with a ";"
      sqlite> .tables
      style_meta styles
      sqlite> SELECT * FROM styles;
      6||||YouTube|/* AGENT_SHEET */
      /* ▓▓ NIGHTSHIFT - eye care: ▓▓
      ▓▓_http://userstyles.org/styles/18192/nightshift-eye-care_▓▓ */

      @namespace url(http://www.w3.org/1999/xhtml);
      @-moz-document regexp("https?://www.youtube.com/.*") {
      body,html min-height: 100%!important;
      html, bodybackground-color:#111!important
      body>*:not(:empty)background-color:#222!important
      body>*>*:not(:empty)background-color:#222!important
      body>*>*>*:not(:empty)background-color:#282828!important
      ...


      My question is this: how can I capture the output of sqlite> SELECT * FROM styles; to a file? (I know I can select the output in the terminal and copy it to a file.)










      share|improve this question














      I installed sqlite3 and want to use it to recover information from stylish.sqlite which is located in my Firefox profile folder and is generated by the Stylish extension:



      $ cd ~/.mozilla/firefox/w4wcp85s.default
      $ sqlite3 stylish.sqlite
      SQLite version 3.7.17 2013-05-20 00:56:22
      Enter ".help" for instructions
      Enter SQL statements terminated with a ";"
      sqlite> .tables
      style_meta styles
      sqlite> SELECT * FROM styles;
      6||||YouTube|/* AGENT_SHEET */
      /* ▓▓ NIGHTSHIFT - eye care: ▓▓
      ▓▓_http://userstyles.org/styles/18192/nightshift-eye-care_▓▓ */

      @namespace url(http://www.w3.org/1999/xhtml);
      @-moz-document regexp("https?://www.youtube.com/.*") {
      body,html min-height: 100%!important;
      html, bodybackground-color:#111!important
      body>*:not(:empty)background-color:#222!important
      body>*>*:not(:empty)background-color:#222!important
      body>*>*>*:not(:empty)background-color:#282828!important
      ...


      My question is this: how can I capture the output of sqlite> SELECT * FROM styles; to a file? (I know I can select the output in the terminal and copy it to a file.)







      io-redirection sqlite






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jan 30 '14 at 6:40







      user15760



























          2 Answers
          2






          active

          oldest

          votes


















          4














          Run it all as a single command:



          $ sqlite3 stylish.sqlite "SELECT * FROM styles;" > somefile.txt


          Example



          $ sqlite3 addons.sqlite "select * from icon;" > somefile.txt

          $ cat somefile.txt
          1|32|https://addons.cdn.mozilla.net/img/uploads/addon_icons/354/354399-32.png?modified=1369154804
          1|64|https://addons.cdn.mozilla.net/img/uploads/addon_icons/354/354399-64.png?modified=1369154804


          Using tee



          If you want to see the output as it's being written to the file you can use tee instead.



          $ sqlite3 addons.sqlite "select * from icon;" | tee somefile.txt
          1|32|https://addons.cdn.mozilla.net/img/uploads/addon_icons/354/354399-32.png?modified=1369154804
          1|64|https://addons.cdn.mozilla.net/img/uploads/addon_icons/354/354399-64.png?modified=1369154804





          share|improve this answer

























          • Won't work with binary blobs.

            – Julian F. Weinert
            Aug 4 '15 at 10:44


















          0














          From inside the SQLite command line interface



          If you are working inside the command line interface of SQLite, you cannot use redirections or pipes.

          However, you can use the command .output (the command .mode could be useful too).



          .output some_file
          SELECT * FROM table; /* SQLite saves the output in 'some_file' */

          .output
          SELECT * FROM table; /* SQLite presents the output again in the screen */


          Two notes:



          • As soon you run .output some_file, the output file is opened in mode "w",

            thus be careful if the file already exists and contains some data.

          • To unset the redirection you must use the .output command without arguments.

          An extra



          You can produce a CSV file using the command .mode.



          .mode csv
          .output some_file
          SELECT * FROM table;
          .output
          .mode





          share|improve this answer
























            Your Answer








            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "106"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f111608%2fhow-to-redirect-sqlite3-output-to-a-file%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown
























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            4














            Run it all as a single command:



            $ sqlite3 stylish.sqlite "SELECT * FROM styles;" > somefile.txt


            Example



            $ sqlite3 addons.sqlite "select * from icon;" > somefile.txt

            $ cat somefile.txt
            1|32|https://addons.cdn.mozilla.net/img/uploads/addon_icons/354/354399-32.png?modified=1369154804
            1|64|https://addons.cdn.mozilla.net/img/uploads/addon_icons/354/354399-64.png?modified=1369154804


            Using tee



            If you want to see the output as it's being written to the file you can use tee instead.



            $ sqlite3 addons.sqlite "select * from icon;" | tee somefile.txt
            1|32|https://addons.cdn.mozilla.net/img/uploads/addon_icons/354/354399-32.png?modified=1369154804
            1|64|https://addons.cdn.mozilla.net/img/uploads/addon_icons/354/354399-64.png?modified=1369154804





            share|improve this answer

























            • Won't work with binary blobs.

              – Julian F. Weinert
              Aug 4 '15 at 10:44















            4














            Run it all as a single command:



            $ sqlite3 stylish.sqlite "SELECT * FROM styles;" > somefile.txt


            Example



            $ sqlite3 addons.sqlite "select * from icon;" > somefile.txt

            $ cat somefile.txt
            1|32|https://addons.cdn.mozilla.net/img/uploads/addon_icons/354/354399-32.png?modified=1369154804
            1|64|https://addons.cdn.mozilla.net/img/uploads/addon_icons/354/354399-64.png?modified=1369154804


            Using tee



            If you want to see the output as it's being written to the file you can use tee instead.



            $ sqlite3 addons.sqlite "select * from icon;" | tee somefile.txt
            1|32|https://addons.cdn.mozilla.net/img/uploads/addon_icons/354/354399-32.png?modified=1369154804
            1|64|https://addons.cdn.mozilla.net/img/uploads/addon_icons/354/354399-64.png?modified=1369154804





            share|improve this answer

























            • Won't work with binary blobs.

              – Julian F. Weinert
              Aug 4 '15 at 10:44













            4












            4








            4







            Run it all as a single command:



            $ sqlite3 stylish.sqlite "SELECT * FROM styles;" > somefile.txt


            Example



            $ sqlite3 addons.sqlite "select * from icon;" > somefile.txt

            $ cat somefile.txt
            1|32|https://addons.cdn.mozilla.net/img/uploads/addon_icons/354/354399-32.png?modified=1369154804
            1|64|https://addons.cdn.mozilla.net/img/uploads/addon_icons/354/354399-64.png?modified=1369154804


            Using tee



            If you want to see the output as it's being written to the file you can use tee instead.



            $ sqlite3 addons.sqlite "select * from icon;" | tee somefile.txt
            1|32|https://addons.cdn.mozilla.net/img/uploads/addon_icons/354/354399-32.png?modified=1369154804
            1|64|https://addons.cdn.mozilla.net/img/uploads/addon_icons/354/354399-64.png?modified=1369154804





            share|improve this answer















            Run it all as a single command:



            $ sqlite3 stylish.sqlite "SELECT * FROM styles;" > somefile.txt


            Example



            $ sqlite3 addons.sqlite "select * from icon;" > somefile.txt

            $ cat somefile.txt
            1|32|https://addons.cdn.mozilla.net/img/uploads/addon_icons/354/354399-32.png?modified=1369154804
            1|64|https://addons.cdn.mozilla.net/img/uploads/addon_icons/354/354399-64.png?modified=1369154804


            Using tee



            If you want to see the output as it's being written to the file you can use tee instead.



            $ sqlite3 addons.sqlite "select * from icon;" | tee somefile.txt
            1|32|https://addons.cdn.mozilla.net/img/uploads/addon_icons/354/354399-32.png?modified=1369154804
            1|64|https://addons.cdn.mozilla.net/img/uploads/addon_icons/354/354399-64.png?modified=1369154804






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Jan 30 '14 at 6:55

























            answered Jan 30 '14 at 6:48









            slmslm

            251k66528685




            251k66528685












            • Won't work with binary blobs.

              – Julian F. Weinert
              Aug 4 '15 at 10:44

















            • Won't work with binary blobs.

              – Julian F. Weinert
              Aug 4 '15 at 10:44
















            Won't work with binary blobs.

            – Julian F. Weinert
            Aug 4 '15 at 10:44





            Won't work with binary blobs.

            – Julian F. Weinert
            Aug 4 '15 at 10:44













            0














            From inside the SQLite command line interface



            If you are working inside the command line interface of SQLite, you cannot use redirections or pipes.

            However, you can use the command .output (the command .mode could be useful too).



            .output some_file
            SELECT * FROM table; /* SQLite saves the output in 'some_file' */

            .output
            SELECT * FROM table; /* SQLite presents the output again in the screen */


            Two notes:



            • As soon you run .output some_file, the output file is opened in mode "w",

              thus be careful if the file already exists and contains some data.

            • To unset the redirection you must use the .output command without arguments.

            An extra



            You can produce a CSV file using the command .mode.



            .mode csv
            .output some_file
            SELECT * FROM table;
            .output
            .mode





            share|improve this answer





























              0














              From inside the SQLite command line interface



              If you are working inside the command line interface of SQLite, you cannot use redirections or pipes.

              However, you can use the command .output (the command .mode could be useful too).



              .output some_file
              SELECT * FROM table; /* SQLite saves the output in 'some_file' */

              .output
              SELECT * FROM table; /* SQLite presents the output again in the screen */


              Two notes:



              • As soon you run .output some_file, the output file is opened in mode "w",

                thus be careful if the file already exists and contains some data.

              • To unset the redirection you must use the .output command without arguments.

              An extra



              You can produce a CSV file using the command .mode.



              .mode csv
              .output some_file
              SELECT * FROM table;
              .output
              .mode





              share|improve this answer



























                0












                0








                0







                From inside the SQLite command line interface



                If you are working inside the command line interface of SQLite, you cannot use redirections or pipes.

                However, you can use the command .output (the command .mode could be useful too).



                .output some_file
                SELECT * FROM table; /* SQLite saves the output in 'some_file' */

                .output
                SELECT * FROM table; /* SQLite presents the output again in the screen */


                Two notes:



                • As soon you run .output some_file, the output file is opened in mode "w",

                  thus be careful if the file already exists and contains some data.

                • To unset the redirection you must use the .output command without arguments.

                An extra



                You can produce a CSV file using the command .mode.



                .mode csv
                .output some_file
                SELECT * FROM table;
                .output
                .mode





                share|improve this answer















                From inside the SQLite command line interface



                If you are working inside the command line interface of SQLite, you cannot use redirections or pipes.

                However, you can use the command .output (the command .mode could be useful too).



                .output some_file
                SELECT * FROM table; /* SQLite saves the output in 'some_file' */

                .output
                SELECT * FROM table; /* SQLite presents the output again in the screen */


                Two notes:



                • As soon you run .output some_file, the output file is opened in mode "w",

                  thus be careful if the file already exists and contains some data.

                • To unset the redirection you must use the .output command without arguments.

                An extra



                You can produce a CSV file using the command .mode.



                .mode csv
                .output some_file
                SELECT * FROM table;
                .output
                .mode






                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Jan 24 at 23:46

























                answered Jan 24 at 23:05









                ePi272314ePi272314

                1013




                1013



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Unix & Linux Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f111608%2fhow-to-redirect-sqlite3-output-to-a-file%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown






                    Popular posts from this blog

                    How to check contact read email or not when send email to Individual?

                    Bahrain

                    Postfix configuration issue with fips on centos 7; mailgun relay