Sponsored Content
Top Forums Shell Programming and Scripting Unix Commands to check a file is compressed or not? Post 302350641 by thegeek on Friday 4th of September 2009 11:28:31 AM
Old 09-04-2009
file is the command which can show the file type.

When you give "file <FILENAME>", that will show the what type of compression also...


Code:
$ file test.gz 
test.gz: gzip compressed data, from Unix

There could be better ways to use it inside programs.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Check if file compressed or not

Is there a way I can check if a file is comppressed or not? (Be it tar/gzip or compress). trying to write a generic housekeeping scrit that will delete files over 6 months old and compress any uncompressed files if less than 6 months old. But not sure if there is a clever way to check except for... (4 Replies)
Discussion started by: badg3r
4 Replies

2. Shell Programming and Scripting

Unix file editting commands

ok, are there any other file editting commands out there other than the below that comes with sunsolaris & linux vi, emacs, ed, (1 Reply)
Discussion started by: Terrible
1 Replies

3. Shell Programming and Scripting

Is there any commands to check the dynamic changes of a file

Hi guys i had a script which will generate a log file.Is there any commands to check the dynamic changes in the log file,i.e if i open the log file i should able to see the updating changes live...I hope u understand my query... (2 Replies)
Discussion started by: vinoo
2 Replies

4. Shell Programming and Scripting

check to see if a file is compressed before trying to compress

I simply need to compress all files in a directory that are not already compressed and that are older than 10 days? I have this so far. I need to add to this so I don't try and compress file that are already compressed. Or if you think this can be simplified let me know. Thx. find... (3 Replies)
Discussion started by: rstone
3 Replies

5. UNIX for Dummies Questions & Answers

check for a file and run some commands

Hi all, Can you guys please help me with this... I am on AIX and need to prepare a script which will 1. check for a file named do_backup in the current file system 2. If the file exists i need to run some commands and exit, if the file doesn't exist then sleep for 15 mins and try... (2 Replies)
Discussion started by: family_guy
2 Replies

6. UNIX for Advanced & Expert Users

Check EOF char in Unix. OR To check file has been received completely from a remote system

Advance Thanks. (1) I would like to know any unix/Linux command to check EOF char in a file. (2) Or Any way I can check a file has been reached completely at machine B from machine A. Note that machine A ftp/scp the file to machine B at unknown time. (5 Replies)
Discussion started by: alexalex1
5 Replies

7. Shell Programming and Scripting

Reading UNIX commands from file and redirecting output to a file

Hi All I have written the following script: #!/bin/ksh while read cmdline do echo `$cmdline` pid="$cmdline" done<commands.txt =========== commands.txt contains: ps -ef | grep abc | grep xyz |awk '{print $2}; My objective is to store the o/p of the command in a variable and do... (8 Replies)
Discussion started by: rahulparo
8 Replies

8. Shell Programming and Scripting

Need unix commands to delete records from one file if the same record present in another file...

Need unix commands to delete records from one file if the same record present in another file... just like join ... if the record present in both files.. delete from first file or delete the particular record and write the unmatched records to new file.. tried with grep and while... (6 Replies)
Discussion started by: msathees
6 Replies

9. UNIX for Dummies Questions & Answers

Unix (compressed archieve, non-verbose)

I'm confusing with this question. :wall: Can any one tell me how to do and use which command? :confused: create a compressed archive of the "Test" directory and it's contents, called Test.tar.gz, and place it in the current directory. Use a non-verbose tar command with a single string, including... (5 Replies)
Discussion started by: wk9031
5 Replies

10. UNIX for Advanced & Expert Users

FTP commands to check the file status

Hi Experts, Can some one let me know the FTP commands to check the file status i.e i want to check whether my files are locked or in open status. I am connecting FTP from local machine. Regards, Spidy (1 Reply)
Discussion started by: spidy
1 Replies
ARCHIVE_WRITE_FILTER(3) 				   BSD Library Functions Manual 				   ARCHIVE_WRITE_FILTER(3)

NAME
archive_write_add_filter_bzip2, archive_write_add_filter_compress, archive_write_add_filter_gzip, archive_write_add_filter_lzip, archive_write_add_filter_lzma, archive_write_add_filter_none, archive_write_add_filter_program, archive_write_add_filter_xz LIBRARY
Streaming Archive Library (libarchive, -larchive) SYNOPSIS
#include <archive.h> int archive_write_add_filter_bzip2(struct archive *); int archive_write_add_filter_compress(struct archive *); int archive_write_add_filter_gzip(struct archive *); int archive_write_add_filter_lzip(struct archive *); int archive_write_add_filter_lzma(struct archive *); int archive_write_add_filter_none(struct archive *); int archive_write_add_filter_program(struct archive *, const char * cmd); int archive_write_add_filter_xz(struct archive *); DESCRIPTION
archive_write_add_filter_bzip2(), archive_write_add_filter_compress(), archive_write_add_filter_gzip(), archive_write_add_filter_lzip(), archive_write_add_filter_lzma(), archive_write_add_filter_xz(), The resulting archive will be compressed as specified. Note that the compressed output is always properly blocked. archive_write_add_filter_none() This is never necessary. It is provided only for backwards compatibility. archive_write_add_filter_program() The archive will be fed into the specified compression program. The output of that program is blocked and written to the client write callbacks. RETURN VALUES
These functions return ARCHIVE_OK on success, or ARCHIVE_FATAL. ERRORS
Detailed error codes and textual descriptions are available from the archive_errno() and archive_error_string() functions. SEE ALSO
tar(1), libarchive(3), archive_write(3), archive_write_format(3), archive_write_set_options(3), cpio(5), mtree(5), tar(5) BSD
February 2, 2012 BSD
All times are GMT -4. The time now is 03:02 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy