wangf@unixg.ubc.ca (Frank Wang) (06/11/91)
Is that possible to delete some lines from a file (the file is so large that it's impossible to use any editor) without evoking any editors? Thanx in advance.
les@chinet.chi.il.us (Leslie Mikesell) (06/11/91)
In article <1991Jun11.005723.22179@unixg.ubc.ca> wangf@unixg.ubc.ca (Frank Wang) writes: >Is that possible to delete some lines from a file (the file is so large that >it's impossible to use any editor) without evoking any editors? Sure, if you can describe the portion to delete to sed (the stream editor) using line numbers or unique patterns in the text to identify the portion to delete: sed 'begin,endd' <oldfile >newfile should do it, where begin and end are either line numbers or a pattern enclosed in //'s. Les Mikesell les@chinet.chi.il.us
gary@sci34hub.sci.com (Gary Heston) (06/14/91)
In article <1991Jun11.005723.22179@unixg.ubc.ca> wangf@unixg.ubc.ca (Frank Wang) writes: >Is that possible to delete some lines from a file (the file is so large that >it's impossible to use any editor) without evoking any editors? You can use dd to break the file into two or more parts, using the count and skip options: dd if=toobig of=firstpart count=512 bs=512 will take the first 256K (512 blocks of 512 characters) and put them into a file named firstpart, and: dd if=toobig of=lastpart skip=512 bs=512 creates a file with the rest in it. The original file is untouched, of course. By using combinations of skip and count, you can break the large file into as many pieces of whatever size you need. There will be a little cleanup work needed, since lines in the file probably won't fall on 512-byte boundaries. Nice program, dd. My thanks to whoever in the depths of AT&T wrote it. -- Gary Heston System Mismanager and technoflunky uunet!sci34hub!gary or My opinions, not theirs. SCI Systems, Inc. gary@sci34hub.sci.com I support drug testing. I believe every public official should be given a shot of sodium pentathol and ask "Which laws have you broken this week?".
rayj@camco.Celestial.COM (Ray Jones) (06/20/91)
In <1991Jun14.140007.6242@sci34hub.sci.com> gary@sci34hub.sci.com (Gary Heston) writes: >In article <1991Jun11.005723.22179@unixg.ubc.ca> wangf@unixg.ubc.ca (Frank Wang) writes: >>Is that possible to delete some lines from a file (the file is so large that >>it's impossible to use any editor) without evoking any editors? >You can use dd to break the file into two or more parts, using the count >and skip options: >Nice program, dd. My thanks to whoever in the depths of AT&T wrote it. I agree, dd is a nice program, however, there is a utility program made just for this kind of problem. The program is "split" used to split large files into smaller files. The syntax is: split -n filename where n is the number of lines per smaller file. If n is not specified, the default is 1000 lines. The resultant filenames will have the name appended with .aa .ab ....zz -- Onager Systems Ray A. Jones 18710 NE 59th Ct. UUCP .....uunet!camco!onager!ray # 2053 ...ray@onager.Celestial.COM Redmond, WA 98052 206-885-3568