Sponsored Content
Top Forums Shell Programming and Scripting executing command from subdirectories Post 302358207 by adderek on Thursday 1st of October 2009 04:38:33 PM
Old 10-01-2009
Maybe use this?

Code:
function my_function
{
    for file_or_directory in *;do
        [[ -d "${file_or_directory}" ]] && {
            cd "${file_or_directory}"
            count_files_in_any_way_since_there_are_many_ways
            cd "${OLDPWD}"
            my_function
        }
    done
    return 0
}


Last edited by pludi; 10-03-2009 at 04:12 PM.. Reason: code tags please
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

get command to ftp subdirectories at once

How do I use the "get" command in unix to ftp a directory with many sudirectories at one shot? Any idea anyone?? (3 Replies)
Discussion started by: lydiaEd
3 Replies

2. Shell Programming and Scripting

Executing a command at startup

Hey all, How do I execute a file at startup automatically. From what I've read is that I need to put it into my .bashrc file. I'm not sure where to go from there. Can I just type commands into that and they'll run next time I restart my server? Right now I have added these lines: cd... (2 Replies)
Discussion started by: NathanWarden
2 Replies

3. UNIX for Dummies Questions & Answers

ls command to list recursively ONLY subdirectories

:confused: ls -dlRr I've tried different combinations of the ls command using the above-mentioned options but none of them are giving me the output I am looking for. Objective: To get a recursive listing of all subdirectories from a particular starting point. For example, if my starting... (5 Replies)
Discussion started by: HLee1981
5 Replies

4. UNIX for Dummies Questions & Answers

Doing a capture while another command is executing?

Basically what i'm trying to do is execute an update command and at the same time have the system do a TCPdump to file for that update traffic. So I would like to connect the two commands so that the tcpdump terminates automatically when the update finishes/fails/whatever. Right now I have... (0 Replies)
Discussion started by: MrEddy
0 Replies

5. UNIX for Dummies Questions & Answers

Command for total number of files (and size) across subdirectories?

Hi all... I have a directory called dbrn. This directory contains an unknown number of subdirectories which in turn contain an unknown number of files. What I want to know is: How many files with extention .ABC can be found in /dbrn across all subdirecties, and what is the total size for... (9 Replies)
Discussion started by: Beun
9 Replies

6. Shell Programming and Scripting

Error while executing sh command

Hi, I have 2 files temp1.sh and temp2.sh as follows: =========== temp1.sh =========== echo "session1" sh temp2.sh echo "exit session2 and enter session1" ================================= ============= temp2.sh ============= echo "session2" sh echo "exit session2"... (5 Replies)
Discussion started by: RP09
5 Replies

7. Shell Programming and Scripting

Find command to search files in a directory excluding subdirectories

Hi Forum, I am using the below command to find files older than x days in a directory excluding subdirectories. From the previous forums I got to know that prune command helps us not to descend in subdirectories. Though I am using it here, not getting the desired result. cd $dir... (8 Replies)
Discussion started by: jhilmil
8 Replies

8. Shell Programming and Scripting

Executing a command line in a directory and its subdirectories

I'm finally about to make the jump from PHP's mysql driver to the newer mysqli one using the mysqli converter tool. The tool is called by this command line: php /usr/share/nginx/html/rather/converter/cli.php -d -p ".php,.shtml,.inc" -u -b -v -w >> /tmp/convert.log e.g. at the web root:... (2 Replies)
Discussion started by: dheian
2 Replies

9. UNIX for Dummies Questions & Answers

UNIX - command to count number of files in subdirectories

I have a folder named test/ and under that I have multiple directories and in each of the directory I have multiple log files. I want to know how many files exists under each sub directory. test |--quanrantine |--logfile1 |--logfile2 |--spooling |--logfile1 ... (4 Replies)
Discussion started by: ravikirankethe
4 Replies

10. UNIX for Beginners Questions & Answers

UNIX command to display Owner,Group,Root and Subdirectories list

Hi Team, Am a newbie to Unix. As I would like to see the Server Name,Owner Name ( not numeric form), Group Name ( not numeric ID), ROOT path. I would like to send this list as an attachment to my personal mail. Can any one please help me out to to resolve this . Here is the sample result... (6 Replies)
Discussion started by: vasuvv
6 Replies
ERR(3)							   BSD Library Functions Manual 						    ERR(3)

NAME
err, verr, errc, verrc, errx, verrx, warn, vwarn, warnc, vwarnc, warnx, vwarnx, err_set_exit, err_set_file -- formatted error messages LIBRARY
Standard C Library (libc, -lc) SYNOPSIS
#include <err.h> void err(int eval, const char *fmt, ...); void err_set_exit(void (*exitf)(int)); void err_set_file(void *vfp); void errc(int eval, int code, const char *fmt, ...); void errx(int eval, const char *fmt, ...); void warn(const char *fmt, ...); void warnc(int code, const char *fmt, ...); void warnx(const char *fmt, ...); #include <stdarg.h> void verr(int eval, const char *fmt, va_list args); void verrc(int eval, int code, const char *fmt, va_list args); void verrx(int eval, const char *fmt, va_list args); void vwarn(const char *fmt, va_list args); void vwarnc(int code, const char *fmt, va_list args); void vwarnx(const char *fmt, va_list args); DESCRIPTION
The err() and warn() family of functions display a formatted error message on the standard error output, or on another file specified using the err_set_file() function. In all cases, the last component of the program name, a colon character, and a space are output. If the fmt argument is not NULL, the printf(3)-like formatted error message is output. The output is terminated by a newline character. The err(), errc(), verr(), verrc(), warn(), warnc(), vwarn(), and vwarnc() functions append an error message obtained from strerror(3) based on a supplied error code value or the global variable errno, preceded by another colon and space unless the fmt argument is NULL. In the case of the errc(), verrc(), warnc(), and vwarnc() functions, the code argument is used to look up the error message. The err(), verr(), warn(), and vwarn() functions use the global variable errno to look up the error message. The errx() and warnx() functions do not append an error message. The err(), verr(), errc(), verrc(), errx(), and verrx() functions do not return, but exit with the value of the argument eval. It is recom- mended that the standard values defined in sysexits(3) be used for the value of eval. The err_set_exit() function can be used to specify a function which is called before exit(3) to perform any necessary cleanup; passing a null function pointer for exitf resets the hook to do nothing. The err_set_file() function sets the output stream used by the other functions. Its vfp argument must be either a pointer to an open stream (possibly already converted to void *) or a null pointer (in which case the output stream is set to standard error). EXAMPLES
Display the current errno information string and exit: if ((p = malloc(size)) == NULL) err(EX_OSERR, NULL); if ((fd = open(file_name, O_RDONLY, 0)) == -1) err(EX_NOINPUT, "%s", file_name); Display an error message and exit: if (tm.tm_hour < START_TIME) errx(EX_DATAERR, "too early, wait until %s", start_time_string); Warn of an error: if ((fd = open(raw_device, O_RDONLY, 0)) == -1) warnx("%s: %s: trying the block device", raw_device, strerror(errno)); if ((fd = open(block_device, O_RDONLY, 0)) == -1) err(EX_OSFILE, "%s", block_device); Warn of an error without using the global variable errno: error = my_function(); /* returns a value from <errno.h> */ if (error != 0) warnc(error, "my_function"); SEE ALSO
exit(3), fmtmsg(3), printf(3), strerror(3), sysexits(3) STANDARDS
The err() and warn() families of functions are BSD extensions. As such they should not be used in truly portable code. Use strerror() or similar functions instead. HISTORY
The err() and warn() functions first appeared in 4.4BSD. The err_set_exit() and err_set_file() functions first appeared in FreeBSD 2.1. The errc() and warnc() functions first appeared in FreeBSD 3.0. BSD
March 29, 2012 BSD
All times are GMT -4. The time now is 09:31 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy