I have a folder which has multiple sub-folders and sub sub folders. I want to print the content of a file called result.txt
which is present in many sub folders or sub sub folders into a csv file along with the name of the sub-folder.
That means if the files named result.txt
are in
abc/def/result.txt
efg/result.txt
Then I need a csv file which should have
1. abc content of its result.txt
2. efg content of its result.txt
and so on.
I started with the following find
command
find . -iname 'result.txt' "a portion of path" "content">final.csv
How should I proceed from here ?
Note: (8th December, 2017) Although the below solutions display the content properly on the terminal , none of them work when I add >final.csv. As already mentioned, my result.txt has mutilines. The content of a particular result.txt gets spilled to different cells rather than being in a single cell. Any suggestions ?
a/b/result.txt
anda/c/result.txt
as well?.csv
be comma separated? ;P