Quantcast
Channel: UNIX and Linux Forums
Viewing all articles
Browse latest Browse all 16232

sed not working while passing the variable to print

$
0
0
Hi

I have below sed to search and print particular line that matches in file and prints it, which is actually working fine as expected.

Code:

sed -n "/^2012-11-19 23:[0]*/p" filename
but if I replace date with the variable it seems it's not recognizing it and throwing out error

Code:

v="2012-11-19"
sed -n 's/^'$v' 23:[0]*/p"  filename
 sed -n "s/^$v 23:[0]*/p"  filename

so can anyone help me resolving this??

Viewing all articles
Browse latest Browse all 16232

Trending Articles