Sponsored Content
Top Forums UNIX for Beginners Questions & Answers If file pattern exists in directory then continue Post 303041155 by cmccabe on Friday 15th of November 2019 03:36:47 PM
Old 11-15-2019
If file pattern exists in directory then continue

he below looks in $dir for any pattern of fileone. As is, it executes but only returns File found if the exact format in the script exsists. Why isn't a pattern of fileone being looked for and if it is in [CODE]$dir[/ICODE], File found. I think that is what should happen. Thank you Smilie.


Code:
dir=/path/to
if ls "$dir"/fileone.csv* > /dev/null 2>&1
then
    echo "File not found!" >> "$dir"/log && exit 0
else
    echo "File was found, moving on " >> "$dir"/log
fi


Last edited by cmccabe; 11-15-2019 at 04:37 PM.. Reason: fixed format
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

check if file exists with pattern matching

Hello friends, I am writing a simple shell script which will copy one particular type of files to backup folder if files exists. If files doesn't exists, mv command should not be executed. My file pattern is like wcm-spider-maestro.log.2009-07-15, wcm-spider-maestro.log.2009-07-16 etc.. I... (6 Replies)
Discussion started by: sreenu.shell
6 Replies

2. Shell Programming and Scripting

check if directory and file exists

cp $PATHLOGS/$DATE/*.* $TMP/logs_tmp/ cp $PATHLOGS/$DATE1/*.* $TMP/logs_tmp/ Before copying the files I have to check if the directory $DATE1 and $DATE2 exists. If directory exists then, check if the folder contains some files. if the file exists then, check if the file size is greater... (3 Replies)
Discussion started by: sandy1028
3 Replies

3. Shell Programming and Scripting

Grep pattern from different file and display if it exists in the required file

Hi, I have two files say xxx.txt and yyy.txt. xxx.txt is with list of patterns within double quotes. Eg. "this is the line1" "this is the line2" The yyy.txt with lot of lines. eg: "This is a test message which contains rubbish information just to fill the page which is of no use. this is... (3 Replies)
Discussion started by: abinash
3 Replies

4. Shell Programming and Scripting

How to check if a file exists in a directory?

I want to perform SQL *Loader operation only if a file named "load.txt" exists in a directory "/home/loc/etc". Please help how to check this with a if condition. (8 Replies)
Discussion started by: vel4ever
8 Replies

5. Shell Programming and Scripting

Check for Pattern if exists write to file

Hi ! All I just want to search and write to new file if pattern is found in text file following are my text files by which I want to search Month and last column number my text file1 15-Jan-2011 25 ARTS 1255 125 125 178 198 15-Jan-2011 25 ARTS 1255 125 125 178 198 15-Jan-2011 25... (3 Replies)
Discussion started by: nex_asp
3 Replies

6. Shell Programming and Scripting

How to check if the file exists in directory?

Hi Gurus, I have a requests to find if all the file in the filelist exist in certain directory. example: my filelist abc def ddd cde afg how can I find these 5 files exists at director /home/abc Thanks in advance (7 Replies)
Discussion started by: ken6503
7 Replies

7. Shell Programming and Scripting

Check whether file exists in directory

Hi guys, I am beginner trying to learn unix. So any help is welcomed. My requirement is to check whether is a file exists in a particular directory or not. The directory path and filename are taken dynamically with user interaction. So the program should continue only if the $filename... (1 Reply)
Discussion started by: maris_markur
1 Replies

8. UNIX for Dummies Questions & Answers

Outputting 1 file per row if pattern exists between files

I have many files that can have various amounts of rows. I essentially want to output each row into a new file if a pattern is matched between two files. I have some code that does something similar but I want it to output every single input row from every file into a separate output file; that... (5 Replies)
Discussion started by: verse123
5 Replies

9. Shell Programming and Scripting

Search if file exists for a file pattern stored in array

Hi experts, I have two arrays one has the file paths to be searched in , and the other has the files to be serached.For eg searchfile.dat will have abc303 xyz123 i have to search for files that could be abc303*.dat or for that matter any extension . abc303*.dat.gz The following code... (2 Replies)
Discussion started by: 100bees
2 Replies

10. UNIX for Beginners Questions & Answers

Check that at least one file exists in the directory.

There are some files with suffix dates like abc_20032019.dat abc_17032019.dat If at least one file exists then perform some operation else exit from execution. Korn shell ---------------------------------- array=($inputdir/abc*.dat) If ] ] then echo " file exits" else echo " file does... (10 Replies)
Discussion started by: Rajesh123
10 Replies
File::ShareDir::Install(3pm)				User Contributed Perl Documentation			      File::ShareDir::Install(3pm)

NAME
File::ShareDir::Install - Install shared files SYNOPSIS
use ExtUtils::MakeMaker; use File::ShareDir::Install; install_share 'share'; install_share dist => 'dist-share'; install_share module => 'My::Module' => 'other-share'; WriteMakefile( ... ); # As you normaly would package MY; use File::ShareDir::Install qw(postamble); DESCRIPTION
File::ShareDir::Install allows you to install read-only data files from a distribution. It is a companion module to File::ShareDir, which allows you to locate these files after installation. It is a port Module::Install::Share to ExtUtils::MakeMaker with the improvement of only installing the files you want; ".svn" and other source-control junk will be ignored. EXPORT
install_share install_share $dir; install_share dist => $dir; install_share module => $module, $dir; Causes all the files in $dir and its sub-directories. to be installed into a per-dist or per-module share directory. Must be called before WriteMakefile. The first 2 forms are equivalent. The files will be installed when you run "make install". To locate the files after installation so they can be used inside your module, see File::ShareDir. my $dir = File::ShareDir::module_dir( $module ); Note that if you make multiple calls to "install_share" on different directories that contain the same filenames, the last of these calls takes precedence. In other words, if you do: install_share 'share1'; install_share 'share2'; And both "share1" and "share2" contain a fill called "info", the file "share2/info" will be installed into your "dist_dir()". postamble Exported into the MY package. Only documented here if you need to write your own postable. package MY; use File::ShareDir::Install; sub postamble { my $self = shift; my @ret = File::ShareDir::Install::postamble( $self ); # ... add more things to @ret; return join " ", @ret; } SEE ALSO
File::ShareDir, Module::Install. AUTHOR
Philip Gwyn, <gwyn-AT-cpan.org> COPYRIGHT AND LICENSE
Copyright (C) 2009-2011 by Philip Gwyn This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available. perl v5.12.4 2011-08-26 File::ShareDir::Install(3pm)
All times are GMT -4. The time now is 09:12 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy