JLN
JLN

Reputation: 23

rm -r in shell script (my first *.sh)

I would like to delete some folder on an Ubuntu 8.04 Server.

I would like to start a script to delete this folder.

I start an ssh session to the server.

My script looks like this:

#!/bin/bash
rm -r /var/lib/backuppc/pc/PC1/
rm -r /var/lib/backuppc/pc/PC2/

I run the script like this:

sh scriptname.sh

But I get this message:

rm: cannot remove `/var/lib/backuppc/pc/PC1/\r': No such file or directory
rm: cannot remove `/var/lib/backuppc/pc/PC1/\r': No such file or directory

I'm sorry but I don't use ever a shell script on linux. I think it my fault because I don't know the basics :-(

Can somebody help me? I've to delete ~80 folder... :-(

Upvotes: 2

Views: 25728

Answers (1)

TomCho
TomCho

Reputation: 3507

It looks like there is some "junk" characters after your folder name (namely, \r). To be sure, type cat -A scriptname.sh and check if you can see some weird characters in the end of the lines. If so, I think the easiest thing for you (since you have few lines) is to manually delete the ending of those lines and re-type again. (I'm talking about the last two or three characters only) Type cat -A scriptname.sh and see if the characters disappeared. If so, you should be good to go with your code.

Upvotes: 5

Related Questions