Sponsored Content
Full Discussion: Archive won't move
Top Forums UNIX for Dummies Questions & Answers Archive won't move Post 302678201 by jrymer on Friday 27th of July 2012 11:57:02 AM
Old 07-27-2012
Archive won't move

I' writing a script trying to archive the oldest two directories from one place, tar them, and move them to another.

Code:
#!/bin/bash

cd (/dir/with/dirforarchiving)
ARCHIVE=(/temp/dir/)
FIND=$(find . -maxdepth 1 -type d)
ARRAY=(`ls ${FIND} -ltd | tail -2`)

names=(${ARRAY[7]} ${ARRAY[15]})
dates=(${ARRAY[5]} ${ARRAY[13]})

for i in {0..1}
do
        CUT=$(echo ${dates[$i]} | cut -d- -f1,2)
        if [[ -d ${ARCHIVE}${CUT[$i]} ]]
        then
                tar -zcvf ${names[$i]}.tar.gz ${names[$i]}
                mv ${names[$i]}.tar.gz ${ARCHIVE}${CUT[$i]}
        else
                mkdir ${ARCHIVE}${CUT[$i]}
        fi
done

The problem I'm running into is that the oldest two directories, and some others, were created the same month, date, and different only because their modification time was one or two minutes apart. The oldest two have dates of 2012-07-25, when I run the directory exists check, it will created the directory 2012-07 and move ONE of the two targeted directories into it, the other tar does not go in the target directory but one level up. I want it in /temp/dir/2012-07 one of them goes into that and the other goes to /temp/dir.

How can I fix this?
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

why won't this Work?

hey programmers! 1-why won't gcc accept as an argument? i tried the recommendations on the man page of getch(),..etc. nothing worked. 2-why it won't see <iostream> && <fstream> even if i implemented the function as follow std::cout<<"..etc"<<endl; 3-after i type this code in it gives... (6 Replies)
Discussion started by: mbabeli
6 Replies

2. UNIX for Dummies Questions & Answers

HP 10.20 Won start

After I log ino the machine, a window pops up indicating that I should check that the HOSTNAME is the same in these three files /etc//rc.configd/netconf /etc/hosts /var/adm/inetd.sec How do I change the hostname in these files? Thanks, Mike h (1 Reply)
Discussion started by: hutchin
1 Replies

3. AIX

won't mount /usr...won't boot fully

Hello: NOOB here. I attempted to use smit mkcd. Failed on first attempt, not enough space. 2nd attempt tried to place iso on /usr, not enough space there. Cleanup ran for about 5 minutes after aborting. Now AIX won't boot. LCD display on 7029-6E3 says: 0517 MOUNT /USR. Attempted to boot from CD... (11 Replies)
Discussion started by: bbird
11 Replies

4. UNIX for Dummies Questions & Answers

sample script to archive & move previous day syslog files

hi all. Please help me with archiving previous day syslog files. the files have no extension and have the format YYYY-MM-DD. I want to archive the file then move it to some other machine. thanks. (2 Replies)
Discussion started by: coolatt
2 Replies

5. Shell Programming and Scripting

Extracting from archive | compressing to new archive

Hi there, I have one huge archive (it's a system image). I need sometime to create smaller archives with only one or two file from my big archive. So I'm looking for a command that extracts files from an archive and pipe them to another one. I tried the following : tar -xzOf oldarchive.tgz... (5 Replies)
Discussion started by: chebarbudo
5 Replies

6. AIX

xntpd won't stay up...

AIX 5.3-5300.09.06.1013 (AIX 5.3 TL9 SP6) # startsrc -s xntpd -a "-x" (with -x at the end of the xntpd line in /etc/rc.tcpip, too.) will run for 5-15 minutes, and then die. # errpt -a with a search on xntpd gives me this: ------------------------------------------------ LABEL: ... (7 Replies)
Discussion started by: dafydd2277
7 Replies

7. Shell Programming and Scripting

Archive & move the file

I have a set of files in path /ifx01/etldata/lmt/ a.xml b.xml I have to archive & move these files to path /ifx01/etldata/archive ,so that not even the original files should exists. After acrhiving there should be no files in path /ifx01/etldata/lmt/ (6 Replies)
Discussion started by: jagadeeshn04
6 Replies

8. Shell Programming and Scripting

Move all files from dir and subdir to Archive with File name as complete path_filename

HI, I need to move all files from a dir & its all subdir to Archive folder which is indise dir only. and moved filename should changed to complete path ( Like Dir_subdir_subdir2_.._filename ). also all files names shoud capture in a file in order to mail I written below code ... (11 Replies)
Discussion started by: minijain7
11 Replies

9. Shell Programming and Scripting

Script to archive logs and sftp to another archive server

Requirement: Under fuse application we have placeholders called containers; Every container has their logs under: <container1>/data/log/fuse.log <container1>/data/log/fuse.log.1 <container1>/data/log/fuse.log.XX <container2>/data/log/fuse.log... (6 Replies)
Discussion started by: Arjun Goswami
6 Replies

10. UNIX for Beginners Questions & Answers

Bash script won't run because hardware won't produce display

Can anyone offer any advice on how to modify the script below to work on a new system we have, that has no graphics capability? We admin the system through a serial RAS device. I've tried running the below script through the RAS and through an ssh -X session. It failed with something like "GTK... (3 Replies)
Discussion started by: yelirt5
3 Replies
bup-margin(1)						      General Commands Manual						     bup-margin(1)

NAME
bup-margin - figure out your deduplication safety margin SYNOPSIS
bup margin [options...] DESCRIPTION
bup margin iterates through all objects in your bup repository, calculating the largest number of prefix bits shared between any two entries. This number, n, identifies the longest subset of SHA-1 you could use and still encounter a collision between your object ids. For example, one system that was tested had a collection of 11 million objects (70 GB), and bup margin returned 45. That means a 46-bit hash would be sufficient to avoid all collisions among that set of objects; each object in that repository could be uniquely identified by its first 46 bits. The number of bits needed seems to increase by about 1 or 2 for every doubling of the number of objects. Since SHA-1 hashes have 160 bits, that leaves 115 bits of margin. Of course, because SHA-1 hashes are essentially random, it's theoretically possible to use many more bits with far fewer objects. If you're paranoid about the possibility of SHA-1 collisions, you can monitor your repository by running bup margin occasionally to see if you're getting dangerously close to 160 bits. OPTIONS
--predict Guess the offset into each index file where a particular object will appear, and report the maximum deviation of the correct answer from the guess. This is potentially useful for tuning an interpolation search algorithm. --ignore-midx don't use .midx files, use only .idx files. This is only really useful when used with --predict. EXAMPLE
$ bup margin Reading indexes: 100.00% (1612581/1612581), done. 40 40 matching prefix bits 1.94 bits per doubling 120 bits (61.86 doublings) remaining 4.19338e+18 times larger is possible Everyone on earth could have 625878182 data sets like yours, all in one repository, and we would expect 1 object collision. $ bup margin --predict PackIdxList: using 1 index. Reading indexes: 100.00% (1612581/1612581), done. 915 of 1612581 (0.057%) SEE ALSO
bup-midx(1), bup-save(1) BUP
Part of the bup(1) suite. AUTHORS
Avery Pennarun <apenwarr@gmail.com>. Bup unknown- bup-margin(1)
All times are GMT -4. The time now is 11:11 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy