News for hackers. Stuff that matters.
Re:look(1): lines beginning with given string by hanez on Saturday December 12, 2015 @09:51PM (#10725210)
When running 'look' to get all comments in a file I only get the first found line in the ouput. Can someone explain this?

look "#" .zshrc

There are really a lot more comments (lines starting with '#') in my .zshrc then the first line.

Re:look(1): lines beginning with given string by kbd on Saturday December 12, 2015 @10:00PM (#10725230)
From the manpage:

> As look performs a binary search, the lines in file must be sorted...

I assume you didn't sort your source file first.

Re:look(1): lines beginning with given string by hanez on Saturday December 12, 2015 @10:09PM (#10725249)
When sorting the file first I get no output anymore:

sort ~/.zshrc -o /tmp/.zshrc

look "#" /tmp/.zshrc

Sorry for the noise but I am confused... :|

Re:look(1): lines beginning with given string by emmelaich on Saturday December 12, 2015 @10:44PM (#10725339)
sort(1) might not use the same ordering as look(1)

Try setting LC_COLLATE=C and export it and retry.

Re:look(1): lines beginning with given string by hanez on Saturday December 12, 2015 @10:47PM (#10725349)
Uh, wow! That was it!

Thanks for this answer...

Re:look(1): lines beginning with given string by andreasvc on Saturday December 12, 2015 @10:54PM (#10725362)
It doesn't make sense to sort a configuration file, order and context matters. Easier to just use grep '^#' (or even better, ag).
Re:look(1): lines beginning with given string by hanez on Saturday December 12, 2015 @11:02PM (#10725382)
Yes, I am aware of that but I wanted to understand the usage of 'look' at this point. It was a fault to try stuff using the .zshrc file at first because I ran into misunderstanding everything. It was just the first file that came in mind to me. Since sorting a source file and then "looking" for comments makes no sense in any way, grep seems to be really the better choice.
Re:look(1): lines beginning with given string by dmd on Saturday December 12, 2015 @09:59PM (#10725227)
Your .zshrc is almost certainly not a sorted file.