LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   Bash command to 'cut' text into another text file & modifying text. (http://www.linuxquestions.org/questions/programming-9/bash-command-to-cut-text-into-another-text-file-and-modifying-text-908539/)

velgasius 10-17-2011 04:36 AM

Bash command to 'cut' text into another text file & modifying text.
 
I have a text file named fruitsIlike.txt containing these lines:

I like Apples
I like Oranges
I like Grapes
I like Kiwis
I like Pie

What I want to do is to cut 1 or 2 lines and move it to another text file named movedhere.txt

and how do I modify say..."I like Kiwis" to "I don't like Kiwis"??
I was thinking the theory might be moving all lines before "I like Kiwis" and after it to 2 separate files, then deleting "I like Kiwis" and moving back the 1st batch of text to that file, echoing "I don't like Kiwis" and then moving back the 2nd batch of text.

or is there an easy way?lol

grail 10-17-2011 05:11 AM

Investigate tools like sed or awk or alternatively use a bash script to read through file and output as necessary.

velgasius 10-17-2011 05:17 AM

well the problem is I rly dont understand anything other than the basics, I googled sed and awk and it seems too complicated to me, mind explaining it in a noob languange?>_< along with the codes if possible

grail 10-17-2011 05:44 AM

Example of delete can be found here using sed

If you look further through the whole page you should find solutions to each part of your question.

velgasius 10-17-2011 05:55 AM

wow thanks!that looks like an ocean of info lol xD


All times are GMT -5. The time now is 03:23 PM.