textfile editing
Hi all,
i have a little problem handling a textfile looking like this: Word1 eagrtaerg erage rghegegretg #greqrge rgergtegtwretg rthgrethreth regtrwthgrwthrht Word1 rstgwrtgwrhtrwhtrh whgrthgwr #gegtrewtrghwrethg trgwwrthgrthg wretghwrhtwr Word1 rstgwrtgwrhtrwhtrh whgrthgwr #gegtrewtrghwrethg trgwwrthgrthg wretghwrhtwr The Textblocks are all seperated with a blank line how can i get the textblocks sorted alphabeticaly depending on the first word in the first line of a textblock. Sorting the Textblocks is the goal i tried serachiong for some ready to use awk lines but awk is a little too difficult for a beginner like me.... Can u please help me ??? blubbfish |
This smacks of homework :)
Are you saying you want to sort by Word1? That's a silly thing to do if the word is always the same ;} Cheers, Tink |
no Word1 is just the place of the first word word one could be "Marry" in the first Textblock and "Jim" in the next one... I have to order the textblocks seperated by a empty line alphabetically depending on the first wird of the textblock .....:confused:
|
I know AWK fairly well and might be able to help you out... but I don't understrand, where do you get "Marry" and "Jim" from?
|
He just offered them as replacements for the
original "Word1" that he had in each paragraph. Cheers, Tink |
yes that is the point the first word can be any word .... you can take what you want but i have to sort the textparts which could be more then one line and which are seperated by an empty line by the first word in the first line of each textpart :confused:
|
Just gonna throw this in there...
What word processor are you using? |
Word Prozessor ??? :newbie: ???
the textfile i get is some kind of configfile made with command line vi and the sort mechanism is because the file is huge! And in order to get a better overview i shall sort this file by the first word in each textpart |
This would be easier for someone to figure out if you copy and paste part of the file here. Perhaps
Code:
head yourfile > sample In the meantime, I created a file called test and it looks like the following: Code:
gunter@anduin $ cat test Code:
cat test | sed 's/^$/^/' | tr '\n' '|' | tr '^' '\n' | sed 's/^|//' | sed '/^$/d' | sort | tr '|' '\n' |
Thanks Gunter this is exactly what i was looking for ;-) nice idea to first write the textparts in one file and then reconstrukt it after the sort this really was a way i never imagined to work ;-)
You really helped me :D And btw. your example file is very similar to mine ;-) Greetings my Master i'll pray for yeah ... :study: Blubbfish |
All times are GMT -5. The time now is 09:15 AM. |