LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Parsing with Vim (https://www.linuxquestions.org/questions/linux-general-1/parsing-with-vim-194963/)

mijohnst 06-18-2004 08:52 AM

Parsing with Vim
 
I have a 50 meg text file that I'm going to have to fish through to find certain lines and I was wondering if it's possible to parse it with vi so that I don't have to look through ever line. It would be nice if vi would find the lines and them copy them to another file or just group them all together. Is this something even possible with vi?

Here is a simple example:

# textfile1.txt
granted
granted
granted
granted
granted
denied (I want this line moved to to textfile2.txt)
granted

# textfile2.txt
denied

If this isn't possible with Vim, I'd sure like some suggestions. Thanks!

miss crump 06-18-2004 09:25 AM

You could use grep to search the first file and then output the results to a second file. It would look something like this, depending on what you wanted to do:

grep "searchpattern" file1 > file2

mijohnst 06-18-2004 09:38 AM

miss crump, that's exactly what I'm looking for... Thank you so much... :)


All times are GMT -5. The time now is 01:02 PM.