Skip to main content

Thread: Syntax error when deleting a dir ?!?


i trying delete dir (with cli), contains many sub dirs , files:

hello - de important files stuff (0000-0001)

using command:
php code:
sudo rm -rf hello\ -\ deimportantfilesstuff\ (0000-0001)/ 
but keep getting error:
php code:
-shsyntax error"(" unexpected 
obviously noob linux.. doing wrong?

\ between spaces in file name isn't showing in php code?!?

it's complaining because ( special character in bash, needs escaped. easy route double-tab autocomplete assuming there 1 directory named "hello...", or easier rm hello* again assuming 1 directory. alternative escape argument (or quote it). i.e.

sudo rm -rf 'hello - de important files stuff (0000-0001)'
sudo rm -rf hello\ -\ de\ important\ files\ stuff\ \(0000-0001\)

in second have escaped spaces let bash know it's space , not separating arguments (otherwise run rm on "hello", "-", "de", "important"... not want. have escaped ( , ) because otherwise shell interpret them special characters.


Forum The Ubuntu Forum Community Ubuntu Official Flavours Support General Help [ubuntu] Syntax error when deleting a dir ?!?


Ubuntu

Comments