Quote:
|
Quote:
Quote:
So I have these empty boxes ready for the line counts. <td id="someid"></td> Somehow I need to get this working like the following broken example: Just have sed insert the output of awk after the unit td tag. Im not sure how to make that work tho. Quote:
So does anyone know how to get sed to insert the output of the following command directly into a unique table data box by getting sed to printing the output of the following command after <td id="someid"> Quote:
|
You're quite close. awk can do a lot with its printf function and you could then keep that in a variable, for later use in "sed":
Code:
w=$(wc -l ../dir/target.txt | awk '{printf "<td id=\"someid\">%d</td>\n", $1 }') Code:
sed -e "s#<td id=\"someid\">[[:digit:]]*</td>#<td id=\"someid\">$w</td>#" file.html However, with what you describe, putting the output of "wc" into a text file and then using SSI to read that text file also works well. "cron" can work quite well for you but if your file gets changed at more random intervals, then "incron" can launch scripts when a watched file is updated. That would give you more real-time data for your page. |
Look like it's a waste to rewrite the whole html file each time a td value needs to be actualized
It would be more efficient to use php or maybe javascript ajax For example, write each file lines count in a file: count.txt Code:
#!/bin/bash PHP Code:
|
If this produces a promising looking command
Code:
echo 'sed "s/\(<td id=\"someid\">\)[[:digit:]]*\(<\)/\1'$(wc -l < ../dir/target.txt)'\2/" file.html' |
This works on my machine. In a bash script, I wrote the following.
Code:
data=$(sed 's/.*="\(.*\)".*/\1/' /some_directory/stuff.html) Code:
<td id="backup_home.sh">1</td> |
Quote:
Note: Placed the index.org which is copied to > index.html during the script run, it is in fact rather crude, but indeed functional. Thank you. |
Quote:
|
sed -i creates temp file then moves it to original file, it's not too bad for a table update, although it could be better
|
All times are GMT -5. The time now is 07:57 PM. |