gzip selected files that do not contain the string...


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting gzip selected files that do not contain the string...
# 1  
Old 06-14-2010
gzip selected files that do not contain the string...

Solaris 10

Hi All,

Can anyone give me a simple way of gzipping select files that end with *.dmp and where the filename does not contain the string "nocompress"

I had a go but failed miserably :-(

Thanks in advance
Satnam
# 2  
Old 06-14-2010
Code:
find . -type f \( -name '*.dmp' -a ! -name '*nocompress*' \) | xargs gzip


Last edited by vgersh99; 06-14-2010 at 02:45 PM..
# 3  
Old 06-14-2010
Code:
for f in *.dmp; do
    case $f in
        *nocompress*) continue;;
    esac
    <your gzip command here>
done

Regards,
Alister
# 4  
Old 06-14-2010
smashed it!

Cheers
S

---------- Post updated at 06:45 PM ---------- Previous update was at 06:43 PM ----------

the 1 liner find command works for me as my script uses the find command extensively. very powerful.

cheers
for all the input peeps.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

unzip selected files

Hi, In file zip folder i have many files but i want to extract onlu .LOG file from the zip. How can i achive this Rajesh (3 Replies)
Discussion started by: guddu_12
3 Replies

2. 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

3. Shell Programming and Scripting

compare two files, selected columns only

hi! i have two files that looks like this file 1: ABS 123 456 BCDG 124 542 FGD 459 762 file 2: ABS 132 456 FGD 459 762 output would be: from file1: ABS 132 456 BCDG 124 542 from file 2: ABS 132 456 (4 Replies)
Discussion started by: kingpeejay
4 Replies

4. Shell Programming and Scripting

Delete the lines if it matchs a selected string

HI, I need one help to generate the file based on few condition, I need to print only those line which has N and delete the line which as all Y's. ANd I need to compare only the fields which are marked as Y and N . And one more thing is in the below file 1 and file 2 and file2 abc, dbc can... (6 Replies)
Discussion started by: rashmisb
6 Replies

5. Shell Programming and Scripting

How to delete selected string from a file?

awk '!(/^$/||/--/||/selected/||/^ *$/){print "A." $1 " <> B." $1 " or"}' infile my AWK out put is : A.KZ <> B.KZ or A.KZT <> B.KZT or A.KZ_Z <> B.KZ_Z or A.LH <> B.LH or A.MAN<> B.MAN or A.OBJEKT <> B.OBJECT or A.PAK <> B.PAK ; is there any way to controle AWK to not print the... (1 Reply)
Discussion started by: kanakaraju
1 Replies

6. Shell Programming and Scripting

trying to print selected fields of selected lines by AWK

I am trying to print 1st, 2nd, 13th and 14th fields of a file of line numbers from 29 to 10029. I dont know how to put this in one code. Currently I am removing the selected lines by awk 'NR==29,NR==10029' File1 > File2 and then doing awk '{print $1, $2, $13, $14}' File2 > File3 Can... (3 Replies)
Discussion started by: ananyob
3 Replies

7. Shell Programming and Scripting

concatenating selected lines of multiple files

Hi, I would like a shell script that reads all files in a directory and concatenate them. It is not a simple concatenation. The first few lines of the files should not be included. The lines to be included are the lines from where 'START HERE' appears up to the end of the file. For example, I... (4 Replies)
Discussion started by: laiko
4 Replies

8. Shell Programming and Scripting

Need to print only selected char in a string..?

Hi, I want to print particular chars in a string. for example ie., consider " dear,. roopa$#09%~`';']" as the example string. Here, I want to print only alphanumeric chars.. suppose , if i want only alphanumeric... value would be "dear roopa09" suppose , if i want some spl char(,) with... (2 Replies)
Discussion started by: balan_mca
2 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. Shell Programming and Scripting

remove files other than selected

I wanna remove a set files other than some selected files. Eg. :rolleyes::rolleyes::rolleyes: a directory contains n files like test1.dat test2.dat test3.dat test4.dat out5.dat out1.dat i wanna remove all files which doesnot name like *test* I want to use this in shell... (22 Replies)
Discussion started by: freakygs
22 Replies
Login or Register to Ask a Question