I want to search my code base for ocurrences of a string, and then get the formatted output as filename, line number, and code lide. I got it as I wanted on the first line of the output, but the coming lines loses the wanted formatting.
$ find src/ -name "*.js" | xargs grep --null -E -n 'filter\(|map\(' | xargs -0 printf "%-100s%-5s%-100s" > test.txt
The output is as follows: (scroll right to see the complete line)
src/components/AppRouterSwitch.js 15: return _Routes.map((route, index) => {
src/components/forms/UserEditForm/UserEditForm.js36: const options = UserTypes.map((type, index) => <option key={index} value={type.type}>{type.name}</option>);
src/components/pages/AdminPage/SolutionManagementEditPage/SolutionManagementEditPage.js119: templates:state.templates.filter(item=>item.SOLUTIONID ==id)
src/components/pages/AdminPage/SolutionManagementEditPage/SolutionManagementEditPage.js120: .map(item=>{return{
The first row looks just as I want it. The following loses the desired formatting. Ending the printf format string with /n
doesn't do the trick.
-l
(a lowercase L)