How to remove/rename file which contains special character eg. “-x” using command line [duplicate]











up vote
0
down vote

favorite













Possible Duplicate:
What does “--” (double-dash) mean?






Can anybody explain me below things



i have file named "-xyz".
if i try to remove or move that file using command line , it's unable to move.
i tried below things :



[rahul@srv100 ~]# ls -lrt  -- "-xyz"
-rw-r--r-- 1 rahul rahul 0 Dec 19 08:06 -xyz
[rahul@srv100 ~]# mv "-xyz" xyz
mv: invalid option -- x
Try `mv --help' for more information.
[rahul@srv100 ~]# mv -xyz xyz
mv: invalid option -- x
Try `mv --help' for more information.
[rahul@srv100 ~]# mv -xyz xyz
mv: invalid option -- x
Try `mv --help' for more information.
[rahul@srv100 ~]# mv '-xyz' xyz
mv: invalid option -- x
Try `mv --help' for more information.


finally i rename that file using winscp, and after trying multiple ways i got one option and it's working.



mv -- '-xyz' xyz


Wish the help of "--", i created file/directory as below



mkdir -- --abc
touch -- -xyz


So my Question is what is this "--" in bash ?
Please explain.










share|improve this question















marked as duplicate by Stéphane Chazelas, manatwork, Renan, Ulrich Dangel, George M Dec 21 '12 at 12:46


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.















  • For info, -- has nothing to do with bash. In your case, you can also use ./-xyz.
    – gniourf_gniourf
    Dec 21 '12 at 9:56

















up vote
0
down vote

favorite













Possible Duplicate:
What does “--” (double-dash) mean?






Can anybody explain me below things



i have file named "-xyz".
if i try to remove or move that file using command line , it's unable to move.
i tried below things :



[rahul@srv100 ~]# ls -lrt  -- "-xyz"
-rw-r--r-- 1 rahul rahul 0 Dec 19 08:06 -xyz
[rahul@srv100 ~]# mv "-xyz" xyz
mv: invalid option -- x
Try `mv --help' for more information.
[rahul@srv100 ~]# mv -xyz xyz
mv: invalid option -- x
Try `mv --help' for more information.
[rahul@srv100 ~]# mv -xyz xyz
mv: invalid option -- x
Try `mv --help' for more information.
[rahul@srv100 ~]# mv '-xyz' xyz
mv: invalid option -- x
Try `mv --help' for more information.


finally i rename that file using winscp, and after trying multiple ways i got one option and it's working.



mv -- '-xyz' xyz


Wish the help of "--", i created file/directory as below



mkdir -- --abc
touch -- -xyz


So my Question is what is this "--" in bash ?
Please explain.










share|improve this question















marked as duplicate by Stéphane Chazelas, manatwork, Renan, Ulrich Dangel, George M Dec 21 '12 at 12:46


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.















  • For info, -- has nothing to do with bash. In your case, you can also use ./-xyz.
    – gniourf_gniourf
    Dec 21 '12 at 9:56















up vote
0
down vote

favorite









up vote
0
down vote

favorite












Possible Duplicate:
What does “--” (double-dash) mean?






Can anybody explain me below things



i have file named "-xyz".
if i try to remove or move that file using command line , it's unable to move.
i tried below things :



[rahul@srv100 ~]# ls -lrt  -- "-xyz"
-rw-r--r-- 1 rahul rahul 0 Dec 19 08:06 -xyz
[rahul@srv100 ~]# mv "-xyz" xyz
mv: invalid option -- x
Try `mv --help' for more information.
[rahul@srv100 ~]# mv -xyz xyz
mv: invalid option -- x
Try `mv --help' for more information.
[rahul@srv100 ~]# mv -xyz xyz
mv: invalid option -- x
Try `mv --help' for more information.
[rahul@srv100 ~]# mv '-xyz' xyz
mv: invalid option -- x
Try `mv --help' for more information.


finally i rename that file using winscp, and after trying multiple ways i got one option and it's working.



mv -- '-xyz' xyz


Wish the help of "--", i created file/directory as below



mkdir -- --abc
touch -- -xyz


So my Question is what is this "--" in bash ?
Please explain.










share|improve this question
















Possible Duplicate:
What does “--” (double-dash) mean?






Can anybody explain me below things



i have file named "-xyz".
if i try to remove or move that file using command line , it's unable to move.
i tried below things :



[rahul@srv100 ~]# ls -lrt  -- "-xyz"
-rw-r--r-- 1 rahul rahul 0 Dec 19 08:06 -xyz
[rahul@srv100 ~]# mv "-xyz" xyz
mv: invalid option -- x
Try `mv --help' for more information.
[rahul@srv100 ~]# mv -xyz xyz
mv: invalid option -- x
Try `mv --help' for more information.
[rahul@srv100 ~]# mv -xyz xyz
mv: invalid option -- x
Try `mv --help' for more information.
[rahul@srv100 ~]# mv '-xyz' xyz
mv: invalid option -- x
Try `mv --help' for more information.


finally i rename that file using winscp, and after trying multiple ways i got one option and it's working.



mv -- '-xyz' xyz


Wish the help of "--", i created file/directory as below



mkdir -- --abc
touch -- -xyz


So my Question is what is this "--" in bash ?
Please explain.







bash






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Apr 13 '17 at 12:36









Community

1




1










asked Dec 21 '12 at 9:12









Rahul Patil

14.7k186082




14.7k186082




marked as duplicate by Stéphane Chazelas, manatwork, Renan, Ulrich Dangel, George M Dec 21 '12 at 12:46


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






marked as duplicate by Stéphane Chazelas, manatwork, Renan, Ulrich Dangel, George M Dec 21 '12 at 12:46


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • For info, -- has nothing to do with bash. In your case, you can also use ./-xyz.
    – gniourf_gniourf
    Dec 21 '12 at 9:56




















  • For info, -- has nothing to do with bash. In your case, you can also use ./-xyz.
    – gniourf_gniourf
    Dec 21 '12 at 9:56


















For info, -- has nothing to do with bash. In your case, you can also use ./-xyz.
– gniourf_gniourf
Dec 21 '12 at 9:56






For info, -- has nothing to do with bash. In your case, you can also use ./-xyz.
– gniourf_gniourf
Dec 21 '12 at 9:56












3 Answers
3






active

oldest

votes

















up vote
1
down vote



accepted










As others have already mentioned -- is used to delimit options from arguments. If you execute a program and specify any arguments the program has no way of distinguishing if the specified arguments should be interpreted as a command line option or an argument. That is the reason why a prefix for options was introduced - / -- or / on windows, i.e. -rf,--help or /?



As you may have files beginning with a such an prefix or any other special name which could be interpreted -- was introduced to delimit command line options from normal arguments, i.e. every argument after -- will not be treated as a command line option but just as a argument. getopt (1), a standard solution to parse arguments, for example supports the -- delimiter which means any program using getopt automatically supports the -- delimiter.



If you want to work with files starting with special characters like - you can also just add ./ in front of them as they now don't start with - so they won't be interpreted as command line option, for your example it would be mkdir ./--abc






share|improve this answer




























    up vote
    1
    down vote













    This is used to tell the command that after that point no more command options are accepted.



    So




    rm -- -abc




    means that it will ignore the - from the abc.



    for more information you can refer to:
    http://tldp.org/LDP/abs/html/special-chars.html






    share|improve this answer

















    • 2




      Not really ignore the - from the -abc. Instead, it will not consider -abc to be an option, since after the --, no more options are interpreted, only arguments.
      – gniourf_gniourf
      Dec 21 '12 at 9:58




















    up vote
    1
    down vote













    It's an indicator to the individual commands to stop interpreting further command line arguments as options.






    share|improve this answer






























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      1
      down vote



      accepted










      As others have already mentioned -- is used to delimit options from arguments. If you execute a program and specify any arguments the program has no way of distinguishing if the specified arguments should be interpreted as a command line option or an argument. That is the reason why a prefix for options was introduced - / -- or / on windows, i.e. -rf,--help or /?



      As you may have files beginning with a such an prefix or any other special name which could be interpreted -- was introduced to delimit command line options from normal arguments, i.e. every argument after -- will not be treated as a command line option but just as a argument. getopt (1), a standard solution to parse arguments, for example supports the -- delimiter which means any program using getopt automatically supports the -- delimiter.



      If you want to work with files starting with special characters like - you can also just add ./ in front of them as they now don't start with - so they won't be interpreted as command line option, for your example it would be mkdir ./--abc






      share|improve this answer

























        up vote
        1
        down vote



        accepted










        As others have already mentioned -- is used to delimit options from arguments. If you execute a program and specify any arguments the program has no way of distinguishing if the specified arguments should be interpreted as a command line option or an argument. That is the reason why a prefix for options was introduced - / -- or / on windows, i.e. -rf,--help or /?



        As you may have files beginning with a such an prefix or any other special name which could be interpreted -- was introduced to delimit command line options from normal arguments, i.e. every argument after -- will not be treated as a command line option but just as a argument. getopt (1), a standard solution to parse arguments, for example supports the -- delimiter which means any program using getopt automatically supports the -- delimiter.



        If you want to work with files starting with special characters like - you can also just add ./ in front of them as they now don't start with - so they won't be interpreted as command line option, for your example it would be mkdir ./--abc






        share|improve this answer























          up vote
          1
          down vote



          accepted







          up vote
          1
          down vote



          accepted






          As others have already mentioned -- is used to delimit options from arguments. If you execute a program and specify any arguments the program has no way of distinguishing if the specified arguments should be interpreted as a command line option or an argument. That is the reason why a prefix for options was introduced - / -- or / on windows, i.e. -rf,--help or /?



          As you may have files beginning with a such an prefix or any other special name which could be interpreted -- was introduced to delimit command line options from normal arguments, i.e. every argument after -- will not be treated as a command line option but just as a argument. getopt (1), a standard solution to parse arguments, for example supports the -- delimiter which means any program using getopt automatically supports the -- delimiter.



          If you want to work with files starting with special characters like - you can also just add ./ in front of them as they now don't start with - so they won't be interpreted as command line option, for your example it would be mkdir ./--abc






          share|improve this answer












          As others have already mentioned -- is used to delimit options from arguments. If you execute a program and specify any arguments the program has no way of distinguishing if the specified arguments should be interpreted as a command line option or an argument. That is the reason why a prefix for options was introduced - / -- or / on windows, i.e. -rf,--help or /?



          As you may have files beginning with a such an prefix or any other special name which could be interpreted -- was introduced to delimit command line options from normal arguments, i.e. every argument after -- will not be treated as a command line option but just as a argument. getopt (1), a standard solution to parse arguments, for example supports the -- delimiter which means any program using getopt automatically supports the -- delimiter.



          If you want to work with files starting with special characters like - you can also just add ./ in front of them as they now don't start with - so they won't be interpreted as command line option, for your example it would be mkdir ./--abc







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Dec 21 '12 at 12:26









          Ulrich Dangel

          20.2k25771




          20.2k25771
























              up vote
              1
              down vote













              This is used to tell the command that after that point no more command options are accepted.



              So




              rm -- -abc




              means that it will ignore the - from the abc.



              for more information you can refer to:
              http://tldp.org/LDP/abs/html/special-chars.html






              share|improve this answer

















              • 2




                Not really ignore the - from the -abc. Instead, it will not consider -abc to be an option, since after the --, no more options are interpreted, only arguments.
                – gniourf_gniourf
                Dec 21 '12 at 9:58

















              up vote
              1
              down vote













              This is used to tell the command that after that point no more command options are accepted.



              So




              rm -- -abc




              means that it will ignore the - from the abc.



              for more information you can refer to:
              http://tldp.org/LDP/abs/html/special-chars.html






              share|improve this answer

















              • 2




                Not really ignore the - from the -abc. Instead, it will not consider -abc to be an option, since after the --, no more options are interpreted, only arguments.
                – gniourf_gniourf
                Dec 21 '12 at 9:58















              up vote
              1
              down vote










              up vote
              1
              down vote









              This is used to tell the command that after that point no more command options are accepted.



              So




              rm -- -abc




              means that it will ignore the - from the abc.



              for more information you can refer to:
              http://tldp.org/LDP/abs/html/special-chars.html






              share|improve this answer












              This is used to tell the command that after that point no more command options are accepted.



              So




              rm -- -abc




              means that it will ignore the - from the abc.



              for more information you can refer to:
              http://tldp.org/LDP/abs/html/special-chars.html







              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered Dec 21 '12 at 9:20









              BitsOfNix

              4,09321631




              4,09321631








              • 2




                Not really ignore the - from the -abc. Instead, it will not consider -abc to be an option, since after the --, no more options are interpreted, only arguments.
                – gniourf_gniourf
                Dec 21 '12 at 9:58
















              • 2




                Not really ignore the - from the -abc. Instead, it will not consider -abc to be an option, since after the --, no more options are interpreted, only arguments.
                – gniourf_gniourf
                Dec 21 '12 at 9:58










              2




              2




              Not really ignore the - from the -abc. Instead, it will not consider -abc to be an option, since after the --, no more options are interpreted, only arguments.
              – gniourf_gniourf
              Dec 21 '12 at 9:58






              Not really ignore the - from the -abc. Instead, it will not consider -abc to be an option, since after the --, no more options are interpreted, only arguments.
              – gniourf_gniourf
              Dec 21 '12 at 9:58












              up vote
              1
              down vote













              It's an indicator to the individual commands to stop interpreting further command line arguments as options.






              share|improve this answer



























                up vote
                1
                down vote













                It's an indicator to the individual commands to stop interpreting further command line arguments as options.






                share|improve this answer

























                  up vote
                  1
                  down vote










                  up vote
                  1
                  down vote









                  It's an indicator to the individual commands to stop interpreting further command line arguments as options.






                  share|improve this answer














                  It's an indicator to the individual commands to stop interpreting further command line arguments as options.







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Dec 21 '12 at 12:11









                  Renan

                  14.3k65376




                  14.3k65376










                  answered Dec 21 '12 at 9:20









                  Anil Tallapragada

                  112




                  112















                      Popular posts from this blog

                      サソリ

                      広島県道265号伴広島線

                      Setup Asymptote in Texstudio