2

I'm trying to grep the output of strings and only find lines that start with a certain number of = chars. I tried strings data.txt | grep ^=*

Sample output:

1~{,
 WX2
};K,<
========== truKLdjsbJ5g7yyJ2X2R0o3a5HQJFuLk
Nqp@
w"#/6>
QE++
6?M 
V9p>
Y22f
'WT$
v?4s
xp,b
ai2v>/

In my terminal, the long series of = chars is highlighted in red, so grep is successfully matching it, but I'm also getting all the others. I've checked man grep which says that by default grep should only print matching lines, and indeed that's what I usually observe, but in this case that's definitely not the case.

0

1 Answer 1

2

^=* means search for a line starting with zero or more equal signs.

If you want lines starting with = just use ^=

2
  • 2
    Thanks, I actually want lines that contain more than one = so it seem ^==* will do the trick.
    – Juicy
    Commented Jul 30, 2015 at 21:28
  • 1
    ^==* will return any line with 1 or more = signs. The functionality of this would be equivalent to ^=+ If you want more than one, you should use grep -E '^={2,}' according to the grep manpage
    – Eric
    Commented Jul 30, 2015 at 22:37

You must log in to answer this question.

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