You can always pass your commands as arguments for
Some working examples:
bash -c "rm -fR /some/dir/to_delete; mkdir /hello; touch /hello/foo.bar"
This should work to delete
/some/dir to delete then create dir
/hello and write
baz to file
bash -c 'rm -fR "/some/dir to delete"; mkdir "/hello"; echo "baz" > "/hello/foo.bar"'
These will not work correctly:
Be careful with quotes, this will break things as because quoting error command will be
rm -fR "/some/dir/to and everything after that is ignored (or to be more precise
delete"; mkdir /hello" is expanded if
$0 is used within command):
bash -c "rm -fR "/some/dir/to delete"; mkdir /hello"
quoted part unquoted whitespace here
And here is another thing to mention. If you want
~ to expand as home directory and your file path may contain whitespaces need quoting this will not work. File
~/hello world.tmp is not created in right place but instead it tries to find directory named
~ from current working directory whatever it is and create file here however
~/level2.ls is created under home dir:
bash -c 'echo "Hello World" > "~/hello world.tmp"; cd /; ls * > ~/level2.ls;'
fully quoted filename prevents ~ from expanding
Instead you must use quoting like this to allow
bash -c 'echo "Hello World" > ~/"hello world.tmp"; cd /; ls * > ~/level2.ls;'
now ~ is not quoted at all
Here is line for your case:
' is needed for special char
*, if not escaped it will expand too early.
bash -c 'cd "/home/seraex/MyDoc"; rm -f MyDoc.tgz; tar -czf MyDoc.tgz *'
OR if you want to use more general ~ as home dir then use this:
bash -c 'cd ~/"MyDoc"; rm -f MyDoc.tgz; tar -czf MyDoc.tgz *'
So, this is just one possible way to do what you need, it may or may not work directly too (without
bash -c and outer quotes). At least with KDE 4 launcher it will handle command
cd ~/"MyDoc"; rm -f MyDoc.tgz; tar -czf MyDoc.tgz * without any problems. However other examples should work with any launcher that allows specifying arguments for program and behavior still depends on many things and at least you may want to check that any special characters are expanded at right time.
I have not tested this and cant do that now because answering with my phone but it should work ok. Now tested and I can confirm that it works well