Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

MacBook MH

macrumors member
Original poster
Mar 7, 2009
76
0
Hi everyone.
I got a text file with more than 10 000 entries. Down below there is a preview of its contents:

v.hodný [ý]
p.chnúť sa
z.sť (z cesty) [í]
koleg.ňa [y]
p.lulka


there are only 4 possibilities what can be in the [] brackts. What I want to do is to copy the word before the [] brackets to a specific file depending to the contents of the []. So if there is [ý] or [y] after the word (or group of words in the specific line) copy it to document "y.txt". If there is [í] or after the word (or group of words in the specific line) copy it to document "i.txt".

The result should look like:
document i.txt
p.chnúť sa
z.sť (z cesty)
p.lulka

document y.txt
v.hodný
koleg.ňa

is there any program to do this??? or a terminal command??? PLEASE HELP ME!!! IT IS EXTREMELY IMPORTANT!

THANKS IN ADVANCE!
 
A possible way of doing this

Hi everyone.
I got a text file with more than 10 000 entries.

I would import into an Excel Spread sheet or database (Filemaker or 4D for instance) and then filter for the correct entries and export. Doing it this way should take a matter of minutes.
 
Hi everyone.
I got a text file with more than 10 000 entries. Down below there is a preview of its contents:



there are only 4 possibilities what can be in the [] brackts. What I want to do is to copy the word before the [] brackets to a specific file depending to the contents of the []. So if there is [ý] or [y] after the word (or group of words in the specific line) copy it to document "y.txt". If there is [í] or after the word (or group of words in the specific line) copy it to document "i.txt".

The result should look like:
document i.txt


document y.txt


is there any program to do this??? or a terminal command??? PLEASE HELP ME!!! IT IS EXTREMELY IMPORTANT!

THANKS IN ADVANCE!


You could try the following:

1) Make a copy of your file, name it input.txt, and place it in your Home folder.

2) Open Terminal (in Utilities), copy and paste the following line into the Terminal window, and press return:

Code:
cd; cat input.txt | grep -F -e [y -e [ý | cut -d [ -f 1 > y.txt

You should get a file named y.txt containing what you want.

If so, enter the following to get a file named i.txt

Code:
cat input.txt | grep -F -e [i -e [í | cut -d [ -f 1 > i.txt
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.