how to use sed in a loop w/parameter

February 6, 2011 at 11:11:23
Specs: unix
I have a file called MON_ASN with a timestamp at the end. I wasnt strip out the timestamp and put that in each file at the end of each transaction. Here is what I have below. This works as far as stipping off the timestamp and putting in a file called REPL. But the SED statement does not work. Any ideas?

files=`ls MOM_ASN* 2>/dev/null`
if [[ -z $files ]]
log "no files"
log "$files "
for file in $files
echo $file | cut -f3 -d\_ > REPL
### in REPL file, I have the timestamp I need. In the following statement, I want replace for each file in $files at the end of each transaction with the contents of REPL. This sed does not work here with the $REPL parameter. Need help here
sed "s/$/${REPL}/g" $file >> $totfile
##mv $file backup

See More: how to use sed in a loop w/parameter

Report •

February 6, 2011 at 14:35:37
This link describes embedding shell variables in sed:

Report •

February 7, 2011 at 04:30:23
Thank you! I thought I tried every combination on qualifying that parameter...must have missed this one. Thanks again

Report •

Related Solutions

Ask Question