0

Hi all, I am new in shell scripting and I need your help

1. I would like to make a list of files (no folders) of unix system which do not belong to root

2. I would like to make a list with directories of system which the first letter is d or g.


=========
I know how can I list files or directories but unfortunately I don't know to do the above

ls -l | grep ^d list the directories

ls -l |grep ^- list files
==========

Could you help me please ?

3
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by bufospro
0

You could use the find command.

find . -maxdepth 1 -type f ! -uid 0

The period specifies the current directory.
-maxdepth 1 prevents it from looking into subdirectories.
-type f returns only regular files
! -uid 0 returns only files that do not belong to root

0

Thanks a lot

I try for the other question something like that
find . -maxdepth 1 -type d -name './[dgDG]*'

but it doesn't work. :(

0

Thanks a lot

I try for the other question something like that
find . -maxdepth 1 -type d -name './[dgDG]*'

but it doesn't work. :(

OK I found it thanks a lot

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.