1

By mistake, I created a lot of tmp files suffix '.bedgraph' in my working directory. How could I delete them? I tried to use rm -rf *.bedgraph but it did not work.

MBD_peak_bedfile
N?????A???c??XO.bedgraph
N8??-?X???X?g.??<?=Ԓ????p???<?zʴ?9?JO:J??????iưUl??d>?.bedgraph
N[????n??v?2|z?F7,?ܧ?????g9d.m#??R??.bedgraph
Nq???)???qgV{?hz`?????K,?.bedgraph
Nq??(JBv?D???L???lo??"??8????w??U"?[???*?Q??????Ј???R????;u?c<?s???}`>??=?Ft???h^???S???}??EP??!AdC??J?]?`.bedgraph
Oդ?k.bedgraph
O?m|?t)???¶?j????ci?O???"?F??J?,???*??????%??????ֳ?^?6??{v}3D?4??Ek??c3l??Hw?????+{???&?ۙ6???a?????BM;,fi?(_???????n??@`?.bedgraph
O9???n???t???܁?і??V7??.bedgraph
OC}?U?Q???.bedgraph
OEbѻh?_?Ri_?~???ׂ???-i:?6խtq?&?.bedgraph
On????(???,?ݶ5??-Ֆ?????Ҫ'?$??????S-??<M???(??՛??.bedgraph
O|?i?U?ֽ???oo???vK?????~w?Yڄ[????S"??A?ۃ??????U??؉??F?????????Ʋ1?3$???P?Lg?????x,&?Q?????.bedgraph
Oű??4?"?DI&?OE?Mp?????M??#r%?O?????????!?@~????p???K????9̡?L??z??E?㰹???????-???^?.bedgraph
P?+?g?+ԟm(??ֆ.bedgraph
P?;?}=9??.bedgraph
P?H?????v??$?Y^d?h?'?.,?S??cEٴ??.bedgraph
P.bedgraph
PeakSplitter_Cpp
PeakSplitter_Cpp_1.0.tar.gz
...

I could just ignore those tmp files, but they make the directory really messy.

  • you want to delete only those files which has bedgraph in their name ? – Rahul Jun 22 '16 at 12:52
  • 1
    did you use rm -- "*.bedgraph"? – Braiam Jun 22 '16 at 12:54
  • @Rahul. Except one named "TFChIP_tCD25input.sort.bedgraph" – Jun Jun 22 '16 at 12:59
  • rename the good one to TFChIP_tCD25input.sort.bedgraph.GOOD then get rid of the bad "*.bedgraph" files, I suggest by moving them to a temporary directory first, then rm -rf the directory when you're sure. Afterwards rename your good file back to its former name – infixed Jun 22 '16 at 14:16
1
find . -name '*.bedgraph' -delete 

should work.

Be careful not to delete anything inadvertently.

  • 4
    Run with --print instead of --delete first (or just delete --delete) to see if the right files are selected. – Kusalananda Jun 22 '16 at 12:58
  • @Kusalananda Thanks for explaining my last sentence. – PSkocik Jun 22 '16 at 13:02
  • @PSkocik. Yes, it worked. Also it was the exact reason why "rm" did not work. what if I want to exempt one file name "donotwannadelete.bedgraph" from deletion? – Jun Jun 22 '16 at 13:03
  • 1
    @Jun use find ! -name 'donotwannadelete.bedgraph' .. – Rahul Jun 22 '16 at 13:04
  • @Rahul. I see, TKS! – Jun Jun 22 '16 at 13:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.