Bounded operator that does not attain its norm
What is a bounded operator on a Hilbert space that does not attain its norm? An example in $L^2$ or $l^2$ would be preferred.
All of the simple examples I have looked at (the identity operator, the shift operator) attain their respective norms.
For an example in $L^2[0,1]$, consider the operator of multiplication by $x$, i.e. $(Tf)(x) = x f(x)$.
In finite dimensional spaces all operator is norm attaining: we use the fact that the unit ball is compact. Then $\{Tx,\lVert x\rVert=1\}$ is bounded because it's the image of a compact set by a continuous map.
Otherwise, it's not true. Consider $H:=\ell^2(\Bbb N)$. Define $Tx:=\sum_{n\geq 1}\left(1-\frac 1n\right)\langle x,e_n\rangle e_n$ where $e_n$ is the sequence whose $n$-th term is $1$, the others $0$. The norm of $T$ is $1$, but for $x\neq 0$, $$\lVert Tx\rVert^2=\sum_{n\geq 1}\left(1-\frac 1n\right)^2|\langle x,e_n\rangle|^2\leq \sum_{n\geq 1}|\langle x,e_n\rangle|^2=\lVert x\rVert^2.$$ The last inequality isn't an equality, since $\langle x,e_n\rangle\neq 0$ for some $n$.
On $\ell^2(\mathbb{N})$, take $T\in B(\ell^2(\mathbb{N}))$ to be the map $$ (a_n)_{n\in\mathbb{N}}\mapsto \left((1-\frac1n)a_n\right)_{n\in\mathbb{N}} $$
Since every coefficient is multiplied by scalar less than $1$, $T$ is contractive (i.e. $\|T\|\leq1$). Also, $\|Te_n\|=(1-\frac1n)$, where $e_n$ are the elements in the canonical basis, so $\|T\|=1$. And $$ \|T(a_n)\|^2=\sum_n|(1-\frac1n)a_n|^2<\sum_n|a_n|^2=\|(a_n)\|_2^2, $$ so the norm is never attained.
Edit: another easy example is as follows. Let $H=L^2[0,1]$, and let $T$ be the operator such that $$ (Tf)(t)=tf(t). $$ Then it is easy to see that $\|T\|=1$ (using functions supported near $1$). And, given any $f\in L^2[0,1]$, if $f\ne0$ then $$ \|Tf\|_2^2=\int_0^1t^2|f(t)|^2<\int_0^1|f(t)|^2=\|f\|_2^2 $$ (the inequality has to be strict: otherwise we get $\int_0^1(1-t^2)|f(t)|^2=0$, which implies $f=0$).
This is similar to other answers but a bit more general. Consider a sequence $c=\{c_n\}\in\ell^\infty(\mathbb{Z})$ such that $|c_n|<\sup|c_n|$, e.g. $c_n$ may be positive and growing to $1$.
Define $T:\ell^2(\mathbb{Z})\to \ell^2(\mathbb{Z})$ by $$T:x=\{x_n\}\mapsto Tx = cx =\{c_nx_n\}.$$
Then, for any $x=\{x_n\}\in\ell^2$, we have $$\|Tx\|^2 = \sum_{n\in\mathbb{Z}} |c_nx_n|^2<\sum_{n\in\mathbb{Z}} \sup|c_n|^2|x_n|^2= \sup|c_n|^2\|x\|^2\tag{1}$$ that is $$\|T\| \leq\sup|c_n|.$$ On the other hand the choice $x=e_n=\{\delta_{kn}\}_{k\in\mathbb{Z}}$, where $\delta_{kn}$ is the Kronecker-$\delta$ (which is 0 whenever $k\ne n$ and 1 if $k=n$) shows that $$\sup_{\|x\|\leq1}\|Tx\|\geq\sup_{n}\|Te_n\|=\sup_n|c_n|$$ and hence $$\|T\| =\sup|c_n|.\tag{2}$$ Now, (1) and (2) shows that the norm is never attained.
Let $T:l^{2}\longrightarrow l^{2}$ gven by $T(x)= \Big( \dfrac{n x_n}{n+1}\Big)_{n=1}^{\infty}$. Notice that \begin{equation} \|T(x)\|_{l^{2}} = \left | \sum_{n} \Big( \dfrac{n}{n+1}\Big)^{2}x_{n}^{2} \right |^{1/2} < \Big(\sum_{n} x_{n}^{2}\Big)^{1/2}= \|x_n\|_{l^{2}}. \end{equation} Then $T$ is bounded and if $\|x_n\| = 1, \|T(x)\|_{l^{2}} < 1$. But $\|T(e_i)\| = n/(n+1)$ . Hence $\|T\|=1$.