home | list info | list archive | date index | thread index

Re: one liner

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 <linux [ at ] linux-ottawa [ dot ] org> 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
    linux+unsubscribe [ at ] linux-ottawa [ dot ] org
    <mailto:linux%2Bunsubscribe [ at ] linux-ottawa [ dot ] org>
    To get help send a blank message to linux+help [ at ] linux-ottawa [ dot ] org
    <mailto:linux%2Bhelp [ at ] linux-ottawa [ dot ] org>
    To visit the archives: https://lists.linux-ottawa.org

message navigation