Sponsored Content
Top Forums Shell Programming and Scripting Check if files inside a text file are found under a directory Post 302921273 by RavinderSingh13 on Thursday 16th of October 2014 06:19:49 AM
Old 10-16-2014
Quote:
Originally Posted by arrals_vl
Hi all,

Please somebody help me with this:

I want to check if the files listed in a text file, are found under a directory or not.

For example: the file is list_of_files.txt, which contains inside this rows:

[root@localhost ~]# cat list_of_files
logs
errors
paths
debug
[root@localhost ~]#

i want to check if these 4 files, are found under directory, for example /tmp.

If so, everything is ok, if not, print the files which are missing.

Thank you!
Hello arrals_vl,

Could you please try following script.

Code:
echo "please enter the complete path where you want to search for files."
read path
while read line
do
    NAME=`find "$path" -type f -name "$line" 2>/dev/null`
    if [[ -n "$NAME" ]]
    then
        echo "$line" file has been found.
    else
        echo "$line" file NOT found.
    fi
done < "files"

In my case output is as follows.
Code:
please enter the complete path where you want to search for files.
/tmp
chumma file NOT found.
tets100 file has been found.
test98 file has been found.
test8 file has been found.
test7 file has been found.
test6 file has been found.
test5 file has been found.
test4 file has been found.
test3 file has been found.
test2 file has been found.
test1 file has been found.

Where file named files is the input file with all file names you want to search for.

Thanks,
R. Singh
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Replacing text inside a directory

This is my first post to this group.I am new to Unix.I have one requirement I need to replace a text in all the files in a directory and sub-directory.Eg i have a folder structure like /usr/local/abc , inside abc i have several directories and several files. All the files inside abc and all the... (1 Reply)
Discussion started by: vatsan
1 Replies

2. Shell Programming and Scripting

How to strip ^M at end of each files for all files found in current directory

I am trying to use a loop to strip of the funny character ^M at the end of all lines in each file found in current directory and I have used the following in a script: find . -type f -name '*.txt' | while read file do echo "stripping ^M from ..." ex - "$file" > $tempfile %s/^M//g wq! # mv... (4 Replies)
Discussion started by: bisip99
4 Replies

3. UNIX for Dummies Questions & Answers

Zip files inside the directory, but not the directory itself

Hi, Im facing a problem that im stucked, I have the following structure: thales@pereirtc-vbox:/home/VfARM$ ls code config doc lib manifest.bak manifest.rel manifest.v3 ns pub if i try to execute zip -q -o arm.zip VfARM/* it will create a zip file with the folder VfARM.... (2 Replies)
Discussion started by: Thales.Claro
2 Replies

4. Homework & Coursework Questions

copy files inside a text file

Hi Guys , I am new to this and Hi to all ,Need your help I am trying to copy Files which are inside file.txt The files inside file.txt are inthe below order file1.log file2.log file3.log ....... I want to copy these files to an output Directory , Please help (1 Reply)
Discussion started by: hc17972
1 Replies

5. Homework & Coursework Questions

copy files inside a text file

Hi Guys , I am new to this and Hi to all ,Need your help I am trying to copy Files which are inside file.txt The files inside file.txt are inthe below order file1.log file2.log file3.log ....... I want to copy these files to an output Directory , Please help (1 Reply)
Discussion started by: hc17972
1 Replies

6. Shell Programming and Scripting

Replace Filename and text inside of directory

I have a directory that has directories that contain Dir-20111114-xyz and I want to change them to Dir-20111121-xyz. Inside of Dir-20111114-xyz, I have a config.xml file that also contains the date that I need changed from 20111114 to 20111121 I have used sed to replace inside of file not... (4 Replies)
Discussion started by: icculus99
4 Replies

7. Shell Programming and Scripting

How to grep all the files inside the directory and Sub directory

Hi, I have used the command cat * | grep -r <<String>> * It returns: cat : JAN : is directory *********************** ********************* My directory structure: log - JAN -catalina.out -FEB -catalina.out -MARCH ... (11 Replies)
Discussion started by: nanthagopal
11 Replies

8. Shell Programming and Scripting

Copy files listed in text file to new directory

I am trying to write a script that will copy all file listed in a text file (100s of file names) to a new directory Assume script will run with main as current working directory and I know how many files/lines will be in List.txt Im trying to work up a test script using this model Contents of... (2 Replies)
Discussion started by: IAmTheGrass
2 Replies

9. Shell Programming and Scripting

Append string to all the files inside a directory excluding subdirectories and .zip files

Hii, Could someone help me to append string to the starting of all the filenames inside a directory but it should exclude .zip files and subdirectories. Eg. file1: test1.log file2: test2.log file3 test.zip After running the script file1: string_test1.log file2: string_test2.log file3:... (4 Replies)
Discussion started by: Ravi Kishore
4 Replies

10. Shell Programming and Scripting

Script to check the files existence inside a directory.

Hello Folks, On Below Script, I want to apply condition. Condition that it check the directory for files if not found keep checking. Once directory have files and founded do the calculation and finish the code. Script to check the files existence inside a directory, If not then keep... (16 Replies)
Discussion started by: sadique.manzar
16 Replies
cups-files.conf(5)						    Apple Inc.							cups-files.conf(5)

NAME
cups-files.conf - file and directory configuration file for cups DESCRIPTION
The cups-file.conf file configures the files and directories used by the CUPS scheduler, cupsd(8). It is normally located in the /etc/cups directory. Each line in the file can be a configuration directive, a blank line, or a comment. Comment lines start with the # character. DIRECTIVES
The following directives are understood by cupsd(8). Consult the on-line help for detailed descriptions: AccessLog filename AccessLog syslog Defines the access log filename. ConfigFilePerm mode Specifies the permissions for all configuration files that the scheduler writes. DataDir path Specified the directory where data files can be found. DocumentRoot directory Specifies the root directory for the internal web server documents. ErrorLog filename ErrorLog syslog Specifies the error log filename. FatalErrors none FatalErrors all -kind [... -kind] FatalErrors kind [... kind] Specifies which errors are fatal, causing the scheduler to exit. "Kind" is "browse", "config", "listen", "log", or "permissions". FileDevice Yes FileDevice No Specifies whether the file pseudo-device can be used for new printer queues. FontPath directory[:directory:...] Specifies the search path for fonts. Group group-name-or-number Specifies the group name or ID that will be used when executing external programs. LogFilePerm mode Specifies the permissions for all log files that the scheduler writes. PageLog filename PageLog syslog Specifies the page log filename. Printcap Printcap filename Specifies the filename for a printcap file that is updated automatically with a list of available printers (needed for legacy applica- tions); specifying Printcap with no filename disables printcap generation. RemoteRoot user-name Specifies the username that is associated with unauthenticated root accesses. RequestRoot directory Specifies the directory to store print jobs and other HTTP request data. ServerBin directory Specifies the directory where backends, CGIs, daemons, and filters may be found. ServerCertificate filename Specifies the encryption certificate to use. ServerKey filename Specifies the encryption key to use. ServerRoot directory Specifies the directory where the server configuration files can be found. SystemGroup group-name [group-name ...] Specifies the group(s) to use for System class authentication. TempDir directory Specifies the directory where temporary files are stored. User user-name Specifies the user name or ID that is used when running external programs. SEE ALSO
classes.conf(5), cupsd(8), cupsd.conf(5), mime.convs(5), mime.types(5), printers.conf(5), subscriptions.conf(5), http://localhost:631/help COPYRIGHT
Copyright 2007-2012 by Apple Inc. 19 November 2012 CUPS cups-files.conf(5)
All times are GMT -4. The time now is 02:03 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy