The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
mbox ascii mail text file ? DILEEP410 Shell Programming and Scripting 3 05-20-2008 10:14 AM
Replacing text chrchcol Shell Programming and Scripting 3 07-25-2006 12:30 PM
replacing text ajaya Shell Programming and Scripting 2 04-12-2006 12:31 PM
Creating flat text file (ASCII) Wdonero UNIX for Dummies Questions & Answers 5 04-20-2005 05:33 AM
convert hex to ascii text dangral UNIX for Dummies Questions & Answers 5 04-16-2003 12:27 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-28-2005
cubs0729 cubs0729 is offline
Registered User
  
 

Join Date: Jul 2005
Posts: 31
replacing text in an ascii doc

What would be the best way to replace all instances of...

09/26/2005
with
20050926

There are no spaces between the the date and the preceeding and following data. example lines looks like...

snp01|NAME/OF/A/GROUP|09/26/2005081343|502

the 081343 is the time without colons.

Thank you.
  #2 (permalink)  
Old 09-28-2005
futurelet futurelet is offline
Registered User
  
 

Join Date: Jul 2005
Posts: 137
Code:
ruby -pe'sub(%r!(\d\d)/(\d\d)/(\d{4})!,"\\3\\1\\2")'
  #3 (permalink)  
Old 09-28-2005
cubs0729 cubs0729 is offline
Registered User
  
 

Join Date: Jul 2005
Posts: 31
????

Could you explain that more...

I'm using the korn shell. How would I use ruby inside a korn script.
  #4 (permalink)  
Old 09-28-2005
cubs0729 cubs0729 is offline
Registered User
  
 

Join Date: Jul 2005
Posts: 31
the sed command

I tried using the sed command, but it's doesn't do anything...

sed -e 's/$date/$newDate/g' $ofile > test.txt
  #5 (permalink)  
Old 09-28-2005
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,119
Quote:
I tried using the sed command, but it's doesn't do anything...

sed -e 's/$date/$newDate/g' $ofile > test.txt
Code:
sed -e "s#$date#$newDate#g" $ofile > test.txt
  #6 (permalink)  
Old 09-28-2005
cubs0729 cubs0729 is offline
Registered User
  
 

Join Date: Jul 2005
Posts: 31
...

that sed command is not working for me...

I was going to try using this to do it, but it won't pass the variable to it...

/bin/echo '%s/^/"$newDate "/g\nwq!' | ex - $ofile
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 05:24 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0