Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

Say I have some file with a bunch of lines in the form


Desired output


I want to use awk to extract the substring that starts at the beginning of the line and goes up until, but not including the first equals sign. I want to be able to pipe this output to xargs.

share|improve this question
sed's greediness makes this a quick fix, sed 's/=.*//', although I've never done anything with awk. – Rob Mar 16 '12 at 18:06
up vote 4 down vote accepted

In Awk:

awk '{sub(/=.*/, ""); print}' filename

But, I think Rob's solution is easier:

sed 's/=.*//' filename
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.