- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Find all ascii text files
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
01-14-2004 06:43 AM
01-14-2004 06:43 AM
I see the find command will let me limit the search to regular files, but that would be too broad of a search.
Scott
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2004 06:48 AM
01-14-2004 06:48 AM
Re: Find all ascii text files
I think the find command is your only hope. You can break it down to a find command for each file system or something to reduce the size of the task, but I know of no other way. "find /start_dir -type f |xargs grep "command" > /tmp/find_start_dir.output
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2004 06:48 AM
01-14-2004 06:48 AM
Re: Find all ascii text files
find / -type f
Do a
man find
for more info.
Rgds...Geofff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2004 07:00 AM
01-14-2004 07:00 AM
Re: Find all ascii text files
First I would find all files (find -type f), create a list, and then run the file command on each file to make sure it isn't a binary /executable of some sort. Then from that list you could execute your grep.
# find /dir -type f -print >> /tmp/list
# for i in $(cat list)
do
VAR=$(file $i | grep text | wc -l)
if [ $VAR = 1 ] ; then
COMM=$(grep sometext $i | wc -l)
if [ $COMM = 1] ; then
echo "Command found in $i"
fi
fi
done
The above is not guaranteed to work, but hopefully you get the idea.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2004 07:09 AM
01-14-2004 07:09 AM
Re: Find all ascii text files
Enjoy, Have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2004 07:10 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2004 07:12 AM
01-14-2004 07:12 AM
Re: Find all ascii text files
from 'man perlfunc:
-f File is a plain file.
-d File is a directory.
-l File is a symbolic link.
-p File is a named pipe (FIFO), or Filehandle is a pipe.
-S File is a socket.
-b File is a block special file.
-c File is a character special file.
-t Filehandle is opened to a tty.
-u File has setuid bit set.
-g File has setgid bit set.
-k File has sticky bit set.
-T File is an ASCII text file (heuristic guess).
-B File is a "binary" file (opposite of -T).
-M Script start time minus file modification time, in days.
-A Same for access time.
-C Same for inode change time (Unix, may differ for other pl
atforms)
Enjoy, Have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2004 07:14 AM
01-14-2004 07:14 AM
Re: Find all ascii text files
(where "cmd" is the command you want to grep for)
grep "cmd" `find . -type f -exec file {} \; |grep -v jpg |grep -v gif
|grep -v outfile.txt |grep text |awk -F: '{print $1}'` >outfile.txt
Sometimes jpg and gif show up as "text", so we have to ignore.
There may be others, but those two stuck out.