LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-08-2010, 01:27 AM   #1
Mirge
LQ Newbie
 
Registered: Mar 2010
Posts: 4

Rep: Reputation: 0
Shell script deleting oracle backup?


First of all, hi to all!

My problem is..



I setup linux script to delete my backups older than few days:
RBRDAN=`date –date=”3 days ago” +%w`

rm /u02/oracle/backup/rman/$RBRDAN/*

But, I got error:
rm: cannot remove `/u02/oracle/backup/rman/6\r/*’: No such file or directory

For some reason, it gives me “\r” at the end of the day. Instead of “6″, it gives me “6\r”.
Does anybody know what is the problem?

p.s. Backup files are on storage and scriipt is running on the database server..

Thanks.
 
Old 03-08-2010, 01:41 AM   #2
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Was the script created in Windows? AFAIK \r represents a carriage return. If the file was created in Windows the line would end in carriage return and line feed. Linux uses only line feed for end of line so the carriage return is part of the line in the script.

If so you can use the fromdos command to remove the carriage return or you should be able to hide the unwanted carriage return in a comment:
Code:
RBRDAN=`date –date=”3 days ago” +%w` # A comment to hide this guy ==>
 
Old 03-10-2010, 01:21 PM   #3
Mirge
LQ Newbie
 
Registered: Mar 2010
Posts: 4

Original Poster
Rep: Reputation: 0
Thank you catkin. It solves my problem. Once more thank you..
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple Shell Script? Deleting Duplicate Files... Tag234 Linux - Newbie 6 10-10-2009 04:49 AM
Not able to execute Oracle Sql command in shell script Ranvijaidba Programming 3 10-23-2008 03:45 PM
Shell script to load data to oracle database divyahm Linux - Newbie 2 11-08-2007 09:15 AM
Need a script for daily backup of oracle archive file sathyguy Linux - Newbie 15 01-22-2007 06:49 AM
update oracle table using shell script ann124 Programming 1 12-06-2004 02:42 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:32 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration