Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm running an application that is outputing lines, piping to GREP to select only specific lines, but want to remove the first X characters which are worthless.


varnishlog | grep Hash

Produces for example

   34 Hash         c /address
   41 Hash         c /addresss?xml=1&

I want the last part after the "c" in order to record these in a file.

Which command do I pipe to.

share|improve this question
up vote 3 down vote accepted

awk works, but I think cut is simpler for this task, e.g.

$ varnishlog | grep Hash | cut -b 23-

-b specifies bytes, and 23- says keep the 23rd byte to the end of the line.

You could also use -c, which is characters instead of bytes (in this case characters == bytes)

share|improve this answer

I did some research and came up with the following using AWK:

$ varnishlog | grep Hash | awk {'print substr($0,23)}'

This filters out the first 23 characters and leaves the part that I want.

If anyone has a better answer please post.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .