LinuxQuestions.org
Visit Jeremy's Blog.
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 06-28-2010, 01:45 AM   #1
Aquarius_Girl
Senior Member
 
Registered: Dec 2008
Posts: 4,731
Blog Entries: 29

Rep: Reputation: 931Reputation: 931Reputation: 931Reputation: 931Reputation: 931Reputation: 931Reputation: 931Reputation: 931
Shell script for adding a statement in a file after a particular statement


We are building our C++ project in Kdevelop IDE. Every time we run "Run Configure" from the "Build" menu, a file named "libtool" gets automatically generated.

This file contains a statement as "ECHO="echo"".
If we run "Automake", without modifying the "libtool" the system hangs and the computer needs to be restarted.

Therefore every time we run "Run Configure" we need to include the line "echo="echo"" below the statement "ECHO="echo"" manually.

I think a script can be written which does the above on its own.

I am not a shell script programmer, I know the good tutorials for shell scripts are available on the net, but learning scripting only for this task would be time-consuming and painful.

I shall be great-full if someone helps me with this !

Last edited by Aquarius_Girl; 06-28-2010 at 01:56 AM.
 
Old 06-28-2010, 02:05 AM   #2
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,974

Rep: Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179
Quote:
but learning scripting only for this task would be time-consuming and painful
I find this a curious line to write as you are saying that as of your 1200+ replies you have never had the need to learn sciprting.
As I said ... just a curious thing to say.

Anyhoo:
Code:
sed -i.bak '/ECHO.*/a"echo="echo""' file
 
1 members found this post helpful.
Old 06-28-2010, 02:11 AM   #3
Aquarius_Girl
Senior Member
 
Registered: Dec 2008
Posts: 4,731

Original Poster
Blog Entries: 29

Rep: Reputation: 931Reputation: 931Reputation: 931Reputation: 931Reputation: 931Reputation: 931Reputation: 931Reputation: 931
Quote:
Anyhoo:
Code:
sed -i.bak '/ECHO.*/a"echo="echo""' file
Many thanks to you for writing this. This script must have been a child's play for you.

Can this script be run somehow automatically ? Or every time I need to type this on shell ?

Last edited by Aquarius_Girl; 06-28-2010 at 03:06 AM. Reason: Quote removed
 
Old 06-28-2010, 02:46 AM   #4
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,974

Rep: Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179
Well I am not familiar with kdevelop but I am sure they must have a section to allow scripting. Otherwise you may have to run manually.
 
1 members found this post helpful.
Old 06-28-2010, 03:07 AM   #5
Aquarius_Girl
Senior Member
 
Registered: Dec 2008
Posts: 4,731

Original Poster
Blog Entries: 29

Rep: Reputation: 931Reputation: 931Reputation: 931Reputation: 931Reputation: 931Reputation: 931Reputation: 931Reputation: 931
Thanks, I shall look into kdevelop now.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
If-statement in Shell Script SeraphimNL Linux - Newbie 4 01-11-2010 12:30 AM
if-then statement and wildcard: shell script Cyberman Programming 7 12-27-2009 07:49 AM
for statement in bourne shell script bujecas Linux - General 3 07-17-2006 07:32 AM
How do I use an If statement within a case in a Shell script?? crazygyhrous Programming 7 01-03-2006 06:41 AM
Need help adding an IF / ELSE statement to my Bash Script Relix Linux - General 1 08-01-2002 02:03 PM

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

All times are GMT -5. The time now is 01:02 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