Exclude files in gzip command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Exclude files in gzip command
# 15  
Old 05-01-2014
Makarand,

I need to use your code by invoking directory path which i have mentioned in my previous post will the below one work

Code:
gzip `ls $directory/| grep -v "AUS.*csv" | grep -v "AUS.*txt"`

# 16  
Old 05-01-2014
It's beginning to seem that you are unwilling to help yourself. We are into double digit post count and there's no indication that you've actually tried any off the suggestions.

Why don't you just go ahead and run some tests? If there are problems or shortcomings, try to fix them yourself. If you succeed, report back with your changes so that others can benefit. If you fail, then post the exact errors seen so that we have more information to work with.

Regards,
Alister
# 17  
Old 05-01-2014
hi

when i am using the test directory getting the below error

Code:
gzip `ls test| egrep -v "AUS.*csv|AUS.*txt"`

gzip: can't stat: NZ.csv (NZ.csv): No such file or directory
gzip: can't stat: NZ.txt (NZ.txt): No such file or directory

I have tried all the ways
# 18  
Old 05-01-2014
Try
Code:
cd test
ls | .....

# 19  
Old 05-01-2014
Hi I don't wanted to use cd test rather than accessing the direct path
# 20  
Old 05-02-2014
Quote:
Originally Posted by rohit_shinez
Hi I don't wanted to use cd test rather than accessing the direct path
Going back to your first post to this thread, you said you have a directory named test in the current directory containing the four files:
Code:
direct:
AUS1.tx
AUS2.txt
  and
NZ1.txt

Now you are saying that you want to invoke the command:
Code:
gzip direct: AUS1.tx NZ1.txt

in a directory where none of these files exist.

So, you can choose to use a cd command to get into the directory where those files exist, or you can choose a completely different way to get the list of filenames to be given to gzip.

Why are you so opposed to using the cd command?

What does the following command do:
Code:
cd test;gzip `ls | egrep -v '^AUS.*[.](csv|txt)$'

that is different from what you have said you want?
# 21  
Old 05-02-2014
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
Code:
gzip `ls | egrep -v ''AUS*[.](csv|txt)$'|grep -v "^d"`


Last edited by rohit_shinez; 05-02-2014 at 01:55 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Exclude directories in FIND command

Can you please help tweak the below command to exclude all directories with the name "logs" and "tmp" find . -type f \( ! -name "*.tar*" ! -name "*.bkp*" \) -exec /usr/xpg4/bin/grep -i "user_1" /dev/null {} + >result.out bash-3.2$ uname -a SunOS mymac 5.10 Generic_150400-26 sun4v sparc sun4v... (9 Replies)
Discussion started by: mohtashims
9 Replies

2. Shell Programming and Scripting

Exclude files in ls

Hi, I need to exlucde the files which are present in exclude.txt from a directory exlcude.txt AUZ.txt AUZ.chk NZ.txt NZ.chk tried with below code but not working ls -ltr | grep -v `cat exclude.lst` (9 Replies)
Discussion started by: rohit_shinez
9 Replies

3. Shell Programming and Scripting

Need to exclude .NFSxxx files in clear old files batch script

I am new to Shell Scripting and need some help. The following batch job has been failing for me due to the .nfsxxx files in use. I need to know how to modify the following script to exclude the .nfsxxx files so this batch job will not fail on me. I have done lots of googling and keep coming back... (2 Replies)
Discussion started by: kimberlyg2007
2 Replies

4. UNIX for Dummies Questions & Answers

Find command to exclude files with no extension

The below 'ls' command will list down files with extensions and suppress the ones with no extension ls |grep "\\." But this dosen't work when I apply the same logic using 'find' command find . -type f |grep "\\." I need help on how this logic can be implemented using 'find' command (3 Replies)
Discussion started by: meenavin
3 Replies

5. UNIX for Advanced & Expert Users

gzip vs pipe gzip: produce different file size

Hi All, I have a random test file: test.txt, size: 146 $ ll test.txt $ 146 test.txt Take 1: $ cat test.txt | gzip > test.txt.gz $ ll test.txt.gz $ 124 test.txt.gz Take 2: $ gzip test.txt $ ll test.txt.gz $ 133 test.txt.gz As you can see, gzipping a file and piping into gzip... (1 Reply)
Discussion started by: hanfresco
1 Replies

6. Shell Programming and Scripting

Find command with exclude

I had a Shell script that removes the files that are in a directory older than the specified days. find /test/files -mtime +10 I would like to add another condition to the find command above that is to exclude any file starting with ‘CGU' Thanks (1 Reply)
Discussion started by: db2dbac
1 Replies

7. Shell Programming and Scripting

Using GZIP command

Hi All, Is it possible to redirect the o/p of gzip command to another file? I need to store the o/p in a separate file Regards, sh_kk (7 Replies)
Discussion started by: sh_kk
7 Replies

8. UNIX for Dummies Questions & Answers

list the files but exclude the files in subdirectories

If I execute the command "ls -l /export/home/abcde/dev/proj/code/* | awk -F' ' '{print $9}' | cut -d'/' -f6-8" it will list all the files in /export/home/abcde/dev/proj/code/ directory as well as the files in subdirectories also proj/code/test.sh proj/code/test1.c proj/code/unix... (8 Replies)
Discussion started by: shyjuezy
8 Replies

9. Shell Programming and Scripting

unzip particular gzip files among the normal data files

Hello experts, I run Solaris 9. I have a below script which is used for gunzip the thousand files from a directory. ---- #!/usr/bin/sh cd /home/thousands/gzipfiles/ for i in `ls -1` do gunzip -c $i > /path/to/file/$i done ---- In my SAME directory there thousand of GZIP file and also... (4 Replies)
Discussion started by: thepurple
4 Replies

10. UNIX for Advanced & Expert Users

du (exclude files)

Hi, I want to get the disk usage of a directory. But I want it to ignore a particular directory within it. Lets say I want disk usage of all files/dirs within dir1 except those that are named .snapshot Does du have the option of excluding a particular directory. (1 Reply)
Discussion started by: the_learner
1 Replies
Login or Register to Ask a Question