# Dashed filename in Linux

**URL:** <https://linux-tips.com/t/dashed-filename-in-linux/188>\
**Category:** Shell\
**Created:** [June 29, 2008, 11:54am UTC](https://linux-tips.com/t/dashed-filename-in-linux/188 "2008-06-29T11:54:19Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![demirten](https://linux-tips.com/user_avatar/linux-tips.com/demirten/32/64_2.png) [@demirten](https://linux-tips.com/u/demirten)\
**Post date:** [June 29, 2008, 11:54am UTC](https://linux-tips.com/t/dashed-filename-in-linux/188/1 "2008-06-29T11:54:19Z")

</div>

Working with dashed filename in Linux requires some attention.

Dash (-) character at the end of the commands is a popular convention to refer _stdin_ or _stdout_. Dash is not a special character for filesystem or kernel.

But, if you accidently create a file which begins with a dash (-) character, you’ll be realize that you can’t simply delete this file with regular `rm` command:

```
rm -f -testfile
rm: invalid option -- t

```

Because of the first character is a dash, shell thinks we want to provide an option to rm command itself. To solve this problem you have to use double dash character `--` after our command’s options are finished:

```
rm -f -- -testfile

```

When `--` character seen, shell thinks that optional arguments for command itself finished and doesn’t make option parsing anymore.

Another solution for this problem, using `./` convention to refer filenames. For example you can repeat above example:

```
rm -f ./-testfile

```

This solution also works because command line option parsing ends when a `./` pattern received.

For the **stdin** and **stdout** effect, we can use _/dev/stdin_ and _/dev/stdout_ files. They are just symlinks to _/proc/self/fd/0_ and _/proc/self/fd/1_ so you can use like this:

```
echo test /dev/stdout
cat < /dev/stdin
```
