Sponsored Content
Full Discussion: To quote or not
Top Forums UNIX for Dummies Questions & Answers To quote or not Post 302844098 by Scrutinizer on Friday 16th of August 2013 11:38:13 AM
Old 08-16-2013
It means that the shell will expand the pattern and pass the resulting file names as a parameter to find (so find will never "see" a pattern, just the expansion result), which will lead to a syntax error if the result is more than one file and and to the wrong result if it just one file:

A short illustration would be:
Code:
$ ls
$ mkdir dir1
$ touch fileA fileB dir1/fileC dir1/fileD
$ find . -name 'file*'              # the shell does not expand patterns within quotes, so the shell removes the quotes and file* gets passed to find
./dir1/fileC
./dir1/fileD
./fileA
./fileB
$ find . -name file*                # pattern get expanded to fileA fileB
find: fileB: unknown primary or operator
$ rm fileB
$ find . -name file*                # pattern get expanded to fileA
./fileA
$ rm fileA
$ find . -name file*                # pattern does not get expanded, since no files with that pattern are present in the current directory.
./dir1/fileC
./dir1/fileD


Last edited by Scrutinizer; 08-16-2013 at 12:45 PM..
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Capturing Data between first quote and next quote

I have input file like RDBMS FALIURE UTY8703 'USER_WORK.TEST' .HIghest return code '12' I want to parse data which comed between first quote till next quote USER_WORK.TEST can you please suggest how to do that (4 Replies)
Discussion started by: scorp_rahul23
4 Replies

2. Shell Programming and Scripting

double-quote inside double-quote

hey all, i made a simple .sh like this: echo "<style media="screen" type="text/css">@import url("main.css");</style>" but the output is: <style media=screen type=text/css>@import url(main.css);</style> i want to keep double-quotes, can anyone help me? thanks (3 Replies)
Discussion started by: indraf
3 Replies

3. Shell Programming and Scripting

Quote and variable

The command line bellow works fine by itself. /opt/csw/bin/rsync -azq --delete -e "ssh -i /.ssh/ss" /home/ me@myaccount.storage.com:/home/ Now I would like to introduce some variable into it and make a .sh file such as bellow and it does not work anymore. I guess the part -e "ssh -i /.ssh/ss" has... (4 Replies)
Discussion started by: ngungo
4 Replies

4. Shell Programming and Scripting

Regex in grep to match all lines ending with a double quote (") OR a single quote (')

Hi, I've been trying to write a regex to use in egrep (in a shell script) that'll fetch the names of all the files that match a particular pattern. I expect to match the following line in a file: Name = "abc" The regex I'm using to match the same is: egrep -l '(^) *= *" ** *"$' /PATH_TO_SEARCH... (6 Replies)
Discussion started by: NanJ
6 Replies

5. Shell Programming and Scripting

replacing a quote in some lines with multiple quote fields

i want to replace mistaken quotes in line starting with tag 300 and relocate the quote in the correct position so the input is 223;25 224;20100428064823;1;0;0;0;0;0;0;0;8;1;3;9697;18744;;;;;;;;;;;; 300;X;Event:... (3 Replies)
Discussion started by: wradwan
3 Replies

6. Shell Programming and Scripting

getting value between double quote

Can somebody supply me with a simple way to get a value between two double quotes? Example: input = ADR base is "/u01/app/oracle" output = /u01/app/oracle Thanks to all who answer (4 Replies)
Discussion started by: BeefStu
4 Replies

7. Shell Programming and Scripting

Replacing Double Quote in Double Quote incsv file

Hi All , We have source data file as csv file and since data could contain commas ,each attribute is quoted into double quotes.However problem is that some of the attributa data also contain double quotes which is converted to double double quote while creating csv file XLs data : ... (2 Replies)
Discussion started by: Shalini Badal
2 Replies

8. Shell Programming and Scripting

Replacing all but the first and last double quote in a line with a single quote with awk

From: 1,2,3,4,5,This is a test 6,7,8,9,0,"This, is a test" 1,9,2,8,3,"This is a ""test""" 4,7,3,1,8,"""" To: 1,2,3,4,5,This is a test 6,7,8,9,0,"This; is a test" 1,9,2,8,3,"This is a ''test''" 4,7,3,1,8,"''"Is there an easy syntax I'm overlooking? There will always be an odd number... (5 Replies)
Discussion started by: Michael Stora
5 Replies

9. What is on Your Mind?

A terrific quote:

Food for thought! """ Everybody in this country should learn to program a computer...because it teaches you how to think. """ Steve Jobs. So, SO, true! Merry XMAS all... (4 Replies)
Discussion started by: wisecracker
4 Replies
DirCompare(3pm) 					User Contributed Perl Documentation					   DirCompare(3pm)

NAME
File::DirCompare - Perl module to compare two directories using callbacks. SYNOPSIS
use File::DirCompare; # Simple diff -r --brief replacement use File::Basename; File::DirCompare->compare($dir1, $dir2, sub { my ($a, $b) = @_; if (! $b) { printf "Only in %s: %s ", dirname($a), basename($a); } elsif (! $a) { printf "Only in %s: %s ", dirname($b), basename($b); } else { print "Files $a and $b differ "; } }); # Version-control like Deleted/Added/Modified listing my (@listing, @modified); # use closure to collect results File::DirCompare->compare('old_tree', 'new_tree', sub { my ($a, $b) = @_; if (! $b) { push @listing, "D $a"; } elsif (! $a) { push @listing, "A $b"; } else { if (-f $a && -f $b) { push @listing, "M $b"; push @modified, $b; } else { # One file, one directory - treat as delete + add push @listing, "D $a"; push @listing, "A $b"; } } }); DESCRIPTION
File::DirCompare is a perl module to compare two directories using a callback, invoked for all files that are 'different' between the two directories, and for any files that exist only in one or other directory ('unique' files). File::DirCompare has a single public compare() method, with the following signature: File::DirCompare->compare($dir1, $dir2, $sub, $opts); The first three arguments are required - $dir1 and $dir2 are paths to the two directories to be compared, and $sub is the subroutine reference called for all unique or different files. $opts is an optional hashref of options - see OPTIONS below. The provided subroutine is called for all unique files, and for every pair of 'different' files encountered, with the following signature: $sub->($file1, $file2) where $file1 and $file2 are the paths to the two files. For 'unique' files i.e. where a file exists in only one directory, the subroutine is called with the other argument 'undef' i.e. for: $sub->($file1, undef) $sub->(undef, $file2) the first indicates $file1 exists only in the first directory given ($dir1), and the second indicates $file2 exists only in the second directory given ($dir2). OPTIONS The following optional arguments are supported, passed in using a hash reference after the three required arguments to compare() e.g. File::DirCompare->compare($dir1, $dir2, $sub, { cmp => $cmp_sub, ignore_unique => 1, }); cmp By default, two files are regarded as different if their contents do not match (tested with File::Compare::compare). That default behaviour can be overridden by providing a 'cmp' subroutine to do the file comparison, returning zero if the two files are equal, and non-zero if not. E.g. to compare using modification times instead of file contents: File::DirCompare->compare($dir1, $dir2, $sub, { cmp => sub { -M $_[0] <=> -M $_[1] }, }); ignore_cmp If you want to see all corresponding files, not just 'different' ones, set the 'ignore_cmp' flag to tell File::DirCompare to skip its file comparison checks i.e. File::DirCompare->compare($dir1, $dir2, $sub, { ignore_cmp => 1 }); ignore_unique If you want to ignore files that only exist in one of the two directories, set the 'ignore_unique' flag i.e. File::DirCompare->compare($dir1, $dir2, $sub, { ignore_unique => 1 }); SEE ALSO
File::Dircmp, which provides similar functionality (and whose directory walking code I've adapted for this module), but a simpler reporting-only interface, something like the first example in the SYNOPSIS above. AUTHOR AND CREDITS
Gavin Carr <gavin@openfusion.com.au> Thanks to Robin Barker for a bug report and fix for glob problems with whitespace. COPYRIGHT AND LICENSE
Copyright 2006-2007 by Gavin Carr. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.10.1 2010-03-02 DirCompare(3pm)
All times are GMT -4. The time now is 11:22 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy