LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 07-07-2008, 02:43 AM   #1
opensource82
LQ Newbie
 
Registered: Aug 2007
Posts: 16

Rep: Reputation: 0
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?
 
Old 07-07-2008, 02:50 AM   #2
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

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

:r filename
 
Old 07-07-2008, 02:56 AM   #3
opensource82
LQ Newbie
 
Registered: Aug 2007
Posts: 16

Original Poster
Rep: Reputation: 0
Could you give me a hint how can I test it in an example? Thanks for your help.
 
Old 07-07-2008, 02:58 AM   #4
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 59
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?
 
Old 07-07-2008, 03:16 AM   #5
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 63
opensource82, please use more descriptive subjects.
 
Old 07-07-2008, 03:27 AM   #6
opensource82
LQ Newbie
 
Registered: Aug 2007
Posts: 16

Original Poster
Rep: Reputation: 0
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 .

Regards,
 
Old 07-07-2008, 03:38 AM   #7
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,407

Rep: Reputation: 1965Reputation: 1965Reputation: 1965Reputation: 1965Reputation: 1965Reputation: 1965Reputation: 1965Reputation: 1965Reputation: 1965Reputation: 1965Reputation: 1965
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??
 
Old 07-07-2008, 03:45 AM   #8
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 59
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.
 
Old 07-07-2008, 03:50 AM   #9
opensource82
LQ Newbie
 
Registered: Aug 2007
Posts: 16

Original Poster
Rep: Reputation: 0
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,
 
Old 07-07-2008, 04:14 AM   #10
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 63
don't delete - this is pure gold!
 
Old 07-07-2008, 04:22 AM   #11
opensource82
LQ Newbie
 
Registered: Aug 2007
Posts: 16

Original Poster
Rep: Reputation: 0
You made my day matthewg42 . Finally a good comment as I felt that I annoyed everybody here .
 
  


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
Basic usage of iptables Nerox Linux - Networking 5 04-30-2007 02:44 PM
Basic Wine Usage MALDATA Linux - Software 8 05-02-2006 06:24 PM
basic question about grep czarherr Programming 1 09-26-2005 02:46 AM
grep usage with regular expression jonathanztaub Linux - General 7 09-01-2004 10:35 PM
Grep Usage specialist01 Linux - General 2 06-13-2003 07:52 AM


All times are GMT -5. The time now is 04:08 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration