bash - sed removes part of the string when doing search/replace -
i have local files containing special characters square , regular brackets.
when trying replace part of filename sed filename being
the original file name looks this:
ddatum - ffirma - bbetreff (wwer) [tags_][beleg]_007246-1 copy.pdf
when doing sed replace results like:
20161219 - ffirma - bbetreff (wwer) copy.pdf
another example:
- original:
ddatum - ffirma - bbetreff (wwer) [tags_][beleg]_007858.pdf - result:
20161231 - ffirma - bbetreff (wwer)
the sed command use is:
newname=`sed -e 's/ddatum/'\$firstdate'/g' <<< "\$f"` $firstdate contains simple date string. $f contains original file name.
i suppose has literal characters. search has not rendered useful far. support.
this it:
newname=`sed -e "s/ddatum/$firstdate/g" <<< "$f"` example:
$ f="ddatum - ffirma - bbetreff (wwer) [tags_][beleg]_007246-1 copy.pdf" $ firstdate="20161231" $ newname=`sed -e "s/ddatum/$firstdate/g" <<< "$f"` $ echo $newname 20161231 - ffirma - bbetreff (wwer) [tags_][beleg]_007246-1 copy.pdf
Comments
Post a Comment