I am fairly new to shell scripting and I am trying the following:
My shell script creates a tar file with files with the ending ~. The directory - where the files and sub directories are located - comes as a parameter when I call the script. Files that are archived will be written in a log /var/log/ttl.log and files that have been archived shall be deleted. Deleted files shall also be written in the log under /var/log/ttl.log. Files with the ending ~ in sub directories shall not be deleted. I hope this makes sense.
What I have so far:
This works, but the files are not deleted . Can someone point me in the right direction please?
Another thing: How would I go about deleting the files in the sub directories as well as a next step of my script?
OK, discover all files ending with ~ in or under the current dir and put them in a tar. Log what is in the tar. Delete top level files in the archive. Log deleted files.
I usually get the file names from the tar itself, so nothing is deleted if I cannot list the tar error free. Delete list can be kept in an env var, so temp files are not needed, just pipes. First pipeline is "find ...|tar c..." archive all tilde files. Second pipeline is "dlist=`tar t ... | tee -a logfile | grep -v / `" logs all archived. Then just "delete $dlist" and "echo $dlist >>logfile". Put appropraite headings and trailers in the log, too, and time stamps from 'date'.
Quick question,
is it possible to make a Tar of completely directory and placing the tar file in it (will this cause even the tar file to tarred ?)
sample:
/opt/freeware/bin/tar -cvf - /oracle | gzip > /oracle/backup.tgz
will the tar file backup.tgz also include backup.tgz ?
i tried... (5 Replies)
Hi,
I'm successfully written a script which tar a directory and ssh's it over a remote server
tar cfv - $SDIR | ssh $RHOST "cat > $DDIR/backup.$BKPEXT.tar"
However, Im unable to log the activity to a file. i.e for example if I do
tar cfv - $SDIR | ssh $RHOST "cat >... (1 Reply)
Hi all,
In Solaris howto extract tar file to specific folder.
This is what we do in Linux, but how to do the same thing in Solaris ?
-tar -xzvf /tmp/etc.tar.bz -C /tmp
(Will extract in /tmp dir)
3.gzip COMPRESSION AND EXTRACTION
-tar -czvf /tmp/etc.tar.bz /etc
-du ... (5 Replies)
Good day to everyone. This is my first time posting and just barely above basic Unix training. I think i have search thoroughly to ensure my question hasn't already been posted. But on the off chance the answer has been posted, please be nice as I am not 100% sure I know what I am looking for.
I... (1 Reply)
Hi All,
I am writing a script where it updates a file in an unix account.
To update that file i need to be logged in as that account user.
say account name is ab01 and its password is passab01.
What i want to do is, my script should read login id and password from a parameter file and... (4 Replies)
Hello,
We need to log the operations that specific user on Solaris 10 (SPARC) is performing on one directory and it's contents. I was able to configure solaris auditing service (auditd) and it works fine. The only problem is that auditd logs huge amount of unneeded information. We need to log... (0 Replies)
Dear all
I want to create a tar file which contains all executable files in a specific directory
cd /appl/home/
file some_exe
some_exe: 64-bit XCOFF executable or object module not stripped
My current approach is to tar it one by one
tar -cvf test.tar exefile1
tar -uvf test.tar... (2 Replies)
hi,
i face some problem which need URGENT assistance.
am performing a restoration for recovery in an AIX UNIX server.
when i use the tar -tvf command to view the tape contents,
it gives me /ata1/mydir/myfile.
i understand that how the file was backed up determine whether we could restore... (2 Replies)
I want to insert file to tar file (by tar command).
The file is currently in a diffrenet directory and i want to be saved
at the tar file as it was in other directory.
I write the script in korn shell. How can i do it? (0 Replies)
anyone know if it is possable to extract a subdirectory in a tar file.
IE
tarfile contains
parent dir
-sub dir A
-sub dir B
I want to extract sub dir B. (2 Replies)