Quote:
Code:
sed '/^\$\$INPUT_FILE_DATE=/s/[0-9]\{6\}/'$DATEMONTH'/' test>test
sed '/^\$\$PFFLAG=/s/.$/'$FLAG'/i test>test
|
You cannot read from a file and redirect output to that same file in a single command.
The shell output redirection operator (>) will truncate/erase the file prior to the command being executed. Because the file has been truncated, there is no data for the sed command to read.
You have two options:
1. Use the sed '-i' option to modify the file in-place. As in:
Code:
sed -i '/^\$\$INPUT_FILE_DATE=/s/[0-9]\{6\}/'$DATEMONTH'/' test
sed -i '/^\$\$PFFLAG=/s/.$/'$FLAG'/i test
2. Redirect the output to a temporary file, then copy the temporary file back on top of the original file.
For option 2 to work, you still need to modify your sed commands. The easiest would be to specify multiple sed commands with the -e option. For instance:
Code:
sed -e '/^\$\$INPUT_FILE_DATE=/s/[0-9]\{6\}/'$DATEMONTH'/' \
-e '/^\$\$PFFLAG=/s/.$/'$FLAG'/i test > temp_file
mv temp_file test