How to insert text into multilple desktop files?

For discussions about programming, and for programming questions and advice


Moderator: Forum moderators

Post Reply
geo_c
Posts: 2501
Joined: Fri Jul 31, 2020 3:37 am
Has thanked: 1799 times
Been thanked: 705 times

How to insert text into multilple desktop files?

Post 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.

geo_c
Old School Hipster, and Such

User avatar
MochiMoppel
Posts: 1116
Joined: Mon Jun 15, 2020 6:25 am
Location: Japan
Has thanked: 17 times
Been thanked: 359 times

Re: How to insert text into multilple desktop files?

Post 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

geo_c
Posts: 2501
Joined: Fri Jul 31, 2020 3:37 am
Has thanked: 1799 times
Been thanked: 705 times

Re: How to insert text into multilple desktop files?

Post 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.

geo_c
Old School Hipster, and Such

Post Reply

Return to “Programming”