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 am trying to make simple install script which consist of a bunch of cd.. make.. make install .configure and such also editing some Makefiles in the way. How can I do the editing part. I like to do it in VI as in VI a certain file to change stuff in it or even create new ones with stuff in them.Please remeber that this install script will have to be completley automatic with little manual intervention required if not possible.
Just to make the VI part more clear, I like to be able to go into certain files in VI and modify certain statemtens there to say whatever, also make new files in VI aslo to say what ever.
This need to be done on the fly using a pre-made script off course.
I'm still a bit unclear at what you are trying to do. Could you provide a small example of what type of editing and file creation you want to do with vi in your script.
OK,
Let say I wanted to go from root directory / and create a file in VI called test in /var which will have a test line in it that say "This is a test then save that and go in to in other directory in /etc for example and edit an existing file called "defaults" and modify an entry on the forth line from yes to no.
The way I was thinking to do this is by creating an executable file to read:
"
vi /var/test
then something....something..
vi /etv/defaults
then something...somthing..
# Create a file in /var
cd /
echo "This is a test" > /var/test
# Edit defaults in /etc
cat /etc/defaults | sed '4s/yes/no/' > /etc/defaults
There are a ton of things you can do with sed. I'd suggest you find a good book on it. You should also take a look at awk. It is more difficult to learn than sed, but once you know it, awk can be quite powerfull.
You might also want to look into the other tools that are often piped together to play about with text - awk, cut, tr, grep to name but a few little bits.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.