The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
CLI Magic: Using GNOMEvfs to manipulate files iBot UNIX and Linux RSS News 0 04-08-2008 01:50 AM
Manipulate files tonet Shell Programming and Scripting 0 09-26-2007 01:04 AM
Treating bzip2 files as text files ShawnMilo Shell Programming and Scripting 1 06-15-2007 10:16 AM
text files, ASCII files, binary files and ftp transfers Perderabo Answers to Frequently Asked Questions 0 04-08-2004 01:25 PM
grep multiple text files in folder into 1 text file? coppertone UNIX for Dummies Questions & Answers 7 08-23-2002 11:50 AM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 4 Weeks Ago
Registered User
 

Join Date: Aug 2008
Posts: 3
using sed to manipulate text in files

Hi, I have a slight problem in trying to manipulate the text within a file using the "sed" command in that the text i need changed has "/" slashes in.
I have a .sh script that scans the "/db/sybbackup/" directories for any .dmp file older than 2 days and then to >> the information to a file called "removeold.txt". Essencially the text in the file is shown in below in blue.
/db/sybbackup/databases/ENT_IO_20080101.dmp
I have tried the following using the sed command
1. sed 's/{/db/sybbackup}/{rm /db/sybbackup}/' removeold.txt >> rmscript.sh
2. PATH="/db/sybbackup/"
REPPATH="rm /db/sybbackup"
sed 's/${PATH}/${REPPATH}/' removeold.txt >> rmscript.sh
I am hoping to get the following end result using "sed" and not to use "nawk". mind you, i have only been working on Solaris now for a week and am still waiting for my training
rm /db/sybbackup/databases/ENT_IO_20080101.dmp
Can anyone please point me in the right direction to get past the "/" problem in "sed"
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 4 Weeks Ago
Registered User
 

Join Date: Aug 2008
Posts: 3
Ok, sorted it out, I just replaced the "/" with a "!"

sed 's/{/db/sybbackup/}{rm /db/sybbackup}/' removeold.txt >> rmscript
sed 's!/db/sybbackup!rm /db/sybbackup!' removeold.txt >> rmscript

Suppose i just needed to talk myself thru this :-)
Reply With Quote
  #3 (permalink)  
Old 4 Weeks Ago
drl's Avatar
drl drl is offline
Registered User
 

Join Date: Apr 2007
Location: Saint Paul, MN USA / BSD, CentOS, Debian, OS X, Solaris
Posts: 497
Hi.
Quote:
Originally Posted by Jefferson333
Suppose i just needed to talk myself thru this :-)
Yes, that often works. Some alternatives:
Quote:
So when you're really stuck, when you've looked at the problem in every way you can, when every tool in your toolbox has failed you, take time off to think. Go ride a bike. Take the afternoon off and come back in the evening to give yourself a new perspective. Explain the problem to a friend, a manager, a dog, or the wall. The external challenge to your assumptions is often the catalyst that breaks the barrier down.

-- excerpt from Embedded.com - The ten secrets of embedded debugging
I like the one about the dog. Thanks for posting the solution -- it may help someone else ... cheers, drl
Reply With Quote
  #4 (permalink)  
Old 4 Weeks Ago
Registered User
 

Join Date: Aug 2008
Posts: 3
Quote:
I like the one about the dog. Thanks for posting the solution -- it may help someone else ... cheers, drl
Reply With Quote
Google UNIX.COM
Reply

Tags
debug, problem-solving

Thread Tools
Display Modes




All times are GMT -7. The time now is 07:20 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0