![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Need help in splitting the file | Vaddadi | Shell Programming and Scripting | 3 | 05-23-2008 10:44 AM |
| how to selectively mount FS? | wrapster | Shell Programming and Scripting | 0 | 04-28-2008 10:44 AM |
| shell script to selectively tar directory based on date | fara_aris | Shell Programming and Scripting | 2 | 03-16-2008 07:35 PM |
| file splitting | UBD | Shell Programming and Scripting | 7 | 01-17-2008 03:24 PM |
| [Splitting file] Extracting group of segments from one file to others | ozgurgul | Shell Programming and Scripting | 1 | 09-14-2006 01:17 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Selectively splitting a file with C-shell?
I have a rather long csh script that works, but it's terribly ungraceful and takes a while from various loops. I only know enough code to get myself into trouble, so I'm looking for some guidance.
I have a large file that is separated at intervals by the same line, like this: @<TRIPOS>molecule name_000 blah yadda stuff @<TRIPOS>molecule name_001 blah2 yadda2 stuff2 @<TRIPOS>molecule name_002 blah3 ... and so on for up to name_200, where blah/yadda/stuff are strings with numbers, letters, and white spaces. I need to split this file into individual files, named name_000.mol2, name_001.mol2, name_002.mol2 etc, each of which contain: @<TRIPOS>molecule name_000 (or name_whatever) blah yadda stuff Currently I grep -n 'TRIPOS>molecule' the big file into another file, then use the line numbers to cycle through and pull out lines x through y, naming each file based on what's in line x+1 (name_000), with .mol2 on the end. This takes an incredibly long time, and is rather clunky. I don't know if it's the file cycling or all the variables I pass back and forth that eats up the time, but if anyone knows of an easier way to split the big file up, I would greatly appreciative! I can't come up with a good way to do this in awk - the line numbers between each TRIPOS>molecule are variable, and my awk-fu is rather weak. I also need to keep this in CSH or I'll have to convert a ton of other code. Any ideas? Thanks! |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|