I have a directory that contains so many sub directories and files in them. I would like to create a file which provides each file name and it's source directory path information
For example:
I have a folder name sample which contains sample1 and sample2 sub directories in it.
I have ex1.csv
, ex2.csv
in sample 1 and ex3.csv
, ex4.csv
in sample 2 directory.
I need to create a text file (or) CSV file which gives the information in the following manner.
ex1.csv,sample/sample1
ex2.csv,sample/sample1
ex3.csv,sample/sample2
It would be great if someone help me out to create the script file in UNIX.
I tried: $ find sample -type f -printf '%f,%h\n'
As I am using Solaris it is not allowing me to use printf
and I don't have access to install other utilities.
but when i execute the following code i am getting syntax error
`(' unexpected
– vinod kumar Aug 30 '16 at 18:16bash
shell? If "yes", typebash
in your terminal and try my solution again. If "no", we need to know which shell you use (tryecho $SHELL
). – Martin Nyolt Aug 31 '16 at 08:09