hi Don,
yeah thats what i mean to invoke directory but my files with AUS.2013.txt is also getting exlcuded which i dont wanted. only files ending with .txt and .csv and starts with AUS should be excluded. I got this with below is it possible to ignore any sub directory directory trying with below code but not ignoring the subdirectory
gzip `ls | egrep -v ''AUS*[.](csv|txt)$'|grep -v "^d"`
Huh? You want to exclude files that start with AUS
and end with either .txt
or .csv
and yet you don't want to exclude AUS.2013.txt
(which starts with AUX
and ends with .txt
)???
Your requirements are not at all clear!
If you can't clearly answer the following two questions, I don't see how we will ever be able to help you:
- Why are you opposed to using the
cd
command so you can run gzip
in the directory where the files you want to compress reside?
- What files (including the directory where they are located, the type of files to be processed, and the names of the files in that directory) are to be excluded (or included) in the operand list to be given to
gzip
?
hi don,
let me tell what i needed is
- I want to exclude files starting with AUS and ending with either .csv or .txt alone
- to exclude if any sub directories present in my directory becoz gzip will not zip if any directory present
The following will gzip
all regular files in the specified directory (and only in that directory) that have names that do not both start with AUS
and end with either .csv
or .txt
:
cd directory_containing_files_you_want_to_gzip
gzip `find . ! -name . -prune -type -f ! -name 'AUS*.csv' ! -name 'AUS*.txt'`