Friday, 28 May 2010

Removing files with hyphenated filenames in Linux

I was trying to remove a strangely named directory under my WebSphere Application Server Deployment Manager's wstemp directory: -

/opt/IBM/WebSphere/AppServer/profiles/Dmgr01/wstemp

as follows: -

cd /opt/IBM/WebSphere/AppServer/profiles/Dmgr01/wstemp
rm -Rf -6895560/

which resulted in: -

rm: invalid option -- 6
Try `rm --help' for more information.

I'd had the same problem a few days ago - the problem is that the hyphen ( - ) character is seen by the rm command as an option.

The solution ? A quick rummage around Google threw this up: -


Use the "--" option to tell rm that there are no more options coming, hence the command becomes: -

rm -Rf -- -6895560/

Job done :-)

1 comment:

Yevgen Ovchynnikov said...

You can do this by
rm -rf ./*

:)

Reminder - installing podman and skopeo on Ubuntu 22.04

This follows on from: - Lest I forget - how to install pip on Ubuntu I had reason to install podman  and skopeo  on an Ubuntu box: - lsb_rel...