1

Using variables with sed

view story
linux-howto

http://stackoverflow.com – I'm trying to delete a part of a file using sed in Linux (Ubuntu). Specifically, I want to delete the first lines of a log file until the first occurrence of the current system date (using the pattern '10 Jan 13'). So, I store the date in a variable root@server:/# VAR_DATE=`date -R | cut -c6-11` And after that, I use sed root@server:/# cat log_file.txt | sed -n -e '/$VAR_DATE/,$p' But it doesn't work. I've tried a lot of combinations with the same result: root@server:/# cat log_file.txt | sed -n -e '/"$VAR_DATE"/,$p' root@server:/# cat log_file.txt | sed -n -e '/"${VAR_DATE}"/,$p' root (HowTos)