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 ?

See the man pages for the find command.

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

Thanks a lot

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

but it doesn't work. :(

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.