Page 1 of 1

How to insert text into multilple desktop files?

Posted: Sat Jan 27, 2024 6:31 am
by geo_c

I have 165 desktop files residing in a dedicated directory that need pw-jack inserted after the = in the exec line.

example:

Code: Select all

Exec=lsp-plugins-ab-tester-x2-stereo

needs to be converted to

Code: Select all

Exec=pw-jack lsp-plugins-ab-tester-x2-stereo

I'm not sure how to setup a script or command to do a replacement, whether the sed command is the right route, or if there is a better approach. Looking for suggestions to point me in the right direction.


Re: How to insert text into multilple desktop files?

Posted: Sat Jan 27, 2024 7:29 am
by MochiMoppel

Any conditions? Or are you saying that all desktop files in this directory need this replacement?

In this case a
sed -i 's/Exec=/Exec=pw-jack /' /path/to/directory/*.desktop
should do


Re: How to insert text into multilple desktop files?

Posted: Sat Jan 27, 2024 9:03 am
by geo_c
MochiMoppel wrote: Sat Jan 27, 2024 7:29 am

Any conditions? Or are you saying that all desktop files in this directory need this replacement?

In this case a
sed -i 's/Exec=/Exec=pw-jack /' /path/to/directory/*.desktop
should do

No conditions, they're all the exact same insertion.

Thanks very much, that's a lot simpler than I was thinking it might be, but I haven't used sed in quite awhile.