10-07-2004
If you have the memory, you might want to read the whole file into memory, manipulate it there and then dump the results back to disk.
That could be faster depending on a number of factors e.g number of search operations, insert/delete operations, disk performance or size of file.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I'm trying to insert a single character at position 11 in everyline of a file.
My input file looks like this:
456781 ~Y~12345
456782 ~N~12300
and I want my output to look like this:
45678~1 ~Y~12345
45678~2 ~N~12300
I tried the following awk code, but it's not working:... (3 Replies)
Discussion started by: mmarino
3 Replies
2. Shell Programming and Scripting
how do u insert text into a specific place in a file, say the middle for example, without changing the name for that file (1 Reply)
Discussion started by: mopimp
1 Replies
3. Shell Programming and Scripting
Script 1
Pre-requisites
Create a file with x amount of lines in it, the content of your choice.
Write a script that takes two arguments. The first being a line of text, the second being your newly created file. The script should take the first argument and insert it into the very top (the... (3 Replies)
Discussion started by: ali hussain
3 Replies
4. Shell Programming and Scripting
I wrote a script like
#!/bin/bash
echo $1 > temp
cat $2 >> temp
mv temp $2
now I have problem appending the above script(only using bash shell) so that it now inserts the first argument into the middle of the file.
I have tried using $(('wc -l < file' / 2 ))
but invain so could any one... (4 Replies)
Discussion started by: boris
4 Replies
5. Shell Programming and Scripting
how to insert one file into another file not by concatenating as usual done.
file1
A B
C D
E F
G H
I J
K L
file2
23455
33444
33334
33345
Output shud be
23455
A B
C D (4 Replies)
Discussion started by: cdfd123
4 Replies
6. Shell Programming and Scripting
I want to insert a text into the middle of a file (3 Replies)
Discussion started by: relle
3 Replies
7. UNIX for Dummies Questions & Answers
Hey guys, how do we take a line of text as an argument from a user and then insert it in the middle of a file irrespective of the number of lines in the file. I am trying to do this without SED or AWK. Inserting it in the beginning and at the end is easy, but i am trying to accomplish inserting... (6 Replies)
Discussion started by: kartikkumar84@g
6 Replies
8. Shell Programming and Scripting
I have tried
sed '/6/a text_to_inserted' file > newfile
but this inserts test_to_insert at random places in file and i want it in specific location, which is line 6.
can anyone help.... (6 Replies)
Discussion started by: phenom
6 Replies
9. Shell Programming and Scripting
Hi,
So far i've made a script that takes two argument, 1st is the contents and the 2nd is the named file. At the moment i've managed to insert new contents as a new line at the top, but i want to ask how can you insert contents in the middle of the file?
Source Code
#!/bin/bash
#Write... (3 Replies)
Discussion started by: zen10
3 Replies
10. Shell Programming and Scripting
All,
I have a file which contains two entry with spaces (either one or more than one space). ex.
/tmp/scripts/sql CUST_YR_END_INI.sql
/tmp/scripts/sql CUST_WK_END_INI.sql
/tmp/scripts/sql CUST_MTH_END_INI.sql
/tmp/scripts/sql CUST_YR_END_INC.sql
now I want to... (11 Replies)
Discussion started by: anshu ranjan
11 Replies
CCD(4) BSD Kernel Interfaces Manual CCD(4)
NAME
ccd -- Concatenated disk driver
SYNOPSIS
pseudo-device ccd [count]
DESCRIPTION
The ccd driver provides the capability of combining one or more disks/partitions into one virtual disk.
This document assumes that you're familiar with how to generate kernels, how to properly configure disks and pseudo-devices in a kernel con-
figuration file, and how to partition disks.
Note that the 'raw' partitions of the disks must not be combined. Each component partition should be offset at least one cylinder from the
beginning of the component disk. This avoids potential conflicts between the component disk's disklabel and the ccd's disklabel. The kernel
will only allow component partitions of type FS_CCD. But for now, it allows partition of all types since some port lacks support of an on-
disk BSD disklabel. The partition of FS_UNUSED may be rejected because device driver of component disk will refuse it.
In order to compile in support for the ccd, you must add a line similar to the following to your kernel configuration file:
pseudo-device ccd 4 # concatenated disk devices
The count argument is how many ccds memory is allocated for at boot time. In this example, no more than 4 ccds may be configured.
A ccd may be either serially concatenated or interleaved. To serially concatenate the partitions, specify the interleave factor of 0.
If a ccd is interleaved correctly, a ``striping'' effect is achieved, which can increase performance. Since the interleave factor is
expressed in units of DEV_BSIZE, one must account for sector sizes other than DEV_BSIZE in order to calculate the correct interleave. The
kernel will not allow an interleave factor less than the size of the largest component sector divided by DEV_BSIZE.
Note that best performance is achieved if all component disks have the same geometry and size. Optimum striping cannot occur with different
disk types.
Also note that the total size of concatenated disk may vary depending on the interleave factor even if the exact same components are concate-
nated. And an old on-disk disklabel may be read after interleave factor change. As a result, the disklabel may contain wrong partition
geometry and will cause an error when doing I/O near the end of concatenated disk.
There is a run-time utility that is used for configuring ccds. See ccdconfig(8) for more information.
WARNINGS
If just one (or more) of the disks in a non-mirrored ccd fails, the entire file system will be lost.
FILES
/dev/{,r}ccd* ccd device special files.
SEE ALSO
config(1), MAKEDEV(8), ccdconfig(8), fsck(8), mount(8), newfs(8)
HISTORY
The concatenated disk driver was originally written at the University of Utah.
BSD
March 5, 2004 BSD