To me, “xargs” is a useful command. Let’s see the example together. We want to search for the word “license” in all __init__.py files. My solution is like this:
find . -name __init__.py | xargs cat | grep license
Let’s analyse each command and its options:
find . -name __init__.py : First, we want to find all files match the name “__init__.py” in the current working directory (“.” is important; i.e the current working directory). You will see a list of filepaths of which __init__.py is located in the current directory and its subdirectory in Konsole.
| : This is for redirection purpose; The result that you get in Konsole, the list of filepaths, will become a parameter for other command right after “xargs” command, “cat” command, in this case.
cat : cat is used to view content of text file, __init__,py. As cat is put right after “xargs”, it will try to read all text files in the list and display continuously in Konsole;
greb license : Finally, greb is used to search all lines match the partern “license”.
That’s all from the above command line can do. Do you have other ways?
Enjoy,
da




