Find the owner user of each folder in a list

Hello

I have a file containing the list of different folders like this file_list.txt:

/s8/tests/test1
/s8/tests/tests/test2
/s8/tests/test2
/s8/tests/tests/test2/test5

I want a script to put the owner user of each folder in front of it in the text file.

So the reult would become like this file_list_users.txt:

/s8/tests/test1 user1
/s8/tests/tests/test2 user2
/s8/tests/test2 user1
/s8/tests/tests/test2/test5 user3

look into ls -ld

that is correct but how could i put the owner user of each folder in front of each folder path in the text file?

Hi,

Have you tried anything, let us know if you have.

You can create a loop with your file as input, then using cut or awk capture what you require to an output file.

I'm going to point you at this post where someone has already pretty much answered the question for you.

Regards

Gull04

Are you on Linux? If so you should have the stat command. See man stat for other % options.

stat -c '%n %U' folder1 folder2 folder3
1 Like

Hi,

The command is also available on Solaris 11 and Solaris 10 if the contributed S/W was installed.

Regards

Gull04