LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   basic vi / grep usage (http://www.linuxquestions.org/questions/linux-newbie-8/basic-vi-grep-usage-654020/)

opensource82 07-07-2008 02:43 AM

basic vi / grep usage
 
Hi,
I want to know how can i read data in a file from another file using the vi. For example if i have file called fileone that contain the data:


Numbers:
1
2
3
4
5

the end.


I want to create another file that contain all the numbers for example filetwo as below:

1
2
3
4
5


So the final result for fileone will be
Numbers:
filetwo

the end.


I want to do that so if i want to add more numbers I will use filetwo instead of editing the main file.

Any suggestions?

Mr. C. 07-07-2008 02:50 AM

To read data into a file, move your cursor to where you want the data.

:r filename

opensource82 07-07-2008 02:56 AM

Could you give me a hint how can I test it in an example? Thanks for your help.

Mr. C. 07-07-2008 02:58 AM

I'm confused. You asked how to do something. I gave you the answer. Have you tried it yourself yet? Is there something that is confusing about my solution?

matthewg42 07-07-2008 03:16 AM

opensource82, please use more descriptive subjects.

opensource82 07-07-2008 03:27 AM

I am sorry that i confused. I will clarify more. I made a script to test this command. The script as below

echo Numbers:
r: filetwo

echo the end.


I run this script and it gave me the following :
Numbers:
./fileone.sh: line 2: r:: command not found
the end.

So what I need now is to test the result to see if it will work fine in my operational servers or not. Hope that I didn't confuse you anymore :D.

Regards,

acid_kewpie 07-07-2008 03:38 AM

I've changed the title to something hopefully more useful, and moved it to the Newbie forum as this doesn't *appear* to be anything about programming. But you're writing impressively confusing and vague posts... what does vi have to do with anything if you're using a shell script??

Mr. C. 07-07-2008 03:45 AM

You said:
"I want to know how can i read data in a file from another file using the vi."

I do not see any vi command above.

I think I am not the one confused. Think about what you are trying to do, and then come back with some clear ideas.

opensource82 07-07-2008 03:50 AM

Dear All,
I am sorry for that confusion. Actually i discovered that I was confused and put a fake solution for my problem.
Thanks Mr. C. for your answer. Please acid_kewpie you may delete this thread if you want.

Regards,

matthewg42 07-07-2008 04:14 AM

don't delete - this is pure gold!

opensource82 07-07-2008 04:22 AM

You made my day matthewg42 :D. Finally a good comment as I felt that I annoyed everybody here :).


All times are GMT -5. The time now is 01:40 AM.