Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Script to find file types and info Post 303039874 by Neo on Wednesday 16th of October 2019 08:49:02 PM
Old 10-16-2019
If you only need the file names, with PHP you can use scandir() to scan the entire web directory and put all the file names in array and filter the array based on the extensions. However, if you need more info than just the filename / extension, scandir() will not provide the ownership and permissions, information.

In that case, if I was doing this, I would simply exec() a variation of the ls -lR comand in a PHP script and put each entry (file information) into an array, and then filter the array as needed.

Of course, you don't need PHP to do this, but since your are using a web server which has PHP already, you might enjoy taking the output (your file inventory) and displaying your inventory results on a web page in addition to a CSV file Smilie


See also PHP: fputcsv()

Code:
fputcsv ( resource $handle , array $fields [, string $delimiter = "," [, string $enclosure = '"' [, string $escape_char = "\\" ]]] ) : int

Quote:
fputcsv() formats a line (passed as a fields array) as CSV and writes it (terminated by a newline) to the specified file handle.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

find directory with 2 types of files

Trying to use the find command to find any directory which contains a file ending in .zip AND a file ending in .o I'm having trouble specifying multiple files as criteria and have can't seem to figure it out from Unix in a Nutshell and Google. (2 Replies)
Discussion started by: dangral
2 Replies

2. Shell Programming and Scripting

find multiple file types and tar

There are these ksh files and config files that are written and updated on a daily basis. All I want to do is write a script that finds both these types of files and archive them on a daily basis, to help in restoring in times of system outages and so on. Particulary I'm interested in .ksh ,... (9 Replies)
Discussion started by: manthasirisha
9 Replies

3. Shell Programming and Scripting

trying to write a script to loop through a port info file

Below is part of a script i have written to loop through part of a port info file. How do i continue the script to get info for OS Device Name, manufacturer and then put information into an array? HBA Port WWN: 10000000c9420b4b OS Device Name: /dev/cfg/c10 Manufacturer: Emulex... (5 Replies)
Discussion started by: rcon1
5 Replies

4. Linux

Simplified find command to find multiple file types

Hi, I'm using the following command to find the multiple requierd file types and its working fine find . -name "*.pl" -o -name "*.pm" -o -name "*.sql" -o -name "*.so" -o -name "*.sh" -o -name "*.java" -o -name "*.class" -o -name "*.jar" -o -name "*.gz" -o -name "*.Z" -type f Though... (2 Replies)
Discussion started by: vickramshetty
2 Replies

5. Shell Programming and Scripting

How to pass multiple file types search pattern as argument to find?

How can I pass $var_find variable as argment to find command? test.sh var_find=' \( -name "*.xml" -o -name "*.jsp" \) ' echo "${var_find}" find . -type f ${var_find} -print # Below statement works fine.. I want to replace this with the above.. #find . \( -name "*.xml" -o -name... (4 Replies)
Discussion started by: kchinnam
4 Replies

6. UNIX for Dummies Questions & Answers

How to find the partition types in linux

How do we find the partition type in Linux? df -T will give me the mounted partition types like ufs, ext3 etc. How do I find out for say a newly added disk to the system? Please advise... Thanks (2 Replies)
Discussion started by: lubu
2 Replies

7. Shell Programming and Scripting

bash: find multiple types[solved]

Hi, I would like to use find to search for multiple types. For example search for symlink and regular file but not directories, sockets etc.... Something like: find . -type l,f -name "stuff" But of course it does not work. Is there any way to avoid an if statement and to do it faster? ... (0 Replies)
Discussion started by: Dedalus
0 Replies

8. Shell Programming and Scripting

Script to loop line in a file and add info or do echo

I have a record.txt it will update weekly, and it could be 2 lines or more ... it just echo each line to the script san jose,23.34% tampa,2.15% dallas,30.20% seattle,44.29% Unknown,16.72% How do i write a shell script to give me a test.pl or bash file which contain #!/home/perl... (8 Replies)
Discussion started by: sabercats
8 Replies

9. Shell Programming and Scripting

Using a single "find" cmd to search for multiple file types and output individual files

Hi All, I am new here but I have a scripting question that I can't seem to figure out with the "find" cmd. What I am trying to do is to only have to run a single find cmd parsing the directories and output the different file types to induvidual files and I have been running into problems.... (3 Replies)
Discussion started by: swaters
3 Replies

10. Shell Programming and Scripting

Backup script with selective file types only

i am looking for a backup script to be run in ssh which can move all *.php files only to a archive Eg. a folder has 5 sub folders with different file types, which can be mix of PDF, jpeg, gif etc etc. but the archive generated should only include the *.php files without breaking the directory... (3 Replies)
Discussion started by: netatma
3 Replies
xfsinvutil(8)                                                 System Manager's Manual                                                xfsinvutil(8)

NAME
xfsinvutil - xfsdump inventory database checking and pruning utility SYNOPSIS
xfsinvutil [-F|-i] [-m media_label] -M mount_point mm/dd/yyyy xfsinvutil [-F|-i] [-m media_label] -u UUID mm/dd/yyyy xfsinvutil [-F] -s SESSION_ID xfsinvutil -i xfsinvutil -C DESCRIPTION
xfsdump maintains an online dump inventory in /var/lib/xfsdump/inventory. The -I option of xfsdump displays the inventory contents hierar- chically. The levels of the hierarchy are: filesystem, dump session, stream, and media file. xfsinvutil is a utility to check this inventory database for consistency, to remove entries of dump sessions which may no longer be of rel- evance, and to browse the contents of the inventory. The following command line options are available: -F Don't prompt the operator. When xfsinvutil encounters a matching dump session, xfsinvutil will normally ask the operator for permis- sion to delete the entry. With this option the deletion is performed, no questions asked. -i Interactive mode. Causes xfsinvutil to run in a mode that will allow the operator to browse and modify the contents of the inventory. Please refer to the Interactive Mode section below for more information. -M mount_point mm/dd/yyyy Prunes dump sessions identified by the given mount point which were created prior to the specified date. Optionally -m may be be spec- ified to further limit the matching dump sessions by media label. xfsinvutil will prompt the operator prior to pruning a dump session unless the -F or -i options are given. -u UUID mm/dd/yyyy Like -M, except the matching filesystem is specified using its universally unique identifier (UUID) instead of its mount point. -m media_label If specified, only sessions with at least one media file whose label matches this value will be eligible for pruning. This restric- tion is in addition to those imposed by the date and the -M or -u options. This option allows the pruning of all inventory references to media which may have been overwritten or lost. Note that this option does not apply to sessions with no media files. -s SESSION_ID Prunes the dump session identified by the given session id. xfsinvutil will prompt the operator prior to pruning a dump session unless the -F option is given. -C With this option, xfsinvutil performs consistency checks for all entries in the inventory database. It fixes any problems found. If no consistent entries are found , the corresponding inventory database file is removed. Interactive Mode When run with -i, xfsinvutil will present the operator with a hierarchical representation of the xfsdump inventory. In this mode, the operator can use the arrow keys (or the h j k l keys) to navigate the inventory and also use the following keys and functionality: + Expand a branch of the tree. - Collapse a branch of the tree. * Fully expand a branch of the tree. % Fully collapse a branch of the tree. h Move selection to the parent entry. l Move selection to the child entry. j Move selection to next entry. k Move selection to previous entry. d Mark the current record, and all sub-records, to be deleted. u Clear the current record and all parent records from being deleted. i Import another xfsdump inventory. ? Show help window. x Commit any changes made to the inventory, and exit the program. q Exit the program without committing any changes to the inventory. Inventories from other hosts can be imported to create a larger common inventory. It is recommended that the contents of /var/lib/xfs- dump/inventory on the remote host be copied to a temporary local directory prior to running xfsinvutil. When xfsinvutil is run in interac- tive mode, and the operator hits i, they will be prompted for the path to the inventory to be imported. xfsinvutil will then add the con- tents of the imported inventory to the main window, and all entries will be marked as imported. The operator can then delete any of these entries that are not to be imported. When the operator commits the changes, xfsinvutil will import any entries which were not marked as deleted. Deleted entries are not actually deleted from the original imported inventory. NOTES
Inventory Each dump session updates an inventory database in /var/lib/xfsdump/inventory. xfsdump uses the inventory to determine the base of incre- mental and resumed dumps. This database can be displayed by invoking xfsdump with the -I option. The display uses tabbed indentation to present the inventory hier- archically. The first level is filesystem. The second level is session. The third level is media stream (currently only one stream is supported). The fourth level lists the media files sequentially composing the stream. FILES
/var/lib/xfsdump/inventory dump inventory database SEE ALSO
xfsdump(8), xfsrestore(8). xfsinvutil(8)
All times are GMT -4. The time now is 05:21 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy