With thanks to the debian-user-german mailing-list:
perl -0777 -i.bak -pe 's/###START###.*###ENDE###\s//sm' file perl -i -ne 'next if /^###START###$/../^###END###$/; print' file sed -n '/START/,/END/p' file sed -i '/START/,/END/d' file
Shells are a strange thing…look at this example:
$ bash -c "if [ -e /tmp/* ] ; then echo 'YES' ; fi" bash: line 0: [: too many arguments
Sounds logical, because bash expands the *, but…
$ zsh -c "if [ -e /tmp/* ] ; then echo 'YES' ; fi" YES
I would have expected that zsh would do the same as bash, especially because zsh is otherwise expanding everything.
This is my solution, any hints for a better way, please mail me!
#!/bin/bash
PWD=$(pwd)
DIR=$0
ABS=${DIR}
if ! [ "${DIR:0:1}" == "/" ] ; then
ABS=${PWD}/${DIR}
fi
echo ${ABS}
ls ${ABS}