<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: how to exclude a directory with a find command within a pipe command%0D%0A in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-exclude-a-directory-with-a-find-command-within-a-pipe/m-p/970376#M46018</link>
    <description>&lt;P&gt;Pipe the output from find into &lt;A href="https://man7.org/linux/man-pages/man1/grep.1.html" target="_blank" rel="noopener"&gt;grep&lt;/A&gt; with the -v option to exclude lines with a specific pattern.&lt;/P&gt;</description>
    <pubDate>Tue, 08 Jul 2025 20:37:30 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2025-07-08T20:37:30Z</dc:date>
    <item>
      <title>how to exclude a directory with a find command within a pipe command%0D%0A</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-exclude-a-directory-with-a-find-command-within-a-pipe/m-p/970336#M46015</link>
      <description>&lt;P&gt;How to exclude the 3 subdirectories&lt;/P&gt;
&lt;P&gt;dircf,&amp;nbsp;&amp;nbsp;diraf,&amp;nbsp;dirdrl&lt;/P&gt;
&lt;P&gt;from the find command&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let cleandspath=/dwh_actuariat/sasdata/Data_Retention/;
%let dircf=/dwh_actuariat/sasdata/Data_Retention/Data_Retention_CleanFiles;
%let diraf=/dwh_actuariat/sasdata/Data_Retention/Data_Retention_Anonymized;
%let dirdrl=/dwh_actuariat/sasdata/Data_Retention/Data_Retention_list;

filename oscmd pipe "find &amp;amp;cleandspath -type f -name '*_prm*'  ";
     

data test;
length text $1000.;
	infile oscmd;
    input;
   text= _infile_;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 08 Jul 2025 13:32:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-exclude-a-directory-with-a-find-command-within-a-pipe/m-p/970336#M46015</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2025-07-08T13:32:20Z</dc:date>
    </item>
    <item>
      <title>Re: how to exclude a directory with a find command within a pipe command%0D%0A</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-exclude-a-directory-with-a-find-command-within-a-pipe/m-p/970338#M46016</link>
      <description>&lt;P&gt;how about:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let cleandspath=/dwh_actuariat/sasdata/Data_Retention/;
%let dircf=/dwh_actuariat/sasdata/Data_Retention/Data_Retention_CleanFiles;
%let diraf=/dwh_actuariat/sasdata/Data_Retention/Data_Retention_Anonymized;
%let dirdrl=/dwh_actuariat/sasdata/Data_Retention/Data_Retention_list;

filename oscmd pipe "find &amp;amp;cleandspath -type f -name '*_prm*'  ";

data test;
  length text $1000.;
	infile oscmd;
  input;
  text= _infile_;
  if NOT (text in: ("&amp;amp;dircf." "&amp;amp;diraf." "&amp;amp;dirdrl."));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;for start?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or maybe even with less macrovariables:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let cleandspath=/dwh_actuariat/sasdata/Data_Retention/;

filename oscmd pipe "find &amp;amp;cleandspath -type f -name '*_prm*'  ";

data test;
  length text $1000.;
	infile oscmd;
  input;
  text = _infile_;
  if NOT (text in: ("&amp;amp;cleandspath.Data_Retention_CleanFiles" 
                    "&amp;amp;cleandspath.Data_Retention_Anonymized" 
                    "&amp;amp;cleandspath.Data_Retention_list"
         ));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Tue, 08 Jul 2025 13:47:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-exclude-a-directory-with-a-find-command-within-a-pipe/m-p/970338#M46016</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2025-07-08T13:47:34Z</dc:date>
    </item>
    <item>
      <title>Re: how to exclude a directory with a find command within a pipe command%0D%0A</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-exclude-a-directory-with-a-find-command-within-a-pipe/m-p/970374#M46017</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I can not filter the information into the test dataset.&amp;nbsp; I need to find the good unix command to do what I want, because, I am going to delete those file after.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am looking for something like below but it is like either I am able to filter the directories but not search for file containing _prm&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename oscmd pipe  "find /dwh_actuariat/sasdata/Data_Retention/
                     -type f -name '*_prm*'
                     -path '/dwh_actuariat/sasdata/Data_Retention/Data_Retention_CleanFiles' -prune -o -print 
                     -path '/dwh_actuariat/sasdata/Data_Retention/Data_Retention_Anonymized' -prune -o -print
                     -path '/dwh_actuariat/sasdata/Data_Retention/Data_Retention_list' -prune -o -print 
                     -path '/dwh_actuariat/sasdata/Data_Retention/temp' -prune -o -print
                     -path '/dwh_actuariat/sasdata/Data_Retention/Audit' -prune -o -print
                     -path '/dwh_actuariat/sasdata/Data_Retention/Validation' -prune -o -print 
                     -path '/dwh_actuariat/sasdata/Data_Retention/sas2001b' -prune -o -print ";

data test;
length text $1000.;
	infile oscmd;
    input;
   text= _infile_;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 08 Jul 2025 20:20:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-exclude-a-directory-with-a-find-command-within-a-pipe/m-p/970374#M46017</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2025-07-08T20:20:14Z</dc:date>
    </item>
    <item>
      <title>Re: how to exclude a directory with a find command within a pipe command%0D%0A</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-exclude-a-directory-with-a-find-command-within-a-pipe/m-p/970376#M46018</link>
      <description>&lt;P&gt;Pipe the output from find into &lt;A href="https://man7.org/linux/man-pages/man1/grep.1.html" target="_blank" rel="noopener"&gt;grep&lt;/A&gt; with the -v option to exclude lines with a specific pattern.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Jul 2025 20:37:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-exclude-a-directory-with-a-find-command-within-a-pipe/m-p/970376#M46018</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2025-07-08T20:37:30Z</dc:date>
    </item>
    <item>
      <title>Re: how to exclude a directory with a find command within a pipe command%0D%0A</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-exclude-a-directory-with-a-find-command-within-a-pipe/m-p/970404#M46020</link>
      <description>&lt;P&gt;the option -type -name ‘*_prm*’ is working but not with the -path option&amp;nbsp;&lt;/P&gt;
&lt;P&gt;or the path option is working but not the -type option&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;please provide an example with the grep v option&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class="language-sas"&gt;&lt;CODE&gt;-type f -name '*_prm*'
                     -path '/dwh_actuariat/sasdata/Data_Retention/Data_Retention_CleanFiles' -prune -o -print&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Jul 2025 02:26:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-exclude-a-directory-with-a-find-command-within-a-pipe/m-p/970404#M46020</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2025-07-09T02:26:20Z</dc:date>
    </item>
    <item>
      <title>Re: how to exclude a directory with a find command within a pipe command%0D%0A</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-exclude-a-directory-with-a-find-command-within-a-pipe/m-p/970406#M46021</link>
      <description>&lt;P&gt;Why not just use SAS code instead?&amp;nbsp;&lt;A href="https://github.com/sasutils/macros/blob/master/dirtree.sas" target="_blank" rel="noopener"&gt;https://github.com/sasutils/macros/blob/master/dirtree.sas&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You are asking for help with a UNIX command on a SAS forum.&amp;nbsp; Someone gave you an answer for how to filter the output of the UNIX command using normal SAS code.&amp;nbsp; Why isn't that good enough?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hint on using the find command.&amp;nbsp; Look at the many expressions you can use with the find command.&amp;nbsp; In particular the -prune option.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is an example I used in the past to ignore .snapshot directories that were created automatically on some network attach disk drives.&lt;/P&gt;
&lt;PRE&gt;find ....... -name \.snapshot -prune ....&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Jul 2025 02:54:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-exclude-a-directory-with-a-find-command-within-a-pipe/m-p/970406#M46021</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-07-09T02:54:42Z</dc:date>
    </item>
    <item>
      <title>Re: how to exclude a directory with a find command within a pipe command%0D%0A</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-exclude-a-directory-with-a-find-command-within-a-pipe/m-p/970408#M46022</link>
      <description>&lt;P&gt;You could just use the ! to exclude paths.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Using the following prompts with Copilot:&lt;/P&gt;
&lt;PRE&gt;Amend to exclude paths /a/b/c and /a/b/x from find /a -type f -name '*_prm*' &lt;/PRE&gt;
&lt;P&gt;I've got this answer:&lt;/P&gt;
&lt;PRE&gt;find /a -type f -name '*_prm*' ! -path "/a/b/c/*" ! -path "/a/b/x/*"&lt;/PRE&gt;
&lt;P&gt;Applied to the code you shared this could look like:&lt;/P&gt;
&lt;PRE&gt;filename oscmd pipe "find &amp;amp;cleandspath -type f -name '*_prm*' ! -path '&amp;amp;dircf/*' ! -path '&amp;amp;diraf/*' ! -path '&amp;amp;dirdrl/*' ";&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've tested the syntax and it works as desired. It will exclude all content under the paths that are listed as excluded (the NOT exclamation mark).&lt;/P&gt;</description>
      <pubDate>Wed, 09 Jul 2025 05:59:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-exclude-a-directory-with-a-find-command-within-a-pipe/m-p/970408#M46022</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2025-07-09T05:59:39Z</dc:date>
    </item>
    <item>
      <title>Re: how to exclude a directory with a find command within a pipe command%0D%0A</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-exclude-a-directory-with-a-find-command-within-a-pipe/m-p/970417#M46025</link>
      <description>&lt;P&gt;I created some directories in my personal folder on my Macbook:&lt;/P&gt;
&lt;PRE&gt;&amp;gt; find test
test
test/uvw
test/abc
test/def
test/xyz&lt;/PRE&gt;
&lt;P&gt;Then I ran this command:&lt;/P&gt;
&lt;PRE&gt;find test|grep -v xyz|grep -v uvw&lt;/PRE&gt;
&lt;P&gt;and got this result:&lt;/P&gt;
&lt;PRE&gt;test
test/abc
test/def&lt;/PRE&gt;</description>
      <pubDate>Wed, 09 Jul 2025 09:17:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-exclude-a-directory-with-a-find-command-within-a-pipe/m-p/970417#M46025</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2025-07-09T09:17:13Z</dc:date>
    </item>
    <item>
      <title>Re: how to exclude a directory with a find command within a pipe command%0D%0A</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-exclude-a-directory-with-a-find-command-within-a-pipe/m-p/970418#M46026</link>
      <description>&lt;P&gt;Why can't you create a temporary dataset?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Having such a data set with list of files you want to delete seems like a perfect fit for running FDELETE() function:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
    SET test;
    fname="tempfile";
    rc=filename(fname, strip(text));
    if rc = 0 and fexist(fname) then
       rc=fdelete(fname);
    rc=filename(fname);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or in fact you could do it "on the fly":&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let cleandspath=/dwh_actuariat/sasdata/Data_Retention/;

filename oscmd pipe "find &amp;amp;cleandspath -type f -name '*_prm*'  ";

data _null_;
  length text $1000.;
	infile oscmd;
  input;
  text = _infile_;
  if NOT (text in: ("&amp;amp;cleandspath.Data_Retention_CleanFiles" 
                    "&amp;amp;cleandspath.Data_Retention_Anonymized" 
                    "&amp;amp;cleandspath.Data_Retention_list"
         ));


    fname="tempfile";
    rc=filename(fname, strip(text));
    if rc = 0 and fexist(fname) then
       rc=fdelete(fname);
    rc=filename(fname);

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Wed, 09 Jul 2025 09:30:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-exclude-a-directory-with-a-find-command-within-a-pipe/m-p/970418#M46026</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2025-07-09T09:30:21Z</dc:date>
    </item>
    <item>
      <title>Re: how to exclude a directory with a find command within a pipe command%0D%0A</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-exclude-a-directory-with-a-find-command-within-a-pipe/m-p/970438#M46031</link>
      <description>This script works perferctly.  However, I would like to understand the signification of the exclamation mark</description>
      <pubDate>Wed, 09 Jul 2025 12:45:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-exclude-a-directory-with-a-find-command-within-a-pipe/m-p/970438#M46031</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2025-07-09T12:45:06Z</dc:date>
    </item>
    <item>
      <title>Re: how to exclude a directory with a find command within a pipe command%0D%0A</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-exclude-a-directory-with-a-find-command-within-a-pipe/m-p/970447#M46032</link>
      <description>&lt;P&gt;Read for yourself:&amp;nbsp;&lt;A href="https://man7.org/linux/man-pages/man1/find.1.html" target="_blank" rel="noopener"&gt;find&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's in the OPERATORS section.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Jul 2025 14:35:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-exclude-a-directory-with-a-find-command-within-a-pipe/m-p/970447#M46032</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2025-07-09T14:35:33Z</dc:date>
    </item>
  </channel>
</rss>

