How to Deal With Dashed File Names Like Open, Remove?

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/deal-dashed-file-names-like-open-remove/
PINTEREST
PINTEREST
INSTAGRAM

Dash (-) have important role in Linux and other operating systems. It is used by commands to specify options and arguments. This popular use case may create problems if we have files those provides dash. Linux commands generally need explicit operations to cope with file names those starts with dash.

Create File Name Starts with Dash

We will start by creating a file which name starts with a dash - . We can use different commands like touch , cat  etc. We will use touch  command which will create an empty file. There is special argument -- double dash which is used with file name starts with dash . We will provide double dash parameter before the file name. In this example we will use file name -datafile .

Create File Name Starts with Dash

Create File Name Starts with Dash

List File Names Starts with Dash

We can also list file names those starts with dash . We will use -- option again in order to use dash in files name. We will use ls  command with -* which specifies the files starts with dash.

List File Names Starts with Dash

List File Names Starts with Dash

Remove File Name Starts with Dash

Now I think this part is the most important part. We generally want to remove file those names starts with dash. But we cant and can error like invalid option  etc.

Remove File Name Starts with Dash

Remove File Name Starts with Dash

We need to specify the double dash in order to remove file name starts with dash. In this example we will remove file named -datafile .

LEARN MORE  Linux Directory and File Operations

Write File Name Starts with Dash

We can write file names start with dash. We will use echo  command and redirect the data into the file. In this example we will write this is some data into file named -datafile .

Write File Name Starts with Dash

Write File Name Starts with Dash

Read File Name Starts with Dash

As we have seen in previous example we can read data from file which starts with a dash. We will use cat  command and provide -- double dash option again like previous examples. We will read the file named -datafile

Read File Name Starts with Dash

Read File Name Starts with Dash

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/deal-dashed-file-names-like-open-remove/
PINTEREST
PINTEREST
INSTAGRAM

You may also like...

Leave a Reply

Your email address will not be published.

Enjoy this blog? Please spread the word :)