correct order while combining different options of a commandHow to check/test .tar.bz archives?Recover...

Applying a Taylor series WITH RESPECT TO ... and AROUND...

What container to use to store developer concentrate?

How to store my pliers and wire cutters on my desk?

Anti-cheating: should there be a limit to a number of toilet breaks per game per player?

What is this 4 sharp symbol and what does it mean?

reconstruction filter - How does it actually work?

If you inherit a Roth 401(k), is it taxed?

Assuring luggage isn't lost with short layover

Is there a wealth gap in Boston where the median net worth of white households is $247,500 while the median net worth for black families was $8?

Struggling with cyclical dependancies in unit tests

How did the Axis intend to hold the Caucasus?

Why were contact sensors put on three of the Lunar Module's four legs? Did they ever bend and stick out sideways?

How do I use JSON.generator to generate an unnamed array?

Does Dispel Magic destroy Artificer Turrets?

Compound Word Neologism

Why do they sell Cat 5 Ethernet splitters if you can’t split the signal?

Incrementing add under condition in pandas

What is more environmentally friendly? An A320 or a car?

How could Nomadic scholars effectively memorize libraries worth of information

What steps would an amateur scientist have to take in order to get a scientific breakthrough published?

Dobbs Murder Mystery : A Picture worth 1000 words?

What do you call a flexible diving platform?

Is it safe if the neutral lead is exposed and disconnected?

Polyhedra, Polyhedron, Polytopes and Polygon



correct order while combining different options of a command


How to check/test .tar.bz archives?Recover corrupted .tar salvaged from AndroidWhy is my tar file bigger than its contents?creating archive using tar including all 'dotfiles' but excluding all subdirectories and /wo directory structureWhy does the specific sequence of options matter for tar command?Why did “argument can be squished against option” prevail over “argument is always separate”?Is possible to remove “on fly” the full path using tar?Archive big data into multiple partsWhat does cat of a tar archive show?Tar Splitting Into Standalone Volumes






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







0















I usually combine options together whenever there are more than one option to be used with respect to some command. For example , if i want to create an archive using tar i will write tar -cvf archive.tar file1 file2 but my doubt is that how to know the correct order in which i have to combine the options together. If i use tar -cfv archive.tar file1 file2 it shows error. I have faced this issue with many other commands also. I know it is a very silly doubt but i was having a really hard time getting through it. I have checked the man description of the commands also but there they have specified a particular sequence under the synopsis section. I was not able to find something related to combining the options in a particular sequence.










share|improve this question































    0















    I usually combine options together whenever there are more than one option to be used with respect to some command. For example , if i want to create an archive using tar i will write tar -cvf archive.tar file1 file2 but my doubt is that how to know the correct order in which i have to combine the options together. If i use tar -cfv archive.tar file1 file2 it shows error. I have faced this issue with many other commands also. I know it is a very silly doubt but i was having a really hard time getting through it. I have checked the man description of the commands also but there they have specified a particular sequence under the synopsis section. I was not able to find something related to combining the options in a particular sequence.










    share|improve this question



























      0












      0








      0








      I usually combine options together whenever there are more than one option to be used with respect to some command. For example , if i want to create an archive using tar i will write tar -cvf archive.tar file1 file2 but my doubt is that how to know the correct order in which i have to combine the options together. If i use tar -cfv archive.tar file1 file2 it shows error. I have faced this issue with many other commands also. I know it is a very silly doubt but i was having a really hard time getting through it. I have checked the man description of the commands also but there they have specified a particular sequence under the synopsis section. I was not able to find something related to combining the options in a particular sequence.










      share|improve this question














      I usually combine options together whenever there are more than one option to be used with respect to some command. For example , if i want to create an archive using tar i will write tar -cvf archive.tar file1 file2 but my doubt is that how to know the correct order in which i have to combine the options together. If i use tar -cfv archive.tar file1 file2 it shows error. I have faced this issue with many other commands also. I know it is a very silly doubt but i was having a really hard time getting through it. I have checked the man description of the commands also but there they have specified a particular sequence under the synopsis section. I was not able to find something related to combining the options in a particular sequence.







      bash ubuntu tar options archive






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 41 mins ago









      NoshiiiNoshiii

      981 silver badge9 bronze badges




      981 silver badge9 bronze badges

























          2 Answers
          2






          active

          oldest

          votes


















          2














          The manual for any given command will describe exactly how to use its options.



          In this case, the -f option takes a filename argument. An option's argument (if it takes one) must be placed just after it. In your first tar command, this filename argument is archive.tar, but in your second it is v.



          The second command tries to create an archive called v from three files, archive.tar file1, and file2. Since archive.tar probably does not exist, you would get an error message about this.



          Again, the tar manual would describe this. The GNU tar manual say



          tar -c [-f ARCHIVE] [OPTIONS] [FILE...]


          so it's clear that -f takes the name of an archive. A bit further down, it says




          -f, --file=ARCHIVE



          Use archive file or device ARCHIVE. [...]




          The other options that you use, -c and -v, don't take arguments.



          Also, in general, options come before file operands. Some GNU tools allow you to add opions to the very end of the command line, as in



          tar -c -f archive.tar file1 file2 -v


          but this is (IMHO) bad style, and it would break on many other Unices (-v would be interpreted as a file name).



          The 100% correct way to write your tar command, following the form in the synopsis, is



          tar -c -f archive.tar -v file1 file2





          share|improve this answer





















          • 1





            thank you so much for clear explanation

            – Noshiii
            17 mins ago



















          0














          The issue most usually has to do with options which require a following argument.
          Let's look at tar as an example.
          -f requires a filename, so it must be followed by a filename.



          A general form of argument parsing in pseudocode might help illustrate this:
          Remember that arguments are given to the command as a vector (-cvf file would be broken to argv[0]=c argv[1]=v argv[2]=f argv[3]=file)



          While $argv is not empty
          do
          case $argv[0] in # argv[0] is pointer to leftmost, or first, arg
          c) # single element argument
          set internal variable create_mode=true
          shift # remove argv[0], shifting all indexes down by 1, so argv[0] now points to former argv[1]
          f) # A double element argument
          set internal variable use_file=true
          shift
          set internal variable file_name=$argv[0] # We did a shift, so now argv[0] points to the argument following 'f'
          shift
          v) # Another single element argument
          set internal variable verbose=true
          shift
          # and so on, there is a case for each possible argument, and shifts according to the number of elements in each argument
          done


          The loop will continue processing each argument in argv, until argv (argument vector) is empty.

          As you can see, if an argument has several parts, due to the implementation of argument processing, all it's parts must follow the argument immediately.





          share




























            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%2f532875%2fcorrect-order-while-combining-different-options-of-a-command%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









            2














            The manual for any given command will describe exactly how to use its options.



            In this case, the -f option takes a filename argument. An option's argument (if it takes one) must be placed just after it. In your first tar command, this filename argument is archive.tar, but in your second it is v.



            The second command tries to create an archive called v from three files, archive.tar file1, and file2. Since archive.tar probably does not exist, you would get an error message about this.



            Again, the tar manual would describe this. The GNU tar manual say



            tar -c [-f ARCHIVE] [OPTIONS] [FILE...]


            so it's clear that -f takes the name of an archive. A bit further down, it says




            -f, --file=ARCHIVE



            Use archive file or device ARCHIVE. [...]




            The other options that you use, -c and -v, don't take arguments.



            Also, in general, options come before file operands. Some GNU tools allow you to add opions to the very end of the command line, as in



            tar -c -f archive.tar file1 file2 -v


            but this is (IMHO) bad style, and it would break on many other Unices (-v would be interpreted as a file name).



            The 100% correct way to write your tar command, following the form in the synopsis, is



            tar -c -f archive.tar -v file1 file2





            share|improve this answer





















            • 1





              thank you so much for clear explanation

              – Noshiii
              17 mins ago
















            2














            The manual for any given command will describe exactly how to use its options.



            In this case, the -f option takes a filename argument. An option's argument (if it takes one) must be placed just after it. In your first tar command, this filename argument is archive.tar, but in your second it is v.



            The second command tries to create an archive called v from three files, archive.tar file1, and file2. Since archive.tar probably does not exist, you would get an error message about this.



            Again, the tar manual would describe this. The GNU tar manual say



            tar -c [-f ARCHIVE] [OPTIONS] [FILE...]


            so it's clear that -f takes the name of an archive. A bit further down, it says




            -f, --file=ARCHIVE



            Use archive file or device ARCHIVE. [...]




            The other options that you use, -c and -v, don't take arguments.



            Also, in general, options come before file operands. Some GNU tools allow you to add opions to the very end of the command line, as in



            tar -c -f archive.tar file1 file2 -v


            but this is (IMHO) bad style, and it would break on many other Unices (-v would be interpreted as a file name).



            The 100% correct way to write your tar command, following the form in the synopsis, is



            tar -c -f archive.tar -v file1 file2





            share|improve this answer





















            • 1





              thank you so much for clear explanation

              – Noshiii
              17 mins ago














            2












            2








            2







            The manual for any given command will describe exactly how to use its options.



            In this case, the -f option takes a filename argument. An option's argument (if it takes one) must be placed just after it. In your first tar command, this filename argument is archive.tar, but in your second it is v.



            The second command tries to create an archive called v from three files, archive.tar file1, and file2. Since archive.tar probably does not exist, you would get an error message about this.



            Again, the tar manual would describe this. The GNU tar manual say



            tar -c [-f ARCHIVE] [OPTIONS] [FILE...]


            so it's clear that -f takes the name of an archive. A bit further down, it says




            -f, --file=ARCHIVE



            Use archive file or device ARCHIVE. [...]




            The other options that you use, -c and -v, don't take arguments.



            Also, in general, options come before file operands. Some GNU tools allow you to add opions to the very end of the command line, as in



            tar -c -f archive.tar file1 file2 -v


            but this is (IMHO) bad style, and it would break on many other Unices (-v would be interpreted as a file name).



            The 100% correct way to write your tar command, following the form in the synopsis, is



            tar -c -f archive.tar -v file1 file2





            share|improve this answer













            The manual for any given command will describe exactly how to use its options.



            In this case, the -f option takes a filename argument. An option's argument (if it takes one) must be placed just after it. In your first tar command, this filename argument is archive.tar, but in your second it is v.



            The second command tries to create an archive called v from three files, archive.tar file1, and file2. Since archive.tar probably does not exist, you would get an error message about this.



            Again, the tar manual would describe this. The GNU tar manual say



            tar -c [-f ARCHIVE] [OPTIONS] [FILE...]


            so it's clear that -f takes the name of an archive. A bit further down, it says




            -f, --file=ARCHIVE



            Use archive file or device ARCHIVE. [...]




            The other options that you use, -c and -v, don't take arguments.



            Also, in general, options come before file operands. Some GNU tools allow you to add opions to the very end of the command line, as in



            tar -c -f archive.tar file1 file2 -v


            but this is (IMHO) bad style, and it would break on many other Unices (-v would be interpreted as a file name).



            The 100% correct way to write your tar command, following the form in the synopsis, is



            tar -c -f archive.tar -v file1 file2






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered 32 mins ago









            KusalanandaKusalananda

            156k18 gold badges311 silver badges495 bronze badges




            156k18 gold badges311 silver badges495 bronze badges











            • 1





              thank you so much for clear explanation

              – Noshiii
              17 mins ago














            • 1





              thank you so much for clear explanation

              – Noshiii
              17 mins ago








            1




            1





            thank you so much for clear explanation

            – Noshiii
            17 mins ago





            thank you so much for clear explanation

            – Noshiii
            17 mins ago













            0














            The issue most usually has to do with options which require a following argument.
            Let's look at tar as an example.
            -f requires a filename, so it must be followed by a filename.



            A general form of argument parsing in pseudocode might help illustrate this:
            Remember that arguments are given to the command as a vector (-cvf file would be broken to argv[0]=c argv[1]=v argv[2]=f argv[3]=file)



            While $argv is not empty
            do
            case $argv[0] in # argv[0] is pointer to leftmost, or first, arg
            c) # single element argument
            set internal variable create_mode=true
            shift # remove argv[0], shifting all indexes down by 1, so argv[0] now points to former argv[1]
            f) # A double element argument
            set internal variable use_file=true
            shift
            set internal variable file_name=$argv[0] # We did a shift, so now argv[0] points to the argument following 'f'
            shift
            v) # Another single element argument
            set internal variable verbose=true
            shift
            # and so on, there is a case for each possible argument, and shifts according to the number of elements in each argument
            done


            The loop will continue processing each argument in argv, until argv (argument vector) is empty.

            As you can see, if an argument has several parts, due to the implementation of argument processing, all it's parts must follow the argument immediately.





            share






























              0














              The issue most usually has to do with options which require a following argument.
              Let's look at tar as an example.
              -f requires a filename, so it must be followed by a filename.



              A general form of argument parsing in pseudocode might help illustrate this:
              Remember that arguments are given to the command as a vector (-cvf file would be broken to argv[0]=c argv[1]=v argv[2]=f argv[3]=file)



              While $argv is not empty
              do
              case $argv[0] in # argv[0] is pointer to leftmost, or first, arg
              c) # single element argument
              set internal variable create_mode=true
              shift # remove argv[0], shifting all indexes down by 1, so argv[0] now points to former argv[1]
              f) # A double element argument
              set internal variable use_file=true
              shift
              set internal variable file_name=$argv[0] # We did a shift, so now argv[0] points to the argument following 'f'
              shift
              v) # Another single element argument
              set internal variable verbose=true
              shift
              # and so on, there is a case for each possible argument, and shifts according to the number of elements in each argument
              done


              The loop will continue processing each argument in argv, until argv (argument vector) is empty.

              As you can see, if an argument has several parts, due to the implementation of argument processing, all it's parts must follow the argument immediately.





              share




























                0












                0








                0







                The issue most usually has to do with options which require a following argument.
                Let's look at tar as an example.
                -f requires a filename, so it must be followed by a filename.



                A general form of argument parsing in pseudocode might help illustrate this:
                Remember that arguments are given to the command as a vector (-cvf file would be broken to argv[0]=c argv[1]=v argv[2]=f argv[3]=file)



                While $argv is not empty
                do
                case $argv[0] in # argv[0] is pointer to leftmost, or first, arg
                c) # single element argument
                set internal variable create_mode=true
                shift # remove argv[0], shifting all indexes down by 1, so argv[0] now points to former argv[1]
                f) # A double element argument
                set internal variable use_file=true
                shift
                set internal variable file_name=$argv[0] # We did a shift, so now argv[0] points to the argument following 'f'
                shift
                v) # Another single element argument
                set internal variable verbose=true
                shift
                # and so on, there is a case for each possible argument, and shifts according to the number of elements in each argument
                done


                The loop will continue processing each argument in argv, until argv (argument vector) is empty.

                As you can see, if an argument has several parts, due to the implementation of argument processing, all it's parts must follow the argument immediately.





                share













                The issue most usually has to do with options which require a following argument.
                Let's look at tar as an example.
                -f requires a filename, so it must be followed by a filename.



                A general form of argument parsing in pseudocode might help illustrate this:
                Remember that arguments are given to the command as a vector (-cvf file would be broken to argv[0]=c argv[1]=v argv[2]=f argv[3]=file)



                While $argv is not empty
                do
                case $argv[0] in # argv[0] is pointer to leftmost, or first, arg
                c) # single element argument
                set internal variable create_mode=true
                shift # remove argv[0], shifting all indexes down by 1, so argv[0] now points to former argv[1]
                f) # A double element argument
                set internal variable use_file=true
                shift
                set internal variable file_name=$argv[0] # We did a shift, so now argv[0] points to the argument following 'f'
                shift
                v) # Another single element argument
                set internal variable verbose=true
                shift
                # and so on, there is a case for each possible argument, and shifts according to the number of elements in each argument
                done


                The loop will continue processing each argument in argv, until argv (argument vector) is empty.

                As you can see, if an argument has several parts, due to the implementation of argument processing, all it's parts must follow the argument immediately.






                share











                share


                share










                answered 8 mins ago









                Dani_lDani_l

                3,3211 gold badge11 silver badges30 bronze badges




                3,3211 gold badge11 silver badges30 bronze badges

































                    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%2f532875%2fcorrect-order-while-combining-different-options-of-a-command%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

                    Taj Mahal Inhaltsverzeichnis Aufbau | Geschichte | 350-Jahr-Feier | Heutige Bedeutung | Siehe auch |...

                    Baia Sprie Cuprins Etimologie | Istorie | Demografie | Politică și administrație | Arii naturale...

                    Nicolae Petrescu-Găină Cuprins Biografie | Opera | In memoriam | Varia | Controverse, incertitudini...