• Home
  • LLMs
  • Docker
  • Kubernetes
  • Java
  • All
  • About
Linux-Ubuntu | List and delete a file or a directory with a name starting with dash (-) characters
  • Using the command echo:
    $ echo "" > --file1

  • Using the command touch:
    $ touch --file2
    touch: unrecognized option '--file2'
    Try 'touch --help' for more information.

    Solutions:
    $ touch ./--file2
    $ touch -- --file3

  • Using the command ls:
    $ ls --file1
    ls: unrecognized option '--file1'
    Try 'ls --help' for more information.

    Solutions:
    $ ls ./--file1
    ./--file1
    $ ls -- --file1
    --file1

  • Using the command rm:
    $ rm --file1
    rm: unrecognized option '--file1'
    Try 'rm ./--file1' to remove the file '--file1'.
    Try 'rm --help' for more information.

    Solutions:
    $ rm ./--file1
    $ rm -- --file2
© 2025  mtitek