Find files that contain some text

A short one liner to find all files in a directory tree that contain some text.

grep -Rl “text to searchdirectory

The text to search may be a regular expression as accepted by grep. The directory is the root of the tree you want to search.

Hope this is found helpful.

Comments

Add all items in an array to a collection

So I wanted to add all the items in an array to a collection in Java easily. A look into the util package documentation offered a solution which I now share.

yourCollection.addAll(java.util.Arrays.asList(yourArray));

The collection can be any object from the collections framework (List, Set, Queue) and yourArray is the array with the elements to be added.
If you are using generics, the component type of the array has to be a assignment compatible with the type of the collection. In other words, if your list is something like List<CharSequence>, then you can add an array of type StringBuffer[], String[], or CharSequence[], but not Long[].

Comments