- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Various definitions of UX commands
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2007 09:15 PM
07-03-2007 09:15 PM
In this thread, I shall keep asking few basic ux command's questions.
Whats the difference in:
find . -mtime +60 -exec rm -f {} \;
and
find . -mtime +60 | xargs rm 2>/dev/null
Thank you!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2007 09:23 PM
07-03-2007 09:23 PM
Re: Various definitions of UX commands
Functionally I see no difference.
They are both supposed to erase files over 60 days since last modification.
The real difference is how the output is handled.
Have you tested them? Do they work differently?
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2007 09:24 PM
07-03-2007 09:24 PM
Re: Various definitions of UX commands
$ find . -mtime +60 -exec rm -f {} +
This has the advantage of xargs in doing more one file at a time (using ";") and it doesn't need xargs.
Your find -exec ... \; above invokes rm once per file.
Another differences is that your xargs command was missing -f and had an extra redirect of stderr.
You may want to fix them to add "-type f" so you only find files.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2007 09:35 PM
07-03-2007 09:35 PM
Re: Various definitions of UX commands
The -exec spawns a separate process for each file or directory, where xargs groups and collects, resulting in fewer processes.
If you want to use the -exec you should use the + delimiter insted of the ; this will work identical with the xargs.
find . -mtime +60 -exec rm -f {} \+
You will find some information about this in the man pages for find.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2007 09:48 PM
07-03-2007 09:48 PM
Re: Various definitions of UX commands
find . -mtime +60 -exec rm -f {} \+
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2007 09:52 PM
07-03-2007 09:52 PM
Re: Various definitions of UX commands
What is it suppose to do?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2007 10:07 PM
07-03-2007 10:07 PM
Re: Various definitions of UX commands
1)
Is it correct?
find . -follow -type f \( -name "core*" -a -mtime +0 \) -exec rm {} \;
What will follow do here?
2) Is it correct?
find /global/mfg/home/*/archive -follow -type f \( -name "*" -a -mtime +30 \) -exec rm {} \;
3) What is the differnce for ending command with {} \; and {}+ Also, what is the significance of {}?
4) /usr/bin/rm $(/usr/bin/ls -t /home/root/core* | /usr/bin/tail +2)
What is it suppose to do?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2007 10:50 PM
07-03-2007 10:50 PM
SolutionThe proper syntax is just: -exec rm -f {} +
(There is no need for "\", contrary to the broken documentation.)
The "{} +" tells find to batch up as many args as will fit.
>command: /usr/bin/rm $(/usr/bin/ls -t /home/root/core* | /usr/bin/tail +2)
This says remove the files returned by $(...). This lists all of the files core*, and skips the latest.
>1)find . -follow -type f \( -name "core*" -a -mtime +0 \) -exec rm {} \;
>What will -follow do here?
It will follow symlinks.
Note: No need for () and -a, since the default is AND.
>2) Is it correct?
find /global/mfg/home/*/archive -follow -type f \( -name "*" -a -mtime +30 \) -exec rm {} \;
Probably not. No need for -name "*".
>3) What is the difference for ending command with {} \; and {}+ Also, what is the significance of {}?
Using "{} +" will batch up files to execute the same command with as many as will fit.
The "{}" is an indication where -exec should insert the filenames it finds. For the "+" case it is required by Posix but HP-UX allows you to leave it out, unless you are doing UNIX 2003 branding, where "{}" is required.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2007 12:41 AM
07-04-2007 12:41 AM
Re: Various definitions of UX commands
find . -follow -type f -mtime +0 -exec ll {} \;
IF i understand correctly, above will only list files which are symbolic links , or will it print all files. See here:
a300sl57:/prod_wrk/pp> ll h
lrwxrwxrwx 1 mfgeb qad 1 2007-07-04 05:57 h -> g
a300sl57:/prod_wrk/pp> find . -follow -type f -mtime +0 -exec ls -l {} \;
find: ./h: No such file or directory
-rw-rw-r-- 1 mfgeb qad 0 2007-01-26 15:44 ./a.txt
-rw-rw-r-- 1 mfgeb qad 0 2007-01-26 15:45 ./b.txt
a300sl57:/prod_wrk/pp>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2007 12:58 AM
07-04-2007 12:58 AM
Re: Various definitions of UX commands
a300sl57:/prod_wrk/pp> find . -follow -type f -mtime +0 -exec ls -l {} \;
-rw-rw-r-- 1 mfgeb qad 0 2007-01-26 15:44 ./g
lrwxrwxrwx 1 mfgeb qad 1 2007-07-04 05:57 ./h -> g
-rw-rw-r-- 1 mfgeb qad 0 2007-01-26 15:44 ./a.txt
-rw-rw-r-- 1 mfgeb qad 0 2007-01-26 15:45 ./b.txt
a300sl57:/prod_wrk/pp>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2007 01:04 AM
07-04-2007 01:04 AM
Re: Various definitions of UX commands
> find . -follow -type f -mtime +0 -exec ll {} \;
> IF i understand correctly, above will only list files which are symbolic links , or will it print all files. See here:
By adding '-follow' you will list files that are referenced by symbolic links in the directory in which you are searching. If omitted, symbolic links in the directory that you are searching will NOT be resolved.
Consider:
# mkdir /tmp/dummy && cd /tmp/dummy
# touch f1 f2 f3
# touch /var/tmp/removeme
# find . -type f -exec ll {} \;
-rw-r----- 1 root sys 0 Jul 4 08:57 ./f1
-rw-r----- 1 root sys 0 Jul 4 08:57 ./f2
-rw-r----- 1 root sys 0 Jul 4 08:57 ./f3
# find . -follow -type f -exec ll {} \;
-rw-r----- 1 root sys 0 Jul 4 08:57 ./f1
-rw-r----- 1 root sys 0 Jul 4 08:57 ./f2
-rw-r----- 1 root sys 0 Jul 4 08:57 ./f3
lrwxr-x--- 1 root sys 17 Jul 4 08:57 ./linktovar -> /var/tm
p/removeme
The '-type' switch can take various arguments : "f" for files; "d" for directories; and "l" for symbolic links.
By choosing "f" you limit yourself only to FILES but by adding '-follow' you FOLLOW any symbolic links and report FILES that they represent.
Regards!
...JRF...