Arunkumar Arunkumar - 1 year ago 56
Java Question

List of characters which needs to be escaped in a linux shell command

In Linux and other OS, file can contain characters like

etc. in their names.
Whenever I try to use any of these files in my bash command like cat, ls, etc. I am required to escape them like below :

filename abc(10-oct).txt
cat abc(10-oct).txt wont work.

If I precede
characters with
character like

cat abc\(10-oct\).txt

This works

I am trying to automate some of Linux shell commands via Java program.And I am not sure of what all characters I must take care of and escape them.

If someone may point to a resource where I can get an entire list of characters, it would be a great help.

Many Thanks

Answer Source

You can use Single Quote 'filename' which will escape everything needs to be escaped in shell mode

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download