- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: copying file content to memory
Operating System - Linux
1753547
Members
5698
Online
108795
Solutions
Forums
Categories
Company
Local Language
юдл
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
юдл
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-17-2010 04:26 PM
тАО12-17-2010 04:26 PM
copying file content to memory
Hi there
How can I copy a text-file content to the memory without editing the file ?
For example there is 12000 lines of text in file "A" and I want to copy and paste all of it to file "B" between line 1 and 3 ?
Is there any way of doing that without manually copying all the 12000 lines ?
How can I copy a text-file content to the memory without editing the file ?
For example there is 12000 lines of text in file "A" and I want to copy and paste all of it to file "B" between line 1 and 3 ?
Is there any way of doing that without manually copying all the 12000 lines ?
Jesus is the King
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-17-2010 07:54 PM
тАО12-17-2010 07:54 PM
Re: copying file content to memory
> How can I copy a text-file content to the
> memory without editing the file ?
By "to the memory", do you mean "to another
file"?
> [...] between line 1 and 3 ?
What did you want to do with line 2, which is
currently between lines 1 and 3?
> Is there any way of doing that [...]
Depending on exactly what "that" is, there
are probably several ways. Here's a crude
way of doing something:
man cat
man sed
M=2
N=3
( sed -n -e "1,${M}p" A ; cat B ; sed -n -e "${N},\$p" A )
For example:
alp$ cat A
File A line 1.
File A line 2.
File A line 3.
File A line 4.
alp$ cat B
File B line 1.
File B line 2.
File B line 3.
File B line 4.
alp$ sed -n -e "1,${M}p" A
File A line 1.
File A line 2.
alp$ sed -n -e "${N},\$p" A
File A line 3.
File A line 4.
alp$ ( sed -n -e "1,${M}p" A ; cat B ; sed -n -e "${N},\$p" A )
File A line 1.
File A line 2.
File B line 1.
File B line 2.
File B line 3.
File B line 4.
File A line 3.
File A line 4.
> memory without editing the file ?
By "to the memory", do you mean "to another
file"?
> [...] between line 1 and 3 ?
What did you want to do with line 2, which is
currently between lines 1 and 3?
> Is there any way of doing that [...]
Depending on exactly what "that" is, there
are probably several ways. Here's a crude
way of doing something:
man cat
man sed
M=2
N=3
( sed -n -e "1,${M}p" A ; cat B ; sed -n -e "${N},\$p" A )
For example:
alp$ cat A
File A line 1.
File A line 2.
File A line 3.
File A line 4.
alp$ cat B
File B line 1.
File B line 2.
File B line 3.
File B line 4.
alp$ sed -n -e "1,${M}p" A
File A line 1.
File A line 2.
alp$ sed -n -e "${N},\$p" A
File A line 3.
File A line 4.
alp$ ( sed -n -e "1,${M}p" A ; cat B ; sed -n -e "${N},\$p" A )
File A line 1.
File A line 2.
File B line 1.
File B line 2.
File B line 3.
File B line 4.
File A line 3.
File A line 4.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-20-2010 11:55 PM
тАО12-20-2010 11:55 PM
Re: copying file content to memory
what about just using plain old head/tail commands?
head -2 file_a | tail -n 1 >> file_b
head -2 file_a | tail -n 1 >> file_b
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-21-2010 05:04 AM
тАО12-21-2010 05:04 AM
Re: copying file content to memory
> what about just using plain old head/tail
> commands?
Did you try your suggestion before posting
it? How well did it work for you?
Plain old "head" and "tail" commands can
extract parts of one file, but it may not be
immediately clear how you assemble the
pieces. (Even if you do get the right
pieces.)
And, of course, I seem to have reversed the
roles of "A" and "B" in my example, if I
understand the original question (which I
don't claim to do).
> commands?
Did you try your suggestion before posting
it? How well did it work for you?
Plain old "head" and "tail" commands can
extract parts of one file, but it may not be
immediately clear how you assemble the
pieces. (Even if you do get the right
pieces.)
And, of course, I seem to have reversed the
roles of "A" and "B" in my example, if I
understand the original question (which I
don't claim to do).
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP