Skip to content
Advertisement

I am trying to replace a string in a file via shell script where a part of the string is unknown

I have tried a few ways with sed as below without success:

sudo sed -i 's/(device.value=).*( )/1 90 2/g' /boot/cmdline.txt
sudo sed -i 's/device.value=.* /device.value=90/g' /boot/cmdline.txt

I do not know the value behind “=” which can have up to 2 digits. Before and after the string there is a space, and the string always starts with “device.value=”

PS: The file is a one liner with many values seperated through a space.

I would appreciate any help. Thx

Advertisement

Answer

Just found the answer:

sudo sed -i 's/device.value=.*/device.value=90/g' /boot/cmdline.txt
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement