ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I need a way to read and delete text found before a unique string, then delete the string. I would like to have the text stored in a variable--or better yet--executed it as a shell script directly.
I intend to execute the stored text in bash. It does not matter much what language the program is it, however efficiency is desirable. This script is not going to be used on large files, but it may be executed many times sequentially so the faster the script works the better.
Thanks
Here is an example:
exclamation-"It worked!"
echo $exclamation
cd
end of script
blah blah
blah blah blah
blah blah blah
I would like to execute everything before "end of script" as if it were a shell script
I need a way to read and delete text found before a unique string, then delete the string. I would like to have the text stored in a variable--or better yet--executed it as a shell script directly.
I intend to execute the stored text in bash. It does not matter much what language the program is it, however efficiency is desirable. This script is not going to be used on large files, but it may be executed many times sequentially so the faster the script works the better.
Thanks
Here is an example:
exclamation-"It worked!"
echo $exclamation
cd
end of script
; this is yet another indication that input data is poorly organized - the piece to be executed should have been in a separate file in the first place.
Last edited by Sergei Steshenko; 08-25-2010 at 10:42 AM.
This is actually not part of data extracting. See, the other part of the program is to make input files. I have a method where I make a template that is very similar to the input file for the actual program, except certain numbers replaced with parameters. I have the script fill in parameters (e.g. $1, $2 ...) and create the input file.
However, different programs have different syntax for execution. I would like to have both the template for the input and the script to execute it and parse the output all in one file--for easy use. So if I made the script to execute the input and parse the output the first part of the file, then separate it by some string that is not a command for any widely used language. Then I just have the template part of the file follow.
I cannot help that the output of quantum chemistry packages is poorly organized. My task is to graph the potential energy of water as a function of bond length. I have some good tools that can get me pretty far, and I am not about to rewrite Hartree-Fock algorithms when I can parse text.
I need a way to read and delete text found before a unique string, then delete the string. I would like to have the text stored in a variable--or better yet--executed it as a shell script directly.
seriously, give a better example next time. Show what your desired output is.
Code:
$ more file
blah blah junk
blah blah myunique string
this is the end
$ awk '/myunique/{gsub(/.*myunique/,"");f=1}f' file
string
this is the end
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.