Terminal only shows > symbol when I enter this find command [duplicate]











up vote
0
down vote

favorite













This question already has an answer here:




  • What mode does the terminal go into when I type a single quote?

    2 answers




I want to delete all .ppm and .png files under current directory. So after checking some web pages about the usage of "find" command on the Internet, I typed the command below:



find . -type f ( -iname ".png" -o -iname ".ppm ) -exec rm {} ;


but the Terminal just showed a



>


and did not do anything. What was wrong with it?










share|improve this question















marked as duplicate by wjandrea, Sergiy Kolodyazhnyy, karel, Fabby, Zanna Nov 30 at 11:24


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.















  • Since you had an argument list too long issue, see also Renaming large number of image files with bash
    – Zanna
    Nov 30 at 11:24















up vote
0
down vote

favorite













This question already has an answer here:




  • What mode does the terminal go into when I type a single quote?

    2 answers




I want to delete all .ppm and .png files under current directory. So after checking some web pages about the usage of "find" command on the Internet, I typed the command below:



find . -type f ( -iname ".png" -o -iname ".ppm ) -exec rm {} ;


but the Terminal just showed a



>


and did not do anything. What was wrong with it?










share|improve this question















marked as duplicate by wjandrea, Sergiy Kolodyazhnyy, karel, Fabby, Zanna Nov 30 at 11:24


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.















  • Since you had an argument list too long issue, see also Renaming large number of image files with bash
    – Zanna
    Nov 30 at 11:24













up vote
0
down vote

favorite









up vote
0
down vote

favorite












This question already has an answer here:




  • What mode does the terminal go into when I type a single quote?

    2 answers




I want to delete all .ppm and .png files under current directory. So after checking some web pages about the usage of "find" command on the Internet, I typed the command below:



find . -type f ( -iname ".png" -o -iname ".ppm ) -exec rm {} ;


but the Terminal just showed a



>


and did not do anything. What was wrong with it?










share|improve this question
















This question already has an answer here:




  • What mode does the terminal go into when I type a single quote?

    2 answers




I want to delete all .ppm and .png files under current directory. So after checking some web pages about the usage of "find" command on the Internet, I typed the command below:



find . -type f ( -iname ".png" -o -iname ".ppm ) -exec rm {} ;


but the Terminal just showed a



>


and did not do anything. What was wrong with it?





This question already has an answer here:




  • What mode does the terminal go into when I type a single quote?

    2 answers








16.04 command-line bash find






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 30 at 11:21









Zanna

49.3k13126236




49.3k13126236










asked Nov 29 at 23:52









gbcat

32




32




marked as duplicate by wjandrea, Sergiy Kolodyazhnyy, karel, Fabby, Zanna Nov 30 at 11:24


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 wjandrea, Sergiy Kolodyazhnyy, karel, Fabby, Zanna Nov 30 at 11:24


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.














  • Since you had an argument list too long issue, see also Renaming large number of image files with bash
    – Zanna
    Nov 30 at 11:24


















  • Since you had an argument list too long issue, see also Renaming large number of image files with bash
    – Zanna
    Nov 30 at 11:24
















Since you had an argument list too long issue, see also Renaming large number of image files with bash
– Zanna
Nov 30 at 11:24




Since you had an argument list too long issue, see also Renaming large number of image files with bash
– Zanna
Nov 30 at 11:24










2 Answers
2






active

oldest

votes

















up vote
3
down vote



accepted










You just forgot to close the quoted string with a " after ".ppm.



The > you see is Bash's secondary prompt, as defined by the $PS2 environment variable. You get it when you input a command fragment that is supposed to continue (like e.g. because it has an unclosed quoted string or a missing done or fi keyword...) but press Enter to make a line break.



Another thing is that -iname ".png" would only (case insensitively) match files with the exact name ".png". What you want is to match all files ending with ".png", so the condition must be -iname "*.png" instead. Same for ".ppm" of course.



So the correct find command would be:



find . -type f ( -iname "*.png" -o -iname "*.ppm" ) -exec rm {} ;


However, I'd usually recommend dry-running it without the -exec rm {} ; first and check the list of files again for correctness, before actually letting it delete stuff without further confirmation.



Also, as correctly pointed out in the comments, you can and probably should replace -exec rm {} ; with -delete to let find handle the deletion internally.






share|improve this answer























  • Thank you very much.
    – gbcat
    Nov 30 at 0:12






  • 1




    Note that you can use -delete instead of -exec rm {} ;, which is just cleaner
    – wjandrea
    Nov 30 at 0:25




















up vote
0
down vote













You don't need find for this. Instead, you can run



rm *{.png,.ppm}


in the directory.






share|improve this answer

















  • 1




    Sorry, I have tried it yet, but Argument list too long.
    – gbcat
    Nov 30 at 0:05










  • Have you copied and pasted it? I tested it and worked.
    – Turtle10000
    Nov 30 at 0:08






  • 1




    Of course it will work with a few images. But my directory contains more than 100,000 images.
    – gbcat
    Nov 30 at 0:10












  • Sorry then, didn't understand your first comment right.
    – Turtle10000
    Nov 30 at 0:11


















2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
3
down vote



accepted










You just forgot to close the quoted string with a " after ".ppm.



The > you see is Bash's secondary prompt, as defined by the $PS2 environment variable. You get it when you input a command fragment that is supposed to continue (like e.g. because it has an unclosed quoted string or a missing done or fi keyword...) but press Enter to make a line break.



Another thing is that -iname ".png" would only (case insensitively) match files with the exact name ".png". What you want is to match all files ending with ".png", so the condition must be -iname "*.png" instead. Same for ".ppm" of course.



So the correct find command would be:



find . -type f ( -iname "*.png" -o -iname "*.ppm" ) -exec rm {} ;


However, I'd usually recommend dry-running it without the -exec rm {} ; first and check the list of files again for correctness, before actually letting it delete stuff without further confirmation.



Also, as correctly pointed out in the comments, you can and probably should replace -exec rm {} ; with -delete to let find handle the deletion internally.






share|improve this answer























  • Thank you very much.
    – gbcat
    Nov 30 at 0:12






  • 1




    Note that you can use -delete instead of -exec rm {} ;, which is just cleaner
    – wjandrea
    Nov 30 at 0:25

















up vote
3
down vote



accepted










You just forgot to close the quoted string with a " after ".ppm.



The > you see is Bash's secondary prompt, as defined by the $PS2 environment variable. You get it when you input a command fragment that is supposed to continue (like e.g. because it has an unclosed quoted string or a missing done or fi keyword...) but press Enter to make a line break.



Another thing is that -iname ".png" would only (case insensitively) match files with the exact name ".png". What you want is to match all files ending with ".png", so the condition must be -iname "*.png" instead. Same for ".ppm" of course.



So the correct find command would be:



find . -type f ( -iname "*.png" -o -iname "*.ppm" ) -exec rm {} ;


However, I'd usually recommend dry-running it without the -exec rm {} ; first and check the list of files again for correctness, before actually letting it delete stuff without further confirmation.



Also, as correctly pointed out in the comments, you can and probably should replace -exec rm {} ; with -delete to let find handle the deletion internally.






share|improve this answer























  • Thank you very much.
    – gbcat
    Nov 30 at 0:12






  • 1




    Note that you can use -delete instead of -exec rm {} ;, which is just cleaner
    – wjandrea
    Nov 30 at 0:25















up vote
3
down vote



accepted







up vote
3
down vote



accepted






You just forgot to close the quoted string with a " after ".ppm.



The > you see is Bash's secondary prompt, as defined by the $PS2 environment variable. You get it when you input a command fragment that is supposed to continue (like e.g. because it has an unclosed quoted string or a missing done or fi keyword...) but press Enter to make a line break.



Another thing is that -iname ".png" would only (case insensitively) match files with the exact name ".png". What you want is to match all files ending with ".png", so the condition must be -iname "*.png" instead. Same for ".ppm" of course.



So the correct find command would be:



find . -type f ( -iname "*.png" -o -iname "*.ppm" ) -exec rm {} ;


However, I'd usually recommend dry-running it without the -exec rm {} ; first and check the list of files again for correctness, before actually letting it delete stuff without further confirmation.



Also, as correctly pointed out in the comments, you can and probably should replace -exec rm {} ; with -delete to let find handle the deletion internally.






share|improve this answer














You just forgot to close the quoted string with a " after ".ppm.



The > you see is Bash's secondary prompt, as defined by the $PS2 environment variable. You get it when you input a command fragment that is supposed to continue (like e.g. because it has an unclosed quoted string or a missing done or fi keyword...) but press Enter to make a line break.



Another thing is that -iname ".png" would only (case insensitively) match files with the exact name ".png". What you want is to match all files ending with ".png", so the condition must be -iname "*.png" instead. Same for ".ppm" of course.



So the correct find command would be:



find . -type f ( -iname "*.png" -o -iname "*.ppm" ) -exec rm {} ;


However, I'd usually recommend dry-running it without the -exec rm {} ; first and check the list of files again for correctness, before actually letting it delete stuff without further confirmation.



Also, as correctly pointed out in the comments, you can and probably should replace -exec rm {} ; with -delete to let find handle the deletion internally.







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 30 at 0:47

























answered Nov 30 at 0:11









Byte Commander

62.5k26169283




62.5k26169283












  • Thank you very much.
    – gbcat
    Nov 30 at 0:12






  • 1




    Note that you can use -delete instead of -exec rm {} ;, which is just cleaner
    – wjandrea
    Nov 30 at 0:25




















  • Thank you very much.
    – gbcat
    Nov 30 at 0:12






  • 1




    Note that you can use -delete instead of -exec rm {} ;, which is just cleaner
    – wjandrea
    Nov 30 at 0:25


















Thank you very much.
– gbcat
Nov 30 at 0:12




Thank you very much.
– gbcat
Nov 30 at 0:12




1




1




Note that you can use -delete instead of -exec rm {} ;, which is just cleaner
– wjandrea
Nov 30 at 0:25






Note that you can use -delete instead of -exec rm {} ;, which is just cleaner
– wjandrea
Nov 30 at 0:25














up vote
0
down vote













You don't need find for this. Instead, you can run



rm *{.png,.ppm}


in the directory.






share|improve this answer

















  • 1




    Sorry, I have tried it yet, but Argument list too long.
    – gbcat
    Nov 30 at 0:05










  • Have you copied and pasted it? I tested it and worked.
    – Turtle10000
    Nov 30 at 0:08






  • 1




    Of course it will work with a few images. But my directory contains more than 100,000 images.
    – gbcat
    Nov 30 at 0:10












  • Sorry then, didn't understand your first comment right.
    – Turtle10000
    Nov 30 at 0:11















up vote
0
down vote













You don't need find for this. Instead, you can run



rm *{.png,.ppm}


in the directory.






share|improve this answer

















  • 1




    Sorry, I have tried it yet, but Argument list too long.
    – gbcat
    Nov 30 at 0:05










  • Have you copied and pasted it? I tested it and worked.
    – Turtle10000
    Nov 30 at 0:08






  • 1




    Of course it will work with a few images. But my directory contains more than 100,000 images.
    – gbcat
    Nov 30 at 0:10












  • Sorry then, didn't understand your first comment right.
    – Turtle10000
    Nov 30 at 0:11













up vote
0
down vote










up vote
0
down vote









You don't need find for this. Instead, you can run



rm *{.png,.ppm}


in the directory.






share|improve this answer












You don't need find for this. Instead, you can run



rm *{.png,.ppm}


in the directory.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 30 at 0:03









Turtle10000

1065




1065








  • 1




    Sorry, I have tried it yet, but Argument list too long.
    – gbcat
    Nov 30 at 0:05










  • Have you copied and pasted it? I tested it and worked.
    – Turtle10000
    Nov 30 at 0:08






  • 1




    Of course it will work with a few images. But my directory contains more than 100,000 images.
    – gbcat
    Nov 30 at 0:10












  • Sorry then, didn't understand your first comment right.
    – Turtle10000
    Nov 30 at 0:11














  • 1




    Sorry, I have tried it yet, but Argument list too long.
    – gbcat
    Nov 30 at 0:05










  • Have you copied and pasted it? I tested it and worked.
    – Turtle10000
    Nov 30 at 0:08






  • 1




    Of course it will work with a few images. But my directory contains more than 100,000 images.
    – gbcat
    Nov 30 at 0:10












  • Sorry then, didn't understand your first comment right.
    – Turtle10000
    Nov 30 at 0:11








1




1




Sorry, I have tried it yet, but Argument list too long.
– gbcat
Nov 30 at 0:05




Sorry, I have tried it yet, but Argument list too long.
– gbcat
Nov 30 at 0:05












Have you copied and pasted it? I tested it and worked.
– Turtle10000
Nov 30 at 0:08




Have you copied and pasted it? I tested it and worked.
– Turtle10000
Nov 30 at 0:08




1




1




Of course it will work with a few images. But my directory contains more than 100,000 images.
– gbcat
Nov 30 at 0:10






Of course it will work with a few images. But my directory contains more than 100,000 images.
– gbcat
Nov 30 at 0:10














Sorry then, didn't understand your first comment right.
– Turtle10000
Nov 30 at 0:11




Sorry then, didn't understand your first comment right.
– Turtle10000
Nov 30 at 0:11



Popular posts from this blog

flock() on closed filehandle LOCK_FILE at /usr/bin/apt-mirror

Mangá

 ⁒  ․,‪⁊‑⁙ ⁖, ⁇‒※‌, †,⁖‗‌⁝    ‾‸⁘,‖⁔⁣,⁂‾
”‑,‥–,‬ ,⁀‹⁋‴⁑ ‒ ,‴⁋”‼ ⁨,‷⁔„ ‰′,‐‚ ‥‡‎“‷⁃⁨⁅⁣,⁔
⁇‘⁔⁡⁏⁌⁡‿‶‏⁨ ⁣⁕⁖⁨⁩⁥‽⁀  ‴‬⁜‟ ⁃‣‧⁕‮ …‍⁨‴ ⁩,⁚⁖‫ ,‵ ⁀,‮⁝‣‣ ⁑  ⁂– ․, ‾‽ ‏⁁“⁗‸ ‾… ‹‡⁌⁎‸‘ ‡⁏⁌‪ ‵⁛ ‎⁨ ―⁦⁤⁄⁕