LINUX UBUNTU : How to copy line in a file and paste it into a new file?
-
I have a file containing my personal details (.txt). How can I copy ONLY few lines in the file and bring it to a NEW .txt file? KINDLY ASSIST ME, PLEASE AND THANK YOU p/s : Doing all this in terminal
-
Answer:
simple open txt file that contains the details now select the lines which you want to copy then press ctrl+c or right click on selected text and click on copy now minimize the txt file now open new txt file and press ctrl+v or right click paste
Wanie at Yahoo! Answers Visit the source
Other answers
A few lines on the top? Use the head command. A few lines on the bottom? Use the tail command. This example will copy the first 3 lines on the top from file.txt and paste the output into newfile.txt head -n3 file.txt > newfile.txt
AWK is a very powerful tool http://www.ibm.com/developerworks/linux/library/l-awk1/index.html
are you connected with SSH or in the GNOME terminal? either way open two terminal screens, vi the target and source files in each separate screen in the source file if using SSH to connection you can highlight and COPY from Source. in the TARGET go to line in which you want to insert, do a ESC "o' Lower case O to open a new line. then "paste the content" of the clipboard from the source. with ESC p OR if you wish to place a specific line, you can also grep for the line in SOURCE and concat it at the end of target. grep "String" source to see if it pulls the string you want. to append the "String" at the end of the target file simply grep "String" source >> Target I do a lot of preprocessing of files between database on a linux box, there are a lot of ways to play it but a simple edit is using vi. get familiar with it and becomes a very good friend. A lot of NOOBs struggle with it, but it isn't as complicated
Related Q & A:
- How to find inodes within a file?Best solution by cyberciti.biz
- How to delete a particular line from a file?Best solution by Stack Overflow
- How can I programmatically extract a file quickly and efficiently within Android?Best solution by Stack Overflow
- Is there a limit on the size of a new file or a text file?Best solution by Stack Overflow
- How to copy and paste a code on my website?Best solution by eHow old
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.