LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 08-04-2009, 01:47 PM   #1
SmearedBlackInk
LQ Newbie
 
Registered: Oct 2006
Location: Garden Grove, CA
Distribution: Slackware
Posts: 9

Rep: Reputation: 0
Need bash script help


I'm trying to find a way to parse a file for a string encapsulated in brackets like:

<start> RANDOM STRING </start>

and then have the script write a new file that has the each string on a new line.

Any help would be greatly appreciated.

Thank you,

~SBI
 
Old 08-04-2009, 01:58 PM   #2
MBybee
Member
 
Registered: Jan 2009
Location: wherever I can make a living
Distribution: OpenBSD / Debian / Ubuntu / Win7 / OpenVMS
Posts: 440

Rep: Reputation: 57
I think sed is probably what you want to use - that or Perl
Sed docs: http://www.gnu.org/software/sed/manual/sed.html
Since you specified bash scripting, that is probably the easiest.
Here's a thread with a nice example: http://www.unix.com/shell-programmin...same-file.html

You would just recast that example specified to use your RANDOM STRING.
The basic concept is sed -i.suffix 's/(regexp to find your string)/(new value)/g' filename
 
Old 08-04-2009, 02:05 PM   #3
SmearedBlackInk
LQ Newbie
 
Registered: Oct 2006
Location: Garden Grove, CA
Distribution: Slackware
Posts: 9

Original Poster
Rep: Reputation: 0
Thank you very much!
 
  


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
passing variable from bash to perl in a bash script quadmore Programming 6 02-21-2011 04:11 AM
[SOLVED] Using a long Bash command including single quotes and pipes in a Bash script antcore Linux - General 9 07-22-2009 11:10 AM
[SOLVED] bash : getopts problem in bash script. angel115 Programming 2 03-02-2009 10:53 AM
Strange if statement behaviour when using bash/bash script freeindy Programming 7 08-04-2008 06:00 AM
Bash script to create bash script jag7720 Programming 10 09-10-2007 07:01 PM

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

All times are GMT -5. The time now is 06:39 PM.

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