I got a Qstion. Im posting to a phpbb forum with bash and curl.. i have a text file with the following tags that i post to the forum:
[bb]$var1[/bb]
[aa]$var2[/aa]
[cc]$var3[/cc]
How can i with sed or awk put var content from shell script between the [tags]...[/tags] in the textfile? I tried with awk and sed to replace it. But i just dont get it to work
try something like this (assuming here that you are replacing the literal string "$nfotext")
#!/bin/bash
TAGS="nfo1 nfo2 nfo3 nfo4"
nfo1var="text for nfo1"
nfo2var="text for nfo2"
nfo3var="text for nfo3"
nfo4var="text for nfo4"
cmdfile=./cmds.sed
echo "#commands to insert data between tags" > $cmdfile
for i in $TAGS; do
eval REP="\$${i}var"
echo "s/\(\$${i}text\)/"$REP"/ " >> $cmdfile
done
sed -f "$cmdfile" infile.dat > outfile.dat
easy to change this so you don't need a cmds.sed file...
The problem i have is that it doesnt replace the nfotxt with the content of the file.nfo
and that it wil replace it with the name of the file rather then the content.. Hope someone can help me with this..