Menu Close

rm: invalid option — ‘J’

There is a file on my Ubuntu file system named -J and I cannot remove it via command line.

A quick rmcommand gave me this error

rm: invalid option -- 'J'

This is because symbol - is used for defining options such as rm -r or rm -f. Running command rm -J will literally execute rmcomamnd with option -J.

The Fixes

There is 3 fixes available for you to try.

1. Append ./ at the front of the file name

$ rm ./-J

2. add -- after rm

$ rm -- -J

3. Use graphical interface. Access your Linux via Desktop and delete it from there by hitting DEL button or right-click and delete the file.

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x