How to set temp file directory for sed command in linux?
bash, sed
Solution
The file must be modified via temporary file, this is actually what sed was doing but it lacked permissions.
When dealing with such a situation, we just do this process manually.
## TEMP File
TFILE=`mktemp --tmpdir tfile.XXXXX`
trap "rm -f $TFILE" 0 1 2 3 15
##
sed 's_XXX_YYY_' /etc/example > "$TFILE"
cat "$TFILE" > /etc/example
## trap Deletes TFILE on Exit
Problem
I have bash script which modified file like this ``` sed -i "/hello world/d" /etc/postfix/virtual ``` and I ran this script from web application. sed command create temporary file in that directory but user under which web application works doesn't have permissions to create files in that directory. I do not want to give more permissions for the user to that folder. Is it possible to specify temp file location for sed command? I am new in linux so sorry if my question is too easy but I didn't find any solution. Thanks!