Sponsored Content
Top Forums Shell Programming and Scripting Counting the number of readable, writable, and executable items in a directory Post 302475436 by ilikecows on Sunday 28th of November 2010 08:24:13 PM
Old 11-28-2010
Code:
USER=`whoami`
for GROUP in `groups`
do
  GROUPLIST=${GROUPLIST}\\\|${GROUP}
done
READ=0
WRITE=0
EXEC=0
for FILE in `ls`
do
  if ls -l $FILE | grep $USER
  then
    if ls -l $FILE | cut -c2 | grep r
    then
     READ=`expr $READ + 1`
    fi
  elif ls -l $FILE | egrep $GROUPLIST
  then
 
  else
  fi
done

You will have to fill in the gaps and add code for all conditions but you should get the idea. Someone else might know an easier way.

Last edited by ilikecows; 11-28-2010 at 09:25 PM.. Reason: Spelling error
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Counting number of files in a directory

Some simple questions from a simple man. If i wanted to count the number of files contained within a directory, say /tmp would ls -l /tmp ¦ wc -l suffice and will it be accurate? second one: How would i check the number of files with a certain string in the filename, in the same directory. ... (2 Replies)
Discussion started by: iamalex
2 Replies

2. UNIX for Dummies Questions & Answers

Number of items in a directory

This should be so simple.. I have folder with about 27 subfolders in it, each folder has a number of fonts in it.. how do I get the total number of fonts for all subfolders? (2 Replies)
Discussion started by: glev2005
2 Replies

3. Shell Programming and Scripting

Counting items in variables, How come this works, However

Hi All, To start with, I have been reading this site for years, Unfortunately I do not consider myself versed well enough with scripts to provide useful help to others. The Blind cannot lead the Blind! Many of you have provided me with brain food and solutions over the years without even... (4 Replies)
Discussion started by: Festus Hagen
4 Replies

4. Programming

Finding the number of bits a executable was compiled

Hi, Can anyone tell me how to find out how many bits a c executable was compiled in? I am trying to do some investigation of running 32bit programs in 64bit systems. (1 Reply)
Discussion started by: Leion
1 Replies

5. UNIX for Dummies Questions & Answers

Counting number of folders in a Directory

Help Needed ! Can we count number of folders of specific date in a directory, even if directory has folders of different dates. Please reply as soon as possible. (1 Reply)
Discussion started by: vishal_215
1 Replies

6. Shell Programming and Scripting

awk, help me - counting items and listing them

This is my first ever post... please help! :o I have two columns....here is part of the file... 12, 46798 6692, 46799 5710, ... (3 Replies)
Discussion started by: pelhabuan
3 Replies

7. Shell Programming and Scripting

counting the number of characters in the filename of all files in a directory?

I am trying to display the output of ls and also print the number of characters in EVERY file name. This is what I have so far: #!/bin/sh for x in `ls`; do echo The number of characters in x | wc -m done Any help appreciated (1 Reply)
Discussion started by: LinuxNubBrah
1 Replies

8. Shell Programming and Scripting

Counting the number of files within a directory input by the user

So I have a loop that stated if a directory exists or not. If it does it prints the number of files within that directory. I use this code... result=`(ls -l . | egrep -c '^-')` However, no matter which directory I input, it outputs the number "2" What is wrong here? (4 Replies)
Discussion started by: itech4814
4 Replies

9. What is on Your Mind?

Number of Small Forum Code Changes (TODO List Items)

In the past few days have I have done a lot of code cleanup work in various categories, including faster page loading and bug fixes: Move countless inline style directives to external CSS stylesheets for key pages (faster page loading) Fixed bug in member panel going between desktop and... (6 Replies)
Discussion started by: Neo
6 Replies
CD-READ(1)							   User Commands							CD-READ(1)

NAME
cd-read - reads Information from a CD or CD-image SYNOPSIS
cd-read [OPTION...] DESCRIPTION
-a, --access-mode=STRING Set CD control access mode -m, --mode=MODE-TYPE set CD-ROM read mode (audio, auto, m1f1, m1f2, m2mf1, m2f2) -d, --debug=INT Set debugging to LEVEL -x, --hexdump Show output as a hex dump. The default is a hex dump when output goes to stdout and no hex dump when output is to a file. -j, --just-hex Don't display printable chars on hex dump. The default is print chars too. --no-header Don't display header and copyright (for regression testing) --no-hexdump Don't show output as a hex dump. -s, --start=INT Set LBA to start reading from -e, --end=INT Set LBA to end reading from -n, --number=INT Set number of sectors to read -b, --bin-file[=FILE] set "bin" CD-ROM disk image file as source -c, --cue-file[=FILE] set "cue" CD-ROM disk image file as source -i, --input[=FILE] set source and determine if "bin" image or device -C, --cdrom-device[=DEVICE] set CD-ROM device as source -N, --nrg-file[=FILE] set Nero CD-ROM disk image file as source -t, --toc-file[=FILE] set "TOC" CD-ROM disk image file as source -o, --output-file=FILE Output blocks to file rather than give a hexdump. -V, --version display version and copyright information and exit Help options: -?, --help Show this help message --usage Display brief usage message AUTHOR
Rocky Bernstein <rocky@gnu.org> COPYRIGHT
Copyright (C) 2003-2005, 2007-2008, 2011-2013 R. Bernstein This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICU- LAR PURPOSE. Have driver: GNU/Linux ioctl and MMC driver Have driver: cdrdao (TOC) disk image driver Have driver: bin/cuesheet disk image driver Have driver: Nero NRG disk image driver Default CD-ROM device: /dev/sr0 SEE ALSO
cd-info(1) for information about a CD; cd-drive(1) for CD-ROM characteristics; iso-read(1) for information about an ISO-9660 image. cd-read version 0.92 December 2013 CD-READ(1)
All times are GMT -4. The time now is 04:17 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy