Having trouble expanding variables with sed
I'm trying to use sed in a script to filter records in a log file by providing 2 variables (flight & Date)to the script. Each record is seperated by a blank line in the log.
My filter works (to look for flt 377 on 2013-05-09) as: sed -e '/./{H;$!d;}' -e 'x;/scheduledFlightNumber>377/!d;/scheduledDepartureTimestamp>2013-05-09/!d' Logfile but I want to be able to provide a flt# and date as arguments. I've tried: sed -e '/./{H;$!d;}' -e 'x;/scheduledFlightNumber>${flt}/!d;/scheduledDepartureTimestamp>${Date}/!d' Logfile but it doesn't expand the ${flt} and ${Date}. I've also tried using "eval" in front of the sed command, but no joy. This is my first post, but I've found many solutions previously (Thanks). TIA for any future help. |
Variables are not expanded inside single quotes '$here' but they are inside double quotes "$here".
That's a shell feature nothing to do with sed. |
It'd be nice to see a few relevant lines of the input file.
Do you just want the lines that match both of the strings, or just specific fields within those lines. |
All times are GMT -5. The time now is 03:48 PM. |