Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

10
  • my problem is I have a lot of such desired values. Commented Sep 11, 2020 at 14:01
  • 1
    @terdon I have recently been told by Ed Morton that a[$1] is sufficient to populate an array "with indices only". Commented Sep 11, 2020 at 14:01
  • @terdon ... which would actually make this question a duplicate ... Commented Sep 11, 2020 at 14:04
  • 1
    @AdminBee well I'll be... That's excellent, I had never realized it! Thanks! And yes, there are several dupes of this, I just never find them easily. Yours will do nicely. Commented Sep 11, 2020 at 14:07
  • 1
    @linux_lover if you have many desired values, use the second approach in my answer as explained in the answer. Commented Sep 11, 2020 at 14:07