FG
💻 Software

ls | grep | rm -- How to format this command?

Fresh7 days ago
Mar 15, 202625579 views
Confidence Score0%
0%

Problem

I'm trying to delete a bunch of files in a certain directory (on Mac OS X using Terminal) should do the trick, but it doesn't. I'm trying to delete any file with a single digit in parentheses in the filename (duplicates downloaded from the web), but it ends up doing something like this: because it …

Error Output

ls | grep \([1-9]\) | xargs rm

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: ls | grep | rm -- How to format this command?

Low Risk

Short version: Do not pipe to . Instead, pipe to , in order to avoid such problems. ...which can be written as: and: which can further be shortened to just with a wildcard. Normally, and separate file names with newlines, but splits its input by new…

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment