You do not need to cd into each directory in turn, you can specify the full path, this is also safer in that if the cd failed the find would have still run, e.g.:
You can replace:
Quote:
-print | xargs /bin/rm -rf
with
The -r would do a recursive delete which should not need to apply to a file, the -f may still be necessary depending on the permissions on the files you are deleting.
If you must cd into each directory first then do:
So that if the cd fails then the find does not run.
Hello,
How do I navigate to the level ABOVE the home directory?
I have the following structure on my drive, bearing in my I'm using a cygwin port on Windows.
C:\
C:\cygwin
C:\cygwin\bin
C:\cygwin\otherfolders
C:\cygwin\home (the home directory)
C:\cygwin\home\H (my user directory)
... (4 Replies)
I am trying to install some applications, on my linux OS and all the instructions are tell me that ill have to navigate to the directories and type the link that they provide, but i try typing 'dir' which shows me the directories but to access a particular one i can't remember how??? can anyone... (2 Replies)
Hi I need to write a shell script which basically searches for all the empty files within the directory structure, lists them before asking the user to confirm if they would like to delete them. If the user deletes the file then a notice would appear confirming the file is deleted.
I've be... (5 Replies)
i have a user 'bart' which does not belong to apps group (as shown below) and i want him to be able to navigate to TEST directory.. i gave him read access but he cannot get through. when i added execute permission he was able to navigate to TEST
drwxr-xr-- 3 draco apps 4096 Apr... (2 Replies)
Hello,
I just saw that on my vps (centOS) my oscommerce with a seo script
has created millions of tmp files inside the /html/cache/ directory.
I would need to remove all those files (millions), I tried via shell but the vps
loads goes to very high and it hangs, is there some way to do a... (7 Replies)
Hi Team,
I have thousands of TIF files which are converted from PDF. Below is a sample of it.
LH9406_BLANCARAMOS_2012041812103210320001.tif
LH9406_BLANCARAMOS_2012041812103210320002.tif
LH9406_BLANCARAMOS_2012041812103210320003.tif
LH9411_ANGENIAHUTCHINSON_2012041812102510250001.tif... (9 Replies)
Hi All,
Am new to both Unix & this Forum - Need some help on a script that I am trying to write:
In a Directory i have few text files which might or might not contain some text that I am trying to find.
Once that text is found in any of the files, it needs to be removed from the file
... (6 Replies)
Hi,
Currently i'm logging as a user say atgdev. When I login it takes me to directory /.
I see the home directory set as /home/atgdev/
I want that when i log in it shud directly go to my home directory i.e /home/atgdev/.
I thought .profile in /home/atgdev/ will be invoked first when i log... (9 Replies)
Hi Folks,
There is a job which generates a .zip files every day at /usr/app/generated directory , now please advise for the script that will delete this zip files permanently.but while deleting it should make sure that it will not delete the last two days recently generated zip files and this... (1 Reply)
Hi ,
i am a new user to this forum can anyone please help me in navigation for this forum.
also when i am trying to open any thread i am getting below error.
Bad Request
Your browser sent a request that this server could not understand.]
Thanks. (1 Reply)
Discussion started by: nkchand
1 Replies
LEARN ABOUT DEBIAN
realpath
REALPATH(1) Debian REALPATH(1)NAME
realpath - return the canonicalised absolute pathname
SYNOPSIS
realpath [-s|--strip] [-z|--zero] filename ...
realpath --h|--help
realpath --v|--version
DESCRIPTION
realpath converts each filename argument to an absolute pathname, which has no components that are symbolic links or the special . or ..
directory entries. (See realpath(3) for more information.)
Each path component in the filename must exist, otherwise realpath will fail and non-zero exit status will be returned.
Please note that mostly the same functionality is provided by the `-e' option of the readlink(1) command.
When the -s option is used realpath only removes the . and .. directories, but not symbolic links from filename. If the given filename
argument is relative (i.e. does not start with `/'), realpath -s prepends to it the current directory name as obtained from the getcwd(2)
system call before further processing.
Each converted pathname is output to the standard output, on its own line.
OPTIONS -s, --strip
Only strip . and .., components, but do not resolve symbolic links.
-z, --zero
Separate output filenames with the null character instead of newline, so it can be used with the `-0' option of xargs(1).
-h, --help
Print short usage information.
-v, --version
Show realpath's version number.
EXAMPLES
For the examples below let's suppose that /usr/bin/X11 is a symbolic link, pointing to directory /usr/bin.
Example 1
Regardless of what the current directory is
realpath /../usr/bin/X11/./xterm
prints
/usr/bin/xterm
but
realpath -s /../usr/bin/X11/./xterm
outputs
/usr/bin/X11/xterm
Example 2
When the current directory is /usr/bin/X11 (which is still a symbolic link to /usr/bin), the output of both
realpath ./xterm
and
realpath -s ./xterm
will be
/usr/bin/xterm
Example 3
Providing that the current directory is /home/user (and the directory exists before and during the realpath run), the command
realpath ../path/to/some/./non-existent/./directory/../or/../file
will fail with the following error
../path/to/some/./non-existent/./directory/../or/../file: No such file or directory
but
realpath -s ../path/to/some/./non-existent/./directory/../or/../file
will return
/home/path/to/some/non-existent/file
EXIT STATUS
realpath returns a zero exit code when all pathnames were successfully converted.
In case of any errors (e.g. missing or unavailable directories in the path), realpath prints error message to stderr and returns a non-zero
exit code.
SEE ALSO basename(1), dirname(1), readlink(1), chase(1), realpath(3)BUGS
Hopefully none :)
If you find some, please report them via the normal Debian bug reporting system, see the file /usr/share/doc/debian/bug-reporting.txt in
the package doc-debian or the reportbug(1) man page.
AUTHOR
Originally written by Lars Wirzenius <liw@iki.fi>, as a part of the dwww package. Robert Luberda <robert@debian.org> currently maintains
and extends it.
realpath is licensed via the GNU General Public License. While it has been written for Debian, porting it to other systems is strongly
encouraged.
Debian October 16th, 2011 REALPATH(1)