1833776 Members
2003 Online
110063 Solutions
New Discussion

strange thing

 
SOLVED
Go to solution
suryanarayana_1
Occasional Advisor

strange thing


Hello everybody,

Today I have copied file from windows system to my HP-UX server.But I couldn't delete or move that file.See below the file name.
ssa(12-12-12).txt

If I try to delete or move that file the following error is giving.

sh: Syntax error: `(' is not expected.
Thanking you,
Surya.
9 REPLIES 9
Mark Grant
Honored Contributor

Re: strange thing

try the following

rm ' ssa(12-12-12).txt'

or

rm ssa\(12-12-12\).txt

Hope this helps
Never preceed any demonstration with anything more predictive than "watch this"
Mark Grant
Honored Contributor
Solution

Re: strange thing

Sorry, an extra space got into that first example, it should read

rm 'ssa(12-12-12).txt'

Never preceed any demonstration with anything more predictive than "watch this"
T G Manikandan
Honored Contributor

Re: strange thing

#rm ssa\(12-12-12\).txt
suryanarayana_1
Occasional Advisor

Re: strange thing


Thanks for your instant response.I able to delete that file by using wildcards.I used rm ssa*.txt.
Mark Grant
Honored Contributor

Re: strange thing

Sorry to spam this post but I think perhaps an explanation is required :)

The "(" character has special meaning to the hp-ux shells and it is being interpreted as such when you type the normal "rm" command.

THe solutions above show methods of stopping the special meaning of characters being used when you type something in. The "\" before a special character "turns off" the special meaning. Also, any characters between two ' marks will also not have thei special characters interpreted. Example special characters are * ? [ { \ & > < and loads more too I should think.
Never preceed any demonstration with anything more predictive than "watch this"
Mark Grant
Honored Contributor

Re: strange thing

No, you will not be able to delete it with wildcards as such.

You might be able to delete several of them with

rm -i *

THis will go through all the files in the directory and ask you to confirm you want them deleted. If you type "y", it deletes them
Never preceed any demonstration with anything more predictive than "watch this"
Balakumar M
Frequent Advisor

Re: strange thing

Try this,

rm 'ssa(12-12-12).txt'

or rm ssa\(12-12-12\).txt

Ref this link, It will give you clear idea.

http://www.helpdesk.umd.edu/topics/troubleshooting/os/unix/1231/

Regards,
Bala
Life is a continues learning process
Elmar P. Kolkman
Honored Contributor

Re: strange thing

Your problem is caused by the shell special characters ( and ). They can be used in filenames, but give problems like this. Spaces and a leading '-' (dash) are other examples of those characters give these problems.

Using the quotes (in this case they can be single and double) solves the problem in this case and with the spaces. The leading dash needs another solution (using '--' (two dashes) as first argument for rm can solve that issue.
Every problem has at least one solution. Only some solutions are harder to find.
Steve Post
Trusted Contributor

Re: strange thing

you could have all sorts of filenames that are goofy. You could have a backspace "^H" as a filename. But the inode for the filename would exist.

ls -i *
126 ^H
find . -inum 126 -exec ls -l {} \;
To "see" you grabbed the correct file.

find . -inum -exec mv {} goofyfile \;