SunQuest
           UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old October 20th, 2003, 07:21 PM
kitchiekoo kitchiekoo is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 3 kitchiekoo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
removing specific characters on the file

hi. im new with shell scripting, please help me out.

i need to make a script that will scan/parse one file and remove characters/word within that file.

for example, file "abcd" contains this text:

"abcdefghijklmnopqrs lmnopqrsabcdfghijk poiuytrewqabcdmnbvcxz"

i need to delete the string "abcd"and replace it with space , so that the output file looks like this:

" efghijklmnopqrs lmnopqrs fghijk poiuytrewq mnbvcxz"

im using HP-UX. thanks!

Reply With Quote
  #2  
Old October 27th, 2003, 06:07 AM
steve_yeoman steve_yeoman is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 4 steve_yeoman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
you could try this perl statement. It works on Solaris. No promises for HP-UX though:

perl -i -pe "s/abcd/ /g" filename

Reply With Quote
  #3  
Old December 5th, 2003, 04:06 AM
jayakhanna jayakhanna is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Location: India
Posts: 61 jayakhanna User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
cat abcd.txt | sed "s/abcd/ /g" >>junk.txt; mv junk.txt abcd.txt;

if you donot want the file to be changed then you can simply use

cat abcd.txt| sed "s/abcd/ /g" to get the output

Regards
__________________
Regards
JK

Reply With Quote
  #4  
Old December 5th, 2003, 06:01 AM
M.Hirsch M.Hirsch is offline
Contributing User
Dev Shed God 1st Plane (5500 - 5999 posts)
 
Join Date: Oct 2000
Location: Back in the real world.
Posts: 5,969 M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Month 1 Day 22 h 39 m 55 sec
Reputation Power: 184
Quote:
Originally posted by jayakhanna
cat abcd.txt | sed "s/abcd/ /g" >>junk.txt; mv junk.txt abcd.txt;


Use "cat junk.txt > abcd.txt" instead of the "mv" command. This way will not change the file's permissions.

hth,
M.
__________________
--
Manuel Hirsch - Linux, FreeBSD, programming, administration articles, tutorials and more.

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > removing specific characters on the file


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway