The above will remove all empty directories from the current directory.
To clarify this, the rmdir command should fail if the directory isn't empty. So by ignoring error messages (redirecting them to a black hole, /dev/null), you will successfully delete the empty ones and the non-empty ones shouldn't be in any danger.
It would probably be a good idea to put dummy data into a directory and try to use rmdir on it, just to make sure your environment behaves this way. But it's the default, so it should be fine.
Hi
how to check input is "empty" and "numeric" in ksh?
e.g:
./myscript.ksh k
output show: invalid number input
./myscript.ksh
output show: no input
./myscript.ksh 10
output show: input is numeric (6 Replies)
Hey there!
I try to use 'find' to remove empty directories like this:
find . -depth -type d -empty -exec rm -rf {} ';'
It works just fine, but there are some directories i want to exclude.
So i tried to do sth like this:
find . -depth -type d -empty -exec grep -v "not this one please" -exec... (5 Replies)
Dear friends,
please tell me how to find the files which are existing in the current directory, but it sholud not search in the sub directories..
it is like this,
current directory contains
file1, file2, file3, dir1, dir2
and dir1 conatins
file4, file5
and dir2 contains
file6,... (9 Replies)
Hi,
I have line in input file as below:
3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL
My expected output for line in the file must be :
"1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL"
Can someone... (7 Replies)
I want to list all files/lines which except those which contain the pattern ' /proc/' OR ' /sys/' (mind the leading blank).
In a first approach I coded:
find / -exec ls -ld {} | grep -v ' /proc/| /sys/' \; > /tmp/list.txt
But this doesn't work. I got an error (under Ubuntu):
grep:... (5 Replies)
How can I recursively find all files in a directory and print out the file and first line number of any text blocks that match the below cases?
This would seem to involve find, xargs, *grep, regex, etc.
In summary, I want to find so-called empty "try-catch blocks" that do not contain code... (0 Replies)
I have a bunch of random character lines like ABCEDFG. I want to find all lines with "A" and then change any "E" to "X" in the same line. ALL lines with "A" will have an "X" somewhere in it. I have tried sed awk and vi editor. I get close, not quite there. I know someone has already solved this... (10 Replies)
How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address
and column 3 contains “cc” e-mail address to include with same email.
Sample input file, email.txt
Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies
LEARN ABOUT HPUX
rmdir
rmdir(1) General Commands Manual rmdir(1)NAME
rmdir - remove directories
SYNOPSIS
dir ...
DESCRIPTION
removes the directory entry for each dir operand that refers to an empty directory.
Directories are removed in the order specified. Consequently, if a directory and a subdirectory of that directory are both specified as
arguments, the subdirectory must be specified before the parent directory so that the parent directory will be empty when tries to remove
it. Removal of a directory requires write and search (execute) permission in its parent directory, but no permissions on the directory
itself; but if the sticky bit is set on the parent directory, only the owner of the directory, the owner of the parent directory, or a user
having appropriate privileges can remove the directory.
Options
recognizes the following options:
Force each directory to be removed without prompting for
confirmation, regardless of the presence of the option. This option also suppresses diagnostic messages regarding non-exis-
tent operands.
This option does not suppress any diagnostic messages other than those regarding non-existent operands. To suppress all
error message and interactive prompts, the option should be used while redirecting the standard error output to
This option ignores any previous occurrence of the option.
Write a prompt to the standard error output requesting confirmation
before removing each directory.
This option ignores any previous occurrence of the option.
Path removal.
If, after removing a directory with more than one pathname component, the parent directory of that directory is now empty,
removes the empty parent directory. This continues until encounters a non-empty parent directory, or until all components of
the original pathname have been removed.
When used in conjunction with the option, asks whether to remove each directory component of a path.
EXTERNAL INFLUENCES
Environment Variables
provides a default value for the internationalization variables that are unset or null. If is unset or null, the default value of "C" (see
lang(5)) is used. If any of the internationalization variables contains an invalid setting, will behave as if all internationalization
variables are set to "C". See environ(5).
If set to a non-empty string value, overrides the values of all the other internationalization variables.
determines the interpretation of dir names as single and/or multi-byte characters, the classification of characters as printable, and the
characters matched by character class expressions in regular expressions.
determines the locale that should be used to affect the format and contents of diagnostic messages written to standard error and informa-
tive messages written to standard output.
determines the location of message catalogues for the processing of
International Code Set Support
Single- and multi-byte character code sets are supported.
DIAGNOSTICS
Generally self-explanatory. Note that the option does not suppress all diagnostic messages.
EXAMPLES
To remove directories with a prompt for verification:
directories
To remove as much as possible of a path, type:
SEE ALSO rm(1), rmdir(2), stat(2).
STANDARDS CONFORMANCE
rmdir: SVID2, XPG2, XPG3, XPG4
rmdir(1)