The approach offered by Qingwei Zhang is the correct one ... because it eliminates the possibility of matching incorrectly on string having characters which precede, or follow, the chosen pattern string.

The single quotes is definitely required in the case that the 103 itself is surrounded by double-quotes.


On 2025-06-22 22:37, Qingwei Zhang via linux wrote:
Hi,

You can use the following one-liner with `sed` to edit the file in place:

```
sed -i 's/^CONFIG_TARGET_ROOTFS_PARTSIZE=103$/CONFIG_TARGET_ROOTFS_PARTSIZE=255/' filename
```

Replace `filename` with the actual name of your file.

On Sun, Jun 22, 2025 at 10:31 PM Ron via linux <[email protected]> wrote:

    James via linux wrote on 2025-06-22 19:23:

    > I want a one liner to edit a file in place to change:
    > CONFIG_TARGET_ROOTFS_PARTSIZE=103
    > to
    > CONFIG_TARGET_ROOTFS_PARTSIZE=255


    Assuming file is called $file_name, try this:

    sed -i -e
    's/CONFIG_TARGET_ROOTFS_PARTSIZE=103/CONFIG_TARGET_ROOTFS_PARTSIZE=255/'

    $file_name




    To unsubscribe send a blank message to
    [email protected]
    <mailto:linux%[email protected]>
    To get help send a blank message to [email protected]
    <mailto:linux%[email protected]>
    To visit the archives: https://lists.linux-ottawa.org

Reply via email to