I need to list only the files in a directory that do NOT begin with qc_dl
, qc_dt
or qd_df
, but that also DO end in .sas
.
I can list the files that do not begin with "qc_dl" as such:
ls -I "qc_dl*"
But then I do not know how to only select the SAS programs from the resultant list.
Furthermore, I can select all SAS files that begin either with "qc_dl", "qc_dt" or "qd_df", as follows:
ls qc_d{l,t,f}*.sas
However, I cannot combine the two commands to only list SAS files that DO NOT begin with qc_dl/t/f
.
Best Answer
Assuming file names don't contain newline characters and don't start with
.
, this should work:List files ending in .sas and filtering all that is NOT qc_dl, qc_dt, qc_df
For any filtering needs, grep is your friend.