OT: Regex question
Keary Suska
yellowdog-general@lists.terrasoftsolutions.com
Sat May 4 10:26:01 2002
on 5/3/02 4:41 PM, valites@geneseo.edu purportedly said:
> Don't use positive pattern matching here. Use a negative character class.
> [a-z]* would miss on dirs that start with "."s or digits or funky
> characters.
>
> tar cvf output_file.tar/path/to/[^A-Z]*
>
> will take care of everything but the dir you want to skip and .files
> The "^" means not.
>
> To get a little fancier, try invoking command substitution to do it.
>
> tar cvf output_file.tar `ls -lda [^A-Z]* | grep -v /path/to/file/to/skip`
>
> Using `stuff` causes your shell to expand whatever is in the backticks
> (called command subsitution) and feed it back to the shell.
Just to clarify, the above example would fail for because of the -l option
passed to ls. You want just the file names, not the additional info that a
long listing provides.
$ tar cvf output_file.tar `ls -da [^A-Z]* | grep -v /path/to/file/to/skip`
Would be more correct.
Keary Suska
Esoteritech, Inc.
"Leveraging Open Source for a better Internet"