question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

OS/X (bash) - Command to remove non essential files not working

See original GitHub issue

I am using mac with Sierra and the command to remove non essential files not working, here is the output for same -

Jeetendras-MacBook-Pro:quickstart Jeet$ xargs -a non-essential-files.txt rm -rf xargs: illegal option -- a usage: xargs [-0opt] [-E eofstr] [-I replstr [-R replacements]] [-J replstr] [-L number] [-n number [-x]] [-P maxprocs] [-s size] [utility [argument ...]]

Though there are workarounds for it, it would be good to have a fix here.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
trescenzicommented, Jan 31, 2017

@leebenson I think 1. makes the most sense. Sounds like you’d have to fix the file regardless and it’s probably better to use a command that’s valid on more *nix flavors(including OS X).

Thanks for the quick response!

1reaction
trescenzicommented, Jun 30, 2017

There are some extra nonreadable characters, at least by RHEL7, within the file.

rm -rf $(cat non-essential-files.txt) doesn’t work either.

A hexdump of the file shows what’s wrong:

(0)[11:06][tcrescenzi]~/web/frameworks-next/angular2-listbox/(master)λ hexdump non-essential-files.txt -C
00000000  2e 67 69 74 0d 0a 2e 67  69 74 69 67 6e 6f 72 65  |.git...gitignore|
00000010  0d 0a 2e 74 72 61 76 69  73 2e 79 6d 6c 0d 0a 2a  |...travis.yml..*|
00000020  2e 73 70 65 63 2a 2e 74  73 0d 0a 43 48 41 4e 47  |.spec*.ts..CHANG|
00000030  45 4c 4f 47 2e 6d 64 0d  0a 65 32 65 0d 0a 66 61  |ELOG.md..e2e..fa|
00000040  76 69 63 6f 6e 2e 69 63  6f 0d 0a 6b 61 72 6d 61  |vicon.ico..karma|
00000050  2e 63 6f 6e 66 2e 6a 73  0d 0a 6b 61 72 6d 61 2d  |.conf.js..karma-|
00000060  74 65 73 74 2d 73 68 69  6d 2e 6a 73 0d 0a 4c 49  |test-shim.js..LI|
00000070  43 45 4e 53 45 0d 0a 6e  6f 6e 2d 65 73 73 65 6e  |CENSE..non-essen|
00000080  74 69 61 6c 2d 66 69 6c  65 73 2e 74 78 74 0d 0a  |tial-files.txt..|
00000090  70 72 6f 74 72 61 63 74  6f 72 2e 63 6f 6e 66 69  |protractor.confi|
000000a0  67 2e 6a 73 0d 0a 52 45  41 44 4d 45 2e 6d 64 0d  |g.js..README.md.|
000000b0  0a                                                |.|
000000b1

The solution should be as simple as copying the file to your clipboard and then pasting it over the existing file. That worked for me.

Here’s also a list without the offending characters you can paste into a file that will work with xargs -a <file> rm -rf

.git
.gitignore
.travis.yml
*.spec*.ts
CHANGELOG.md
e2e
favicon.ico
karma.conf.js
karma-test-shim.js
LICENSE
non-essential-files.txt
protractor.config.js
README.md

For those uncertain if it’s working try xargs -a <file> ls and it’ll show you what will be touched by the command.

Read more comments on GitHub >

github_iconTop Results From Across the Web

5 Solutions to Force Delete a File on Mac[2022]
Step 3 - Find the File That You Want To Delete. Drag that file to the Terminal window that you want to delete....
Read more >
How to delete files and folders using command line on Mac
Here's how it works in practice: Launch Terminal from your Utilities folder in Applications. Check which directory you're in by typing ls -la....
Read more >
How to delete files and folders using Terminal
Take the commands in this article as an example: the rm command allows you to remove (or delete) files. The rmdir command does...
Read more >
Angular 2 - Remove non essential files from QuickStart seed
The first command doesn't work. Looks like xargs on Mac doesn't have -a option. What is the equivalent to the first command on...
Read more >
macos - Kill all non-essential processes - Ask Different
The processes you mention would all be killed by one command: kill -9 -1. That would also log you out and kill all...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found