On Jan 31, 2007, at 12:31 PM, Google Kreme wrote:


On 30-Jan-2007, at 17:28, Nicklas Persson wrote:
What I would like to do is split the one long file into 97 separate files,
preferably named by the student name. Can this be done in BBEdit?

I have a feeling this is why I should have learned Perl.

Now now, no reason to go to extremes.

From a worksheet

split -p ':::' <filename> split_filename_

this will yield a bunch of files with names like

split_filename_aa
split_filename_ab
split_filename_ac
split_filename_ad
split_filename_ae
etc..

I'm a fan of terminal much as the next person, but I've never found split or csplit to function as expected in Tiger. The above command doesn't function as expected. Well, actually, I don't know what the -p parameter does -- never heard of it before, but a quick man indicates split only supports byte count, line count and suffix length. Csplit should do the trick, but it doesn't work quite as expected, either.

Say you have a text file called sapmmyIP with a dozen items delimited by returns:

58.8.0.0-58.8.255.255 ; ADSL HuaweiBB Truehisp TH
58.18.0.0-58.18.255.255 ; CNCGROUP Neimeng Province CN
558.224.0.0-58.239.255.255 ; Hananet KR
59.0.0.0-59.31.255.255 ; kornet KR
59.144.34.0-59.144.34.255 ; Bharti infotel Ltd IN
59.188.0.0-59.188.255.255 ; New World Telecom HK
60.220.0.0-60.223.255.255 ; CNCGROUP Shanxi CN
61.0.0.0-61.1.255.255 ; BSNLNET IN
61.16.198.192-61.16.198.255 ; HOTWIRE IN
61.32.0.0-61.43.255.255 ; DACOM BORANET KR
222.32.0.0-222.63.255.255 ; CHINA RAILWAY TELECOMM CN
222.76.0.0-222.84.255.255 ; CHINANET fujian Xinjiang Guangxi province CN

one would think using csplit -k -f ickyIP_ sapmmyIP '/\r/' should split these at the line breaks, but it only works once. I may have parameters and arguments mucked up -- someone please point it out if so.


I do think using

split -l 1 -a 2 sapmmyIP ickyIP_

should create 12 files split at the line breaks to create

ickyIP_aa
ickyIP_ab
ickyIP_ac
...

how one would run this within BBEdit is beyond me. Terminal is your friend?

vail

--
------------------------------------------------------------------
Have a feature request? Not sure the software's working correctly?
If so, please send mail to <[EMAIL PROTECTED]>, not to the list.
List FAQ: <http://www.barebones.com/support/lists/bbedit_talk.shtml>
List archives: <http://www.listsearch.com/BBEditTalk.lasso>
To unsubscribe, send mail to:  <[EMAIL PROTECTED]>

Reply via email to