Tag Info

New answers tagged

2

If you partition the drive /dev/sda you will get as result two partitions, not drives /dev/sda1 and /dev/sda2 To partition it now you will need a lot of details. Will be better to back your data and start with new installation. And in the process of install select manual disk partitioning and split the disk


2

You can easily partition it into /dev/sda1 and /dev/sda2 with fdisk, parted, gparted, or another partitioning tool (if you're working from a live CD) or via Anaconda (if you're in the Anaconda installer).


1

This is a job for csplit: csplit -s input_file 1001 will silently split input_file, the first piece xx00 - up to but not including line 1001 and the second piece xx01 - the remaining lines. You can play with the options if you need different output file names e.g. using -f and specifying a prefix: csplit -sf piece. input_file 1001 produces two files ...


1

An easy hack is to print either to STDOUT or STDERR, depending on whether the target pattern has been matched. You can then use the shell's redirection operators to redirect the output accordingly. For example, in Perl, assuming the input file is called f and the two output files f1 and f2: Discarding the line that matches the split pattern: perl -ne ...


5

This is a job for csplit: csplit -sf file -n 1 large_file /XYZ/ would silently split the file, creating pieces with prefix file and numbered using a single digit, e.g. file0 etc. Note that using /regex/ would split up to, but not including the line that matches regex. To split up to and including the line matching regex add a +1 offset: csplit -sf file ...


6

With a modern ksh here's a shell variant (i.e. without sed) of one of the sed based answers above: { read in <##XYZ ; print "$in" ; cat >file2 ;} <largefile >file1 And another variant in ksh alone (i.e. also omitting the cat): { read in <##XYZ ; print "$in" ; { read <##"" ;} >file2 ;} <largefile >file1 (The pure ksh ...


5

{ sed '/XYZ/q' >file1; cat >file2; } <infile With GNU sed you should use the -unbuffered switch. Most other seds should just work though. To leave XYZ out... { sed -n '/XYZ/q;p'; cat >file2; } <infile >file1


7

With awk you can do: awk '{print >out}; /XYZ/{out="file2"}' out=file1 largefile Explanation: The first awk argument (out=file1) defines a variable with the filename that will be used for output while the subsequent argument (largefile) is processed. The awk program will print all lines to the file specified by the variable out ({print >out}). If the ...


3

Try this with GNU sed: sed -n -e '1,/XYZ/w file1' -e '/XYZ/,${/XYZ/d;w file2' -e '}' large_file



Top 50 recent answers are included