- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Need "find" command arguments to seek our ASCII/T...
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
03-15-2007 02:43 AM
03-15-2007 02:43 AM
The idea is to seek out ASCII/TEXT files that are hugely compressible and flag/compress them.
Points will be aptly rewarded.
Solved! Go to Solution.
- Tags:
- find
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2007 02:54 AM
03-15-2007 02:54 AM
Re: Need "find" command arguments to seek our ASCII/TEXT files that...
cd to desired starting directory then:
#!/usr/bin/sh
find . -type f -mtime +30 -size +10240 | while read F
do
file "${F}" | grep -i -q "text"
STAT=${?}
if [[ ${STAT} -eq 0 ]]
then
rm "${F}"
fi
done
-----------------------------------------
I would replace the 'rm "${F}"' with 'ls -l "${F}"' until satified with the filters.
We are leveraging the file commands output to determine if the file is a textfile.
The -q option of grep suppresses output. We are only interested in the exit status which is 0 if a pattern match occurs.
- Tags:
- file
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2007 03:11 AM
03-15-2007 03:11 AM
Re: Need "find" command arguments to seek our ASCII/TEXT files that...
I was hoping for a command line wizardry.. i.e Perl.
I do have a script already...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2007 03:17 AM
03-15-2007 03:17 AM
Re: Need "find" command arguments to seek our ASCII/TEXT files that...
# perl -MFile::Find -le 'find(sub{print $File::Find::name if -f $_ && -T $_},@ARGV)' /path
Regards!
...JRF...
- Tags:
- Perl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2007 03:29 AM
03-15-2007 03:29 AM
Re: Need "find" command arguments to seek our ASCII/TEXT files that...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2007 04:54 AM
03-15-2007 04:54 AM
SolutionOoops, sorry, I forgot to add the 30-day criteria to my first offering :-))
# perl -MFile::Find -le 'find(sub{print $File::Find::name if -f $_ && -T _ && -M _ >= 30}, @ARGV)' /path
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2007 11:59 PM
03-15-2007 11:59 PM
Re: Need "find" command arguments to seek our ASCII/TEXT files that...
I owe you a better job of reading (ECANTREAD)! For the record, here's the inclusion of the size criteria:
# perl -MFile::Find -le 'find(sub{print $File::Find::name if -f $_ && -T _ && -M _ >= 30 && -s >= (5*1024*1024)}, @ARGV)' /path
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2007 02:24 AM
03-16-2007 02:24 AM
Re: Need "find" command arguments to seek our ASCII/TEXT files that...
by ksh:
find . -type f -mtime +30 -size +10240| xargs file|grep "ascii"|cut -d":" -f1
HTH,
Art