Sponsored Content
Full Discussion: Create tar file
Top Forums Shell Programming and Scripting Create tar file Post 302621327 by methyl on Tuesday 10th of April 2012 08:48:00 AM
Old 04-10-2012
Code:
[ $(du -b archive.tar  | awk '{print $1}') -gt  1600000000 ] && echo "file size is high" || echo "file size is  low"

1) The du command posted gives the result in 512 byte blocks.
2) The -b parameter to du is irrelevant in this context (and is doesn't mean bytes).

Try doing the comparison in 512 byte blocks:
Code:
[ $(du archive.tar  | awk '{print $1}') -gt  3125000 ] && echo "file size is high" || echo "file size is  low"

This User Gave Thanks to methyl For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

script to create tar file

hello, im a newbie in unix scripting. can someone pls send me a sample script that will tar files in the folders of a specific directory, but will exclude specific files, and afterwards, will ftp the tar into another server. for example: in this directory, pshrprod:/opt/psoft/weblogic/818sp9_80... (2 Replies)
Discussion started by: ajrandrup
2 Replies

2. UNIX for Advanced & Expert Users

How to create a Tar of multiple Files in Unix and FTP the tar to Windows.

Hi, On my Unix Server in my directory, I have 70 files distributed in the following directories (which have several other files too). These files include C Source Files, Shell Script Source Files, Binary Files, Object Files. a) /usr/users/oracle/bin b) /usr/users/oracle... (1 Reply)
Discussion started by: marconi
1 Replies

3. Solaris

Find files older than x days and create a consolidated single tar file.

Hello, I need help in finding files older than x days and creating a single consolidated tar file combining them. Can anyone please provide me a script? Thanks, Dawn (3 Replies)
Discussion started by: Dawn Bosch
3 Replies

4. UNIX for Dummies Questions & Answers

tar -cvf test.tar `find . -mtime -1 -type f` only tar 1 file

Hi all, 4 files are returned when i issue 'find . -mtime -1 -type f -ls'. ./ora_475244.aud ./ora_671958.aud ./ora_934052.aud ./ora_934050.aud However, when I issued the below command: tar -cvf test.tar `find . -mtime -1 -type f`, the tar file only contains the 1st file -... (2 Replies)
Discussion started by: ahSher
2 Replies

5. UNIX for Advanced & Expert Users

Create corrupted *.tar.gz file ?

Hello. I`m writing a bash script who archive log files and send them to backup server. I need some kind of checking mechanism for *.tar.gz files. I found something like: gunzip -t file.tar.gz //Not output from it. And for tar: tar tf file.tar.gz //Only lists archive 1.) I need make a... (3 Replies)
Discussion started by: jabalv
3 Replies

6. UNIX for Dummies Questions & Answers

How to create .tgz file without creating .tar file?

Hi, Could anyone help me in providing command to generate .tgz file without creating .tar file? currently i am using below command for doing the same but if tar file has big size and there is no space in drive then tgz file will not be generated. I want to generate tgz file directly without... (4 Replies)
Discussion started by: Pawan Kumar
4 Replies

7. Shell Programming and Scripting

Create tar file excluding all hard links

I have a problem with tar. Taring a folder with a lot of contents, causes the tar to contain hard links to some files, seen with the same name but 0 in size. The hard links don't exist in the first place. How can I prevent that from happening? I am using the -T option with either -n or... (2 Replies)
Discussion started by: Tribe
2 Replies

8. HP-UX

Unable to create a tar file due to link

Hi, I am trying to tar a directory structure. but unable to do due to a symbolic link. Please help indomt@behpux $ tar -cvf test.tar /home/indomt a /home/indomt symbolic link to /dxdv/03/ap1dm1 Thanks (1 Reply)
Discussion started by: nag_sathi
1 Replies

9. UNIX for Dummies Questions & Answers

How do I create a tar file for only dir and its subdir structures??

How do I create a tar file for only dir and its subdir structures?? (4 Replies)
Discussion started by: vx04
4 Replies

10. UNIX for Dummies Questions & Answers

How to create a TAR File in a Custom Destination Directory?

I want to create the tarzip file into a destination directory, i am in /var/sftp/home/archive/rquadri directory and i am using below command. However it is creating the file in the /var/sftp/home/archive/rquadri directory itself instead of /tmp, may i please know how do i resolve this. tar -cvzf... (5 Replies)
Discussion started by: Ariean
5 Replies
tar(5)								File Formats Manual							    tar(5)

Name
       tar, mdtar - tape archive file format

Description
       The tape archive command dumps several files, including special files, into one, in a medium suitable for transportation.

       A  tape or file is a series of blocks.  Each block is of size TBLOCK.  A file on the tape is represented by a header block, which describes
       the file, followed by zero or more blocks, which give the contents of the file.	At the end of the tape are two blocks filled  with  binary
       zeros, as an end-of-file indicator.

       The  blocks  are  grouped  for  physical I/O operations.  Each group of n blocks (where n is set by the option on the command line, and the
       default is 20 blocks) is written with a single system call; on 9-track tapes, the result of this write is a single tape record.	 The  last
       group  is  always  written at the full size, so blocks after the two zero blocks contain random data.  On reading, the specified or default
       group size is used for the first read, but if that read returns less than a full tape block, the reduced block size  is	used  for  further
       reads.

       The following is an example of a header block:
       #define TBLOCK  512
       #define NAMSIZ  100

       union hblock {
	       char dummy[TBLOCK];
	       struct header {
		       char name[NAMSIZ];
		       char mode[8];
		       char uid[8];
		       char gid[8];
		       char size[12];
		       char mtime[12];
		       char chksum[8];
		       char linkflag;
		       char linkname[NAMSIZ];
		       char rdev[6]
	       } dbuf;
       };

       The  name  field  is  a	null-terminated string.  The other fields are 0-filled octal numbers in ASCII.	Each field (of width w) contains w
       minus 2 digits, a space, and a null, except size and mtime , which do not contain the trailing null.  The name field specifies the name	of
       the  file,  as  specified  on  the command line.  Files dumped because they were in a directory that was named in the command line have the
       directory name as prefix and /filename as suffix.  The field specifies the file mode, with the top bit masked off.  The uid and gid  fields
       specify	the  user  and group numbers that own the file.  The size field specifies the size of the file in bytes.  Links and symbolic links
       are dumped with this field specified as zero.  The mtime field specifies the modification time of the file at the time it was dumped.   The
       chksum  field  is a decimal ASCII value, which represents the sum of all the bytes in the header block.	When calculating the checksum, the
       chksum field is treated as if it were all blanks.  The linkflag field is ASCII 0 if the file is normal or a special file and ASCII 1 if	it
       is  a  hard  link,  and	ASCII  2  if it is a symbolic link.  The name to which it is linked, if any, is in linkname, with a trailing null.
       Unused fields of the header are binary zeros and are included in the checksum.  The rdev field encodes the ASCII representation of a device
       special file's major and minor device numbers.

       The  first  time  a given i-node number is dumped, it is dumped as a regular file.  The second and subsequent times, it is dumped as a link
       instead.  Upon retrieval, if a link entry is retrieved, but not the file it was linked to, an error message is printed and the tape must be
       manually rescanned to retrieve the linked file.

       The encoding of the header is designed to be portable across machines.

Restrictions
       Names or link names longer than NAMSIZ produce error reports and cannot be dumped.

See Also
       tar(1)

																	    tar(5)
All times are GMT -4. The time now is 12:24 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy