Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Highlight directories in path with execute permission for others Post 302512216 by Trinimini on Friday 8th of April 2011 05:27:06 PM
Old 04-08-2011
Highlight directories in path with execute permission for others

Hi all, I'm trying to make a script that takes at the most one argument and lists all directories in the path in a special format:

User Group Other Filename
rwx r-- r-x \
rwx r-x r-- home


This is my code as it is right now:

Code:
if [ $# -gt 1 ]
then
    echo 'Usage: dirpath [ dir-name ]' 1>&2
    exit 1
fi
if [ $# = 1 ]
then
      if [ ! -d $1 ]
     then
          echo "dirpath: $1 is not a valid directory name"
         exit 1
      fi
     cd $1
fi


echo " Owner Group Other Filename"
echo " ----- ----- ----- --------"

pathnow="/$(pwd | sed 's/\// /g')"
for dirs in $pathnow
do
cd $dirs

if [ $(ls -ld . | cut -c10) != 'x' ]
then
tput smso
fi
echo -n `ls -ld . | cut -c1`
echo -n ' '
echo -n `ls -ld . | cut -c2`
echo -n ' '
echo -n `ls -ld . | cut -c3`
echo -n ' '
echo -n `ls -ld . | cut -c4`
echo -n ' '
echo -n `ls -ld . | cut -c5`
echo -n ' '
echo -n `ls -ld . | cut -c6`
echo -n ' '
echo -n `ls -ld . | cut -c7`
echo -n ' '
echo -n `ls -ld . | cut -c8`
echo -n ' '
echo -n `ls -ld . | cut -c9`
echo -n ' '
echo  -n `ls -ld . | cut -c10`
echo " $dirs"
tput rmso
done

exit 0

This is what I get when I run my script:

dirpath ~/BTP100
Owner Group Other Filename
----- ----- ----- --------
d r w x r - x r - x /
d r w x r - x r - x home
d r w x - - x - - x drey5

As you can see aren't there as I want them and the directory BTP100 isn't listed. Also, directories that have execute permission for others aren't being highlighted.

Any help is appreciated.
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

No permission to execute file

I am logged in as root and am trying to execute a file called x_cleanup_equdata but keep getting the message ksh: x_cleanup_equdataNEW: 0403-006 Execute permission denied. I did FTP this file from another server using GET, would this make the difference? I tried chmod 666 but still no luck. ... (2 Replies)
Discussion started by: markbeeson
2 Replies

2. Shell Programming and Scripting

without execute permission

how can a script run without execute permissions. when i run myscript as : sh a.sh it was working but when i say simple a.sh its not working since it has no x permission.but how about fist case? (1 Reply)
Discussion started by: Raom
1 Replies

3. Shell Programming and Scripting

Only Execute Permission for Others...

This might be very silly question but i dont know y is it so... i Have script I have Given the permissions in the following manner... -rwxrwx--x 1 root system 3 Jun 08 15:46 temp I want no one to see what is present in that but should be able to execute it.. but when... (3 Replies)
Discussion started by: pbsrinivas
3 Replies

4. Shell Programming and Scripting

Problem with execute my file permission

Here is my script. 1 echo -n "Enter file name : " 2 read file 3 chmod 777 $file 4 && W="write = yes" || W="Write = no" 5 chmod 777 $file 6 && X="Execute = yes" || X="Execute = No" 7 chmod 777 $file 8 && R="Read = yes" || R="Read = No" ... (0 Replies)
Discussion started by: qral_hdr
0 Replies

5. Shell Programming and Scripting

How to list all the files, directories and sub-directories in the current path except one directory?

Can anyone come up with a unix command that lists all the files, directories and sub-directories in the current directory except a folder called log.? Thank you in advance. (7 Replies)
Discussion started by: Manjunath B
7 Replies

6. UNIX for Dummies Questions & Answers

Provide execute permission to a user

Hi, I have a shell script(test.sh) and need to give execute permission for this shell script to user group cobr_sftp and oracle. Could you please help as to how to give this permission. I have already given full access(777) to script test.sh. Does this mean all the users/user group can access... (1 Reply)
Discussion started by: abhi_123
1 Replies

7. Debian

Execute permission problem

Hello, I need to install a program from a DVD. It uses a sh script called setup. root@ragnok: head -2 /media/cdrom0/setup #!/bin/sh root@ragnok: ls -l /media/cdrom0/setup -r-xr-xr-x 1 root root 4688 Nov 8 08:38 /media/cdrom0/setup root@ragnok: /media/cdrom0/setup bash:... (2 Replies)
Discussion started by: snorkack59
2 Replies

8. Red Hat

Use of Execute permission for folder

Hi All, What is the use of execute permission for a folder. I know "for execute a file(script file) we have to provide execute permission to that respective file".But what is the use to give execute permission to folder.Is it equal to read permission ? Regards, Mastan (1 Reply)
Discussion started by: mastansaheb
1 Replies

9. Solaris

Giving read write permission to user for specific directories and sub directories.

I have searched this quite a long time but couldn't find the right method for me to use. I need to assign read write permission to the user for specific directories and it's sub directories and files. I do not want to use ACL. This is for Solaris. Please help. (1 Reply)
Discussion started by: blinkingdan
1 Replies
createhomedir(1)					    BSD General Commands Manual 					  createhomedir(1)

NAME
createhomedir -- create and populate home directories on the local computer. SYNOPSIS
createhomedir [-scbalh] [-n directoryDomainName] [-u username] DESCRIPTION
createhomedir provides several options for creating and populating home directories. OPTIONS
-s creates home directories for server home paths only (default). -c creates home directories for local home paths only. -b creates home directories for both server and local home paths. -a creates home directories for users defined in all directory domains of the server's search path. -l creates home directories for users defined in the local directory domain. -L causes the created home directory to be localized. -n directoryDomainName creates home directories for users defined in a specific directory domain in the server's search path. -u username creates a home directory for a specific user defined in the domain(s) identified in the -a, -l, or -n parameter. If you omit the -a, -l, and -n parameters when you use the -u parameter, -a is assumed. -i reads username list from standard input and creates specified home directories. Each username should be on its own line. -h usage help. FILES
/usr/sbin/createhomedir location of tool CAVEATS
When using the -a option, search limits of various directory servers (such as Open Directory or Active Directory) can prevent all possible home directories from being created. In this case, you may need to specify the usernames explicitly. Mac OS X May 31, 2019 Mac OS X
All times are GMT -4. The time now is 04:53 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy