[Klug-general] auto-delete menu entries as part of a bash script

James Morris jwm.art.net at gmail.com
Mon Nov 25 17:23:00 UTC 2013


You can use sed with a regular expression:
sed  '\|\[exec[]]\s[(]\(.*\)[)]\s[{]/usr/lib/xscreensaver/\1
-root[}]|d' path/to/menufile

the above command output the menufile to stdout minus matching lines,
it assumes no variation in spaces between the { and } characters from
the example you showed.

once you have confirmed that it works and is not removing lines which
you do not wish removed, pass the -i option for it to edit the file
proper.

i've tested it in debian, using the following file:

----8<--------8<--------8<--------8<--------8<----

[begin] (Fluxbox 1.3.5)
[encoding] {UTF-8}
      [exec] (xterm) {xterm}
      [exec] (firefox) {firefox}
      [exec]   (Run) {fbrun}
[submenu] (Terminals)
      [exec]   (xterm) {xterm}
[end]


[exec] (foobar) {/usr/lib/xscreensaver/foobar -root}
[exec]  (foobar1) {/usr/lib/xscreensaver/foobar1 -root}
[exec] (foobar)   { /usr/lib/xscreensaver/foobar -root }
[exec] (fooba3r)  {/usr/lib/xscreensaver/fooba3r  -root }
[exec] (bar) {/usr/lib/xscreensaver/bar -root}
[exec] (barf) {/usr/lib/xscreensaver/barf -root}

----8<--------8<--------8<--------8<--------8<----

note it won't remove the menu entries with the extra spaces between  { }.

james.

On 25 November 2013 16:08, Sharon Kimble <boudiccas at talktalk.net> wrote:
>
> I want to delete menu commands that are in the form of -
>
> [exec] (foobar) {/usr/lib/xscreensaver/foobar -root}
>
> and there are 50+ commands to be deleted as part of a bash-script. But,
> how do I do it please? I need some form of commands that I can put into
> my menu generation script, which will auto-delete them in the future.
> Can anyone help please?
>
> Thanks
> Sharon.
> --
> A taste of linux = http://www.sharons.org.uk
> efever = http://www.efever.blogspot.com/
> efever = http://sharon04.livejournal.com/
> my git repo = https://bitbucket.org/boudiccas/dots
> Debian testing, Fluxbox 1.3.5, LibreOffice 4.1.3.2
> Registered Linux user 561944
>
> _______________________________________________
> Kent mailing list
> Kent at mailman.lug.org.uk
> https://mailman.lug.org.uk/mailman/listinfo/kent



More information about the Kent mailing list