How is it possible to delete files containing a string as an embedded string except at the
beginning or end by using wild-cards.
I’m an amateur started Ubuntu less than a month.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I don’t think this is possible with a single expansion pattern. You can use
grepfor filtering instead:So the
lslists everything containingfoo, thenegrepremoves the files with matches at the beginning/end, and finallyxargsruns a command (rmin this case) on each remainder.The dangerous thing about this technique is that filenames may contain special characters like line breaks or asterisks, so use at your own risk!