so the operators, once they complete their projects, will move their project folders in the dir "to_be_archived" and once in there the script will take over/handle it and dump the output tar to dir "archived_projects"
lets say the operators have just started moving the project folder into the dir "to_be_archived" and my script is running and it intercepts the new project folder but the project folder is still growing in size, i dont want it to start of the process as they are still moving the project folder to the dir "to_be_archived"
... ... ...
Hi Robert,
You didn't pay close enough attention to what I suggested in post #40: I said it would be much better if you would create a hidden directory under /to_be_archived (such as /to_be_archived/.in_progress), have your operators move everything into a sub-directory under that directory (such as /to_be_archived/.in_progress/project), and then after that project directory contains everything your operators want to archive, have them issue the command:
Your existing script WILL NOT SEE /to_be_archived/.in_progress nor any directories under it. (That is why it is called a hidden directory.) After your operators have completed copying files into /to_be_archived/.in_progress/project, then, and only then, as the final step they issue the mv command that will make the completed project directory visible to your existing script.
If you don't believe that this works, run the following simple script to see that hidden directories will not be visible to your script:
Code:
#!/bin/ksh
# Create a file hierarchy with one hidden project and one visible project:
mkdir junk junk/.hidden junk/.hidden/project2 junk/project1
cd junk
touch project0.tar project1/file1 project1/file2
touch .hidden/project2/hfile1 .hidden/project2/hfile2
echo 'File hierarchy with project2 directory hidden:'
ls -laR # Note that if the -a is left out, ls will not see hidden files either.
echo
# The following is similar to the code you are using, but skips over artifacts
# left over from failed attempts to archive arvhive0.
for DIR in *
do if [ ! -d "$DIR" ]
then printf 'Skipping non-directory file "%s".\n' "$DIR"
continue
fi
printf 'Found file "%s" before moving hidden directory.\n' "$DIR"
# Perform the rest of your script to archive this project...
done
printf '\nNote that .hidden and project2 should not appear above.\n\n'
# Add some more files to project2 (This could be done in parallel with running
# your current script since these files are still hidden from your script.
touch .hidden/project2/hfile3 .hidden/project2/hfile4
# Now make the hidden project2 visible
mv .hidden/project2 project2
echo 'File hierarchy with project2 directory moved out from under hidden directory.'
ls -laR
echo
for DIR in *
do if [ ! -d "$DIR" ]
then printf 'Skipping non-directory file "%s".\n' "$DIR"
continue
fi
printf 'Found file "%s" after moving hidden sub-directory.\n' "$DIR"
done
printf '\nNote that project2 should now appear above but .hidden is still not seen.\n'
# Now clean up after ourselves...
cd -
rm -rf junk
Hi.
I'm trying to copy multiple folders from the remote machine to the local machine. I wrote a batch file to run an ftp window.
The problem I am having is that the only command to copy files is mget *, and this copies only files, not folders.
For example, ftp ts555
cd ts555/test
' test... (5 Replies)
I have written a shell script to perform backups using tar, rsync and optionally utilise lvm snapshots. The script is not finished but is in a working state and comments/descriptions are poor.
I would greatly appreciate any criticism and suggestions of the script to help improve my own learning... (0 Replies)
I have in directory /media/AUDIO/WAVE many .mp3 files with names like:
my filename_01of02.mp3
my filename_02of02.mp3
Your File_01of06.mp3
Your File_02of06.mp3
etc....
In the same directory, /media/AUDIO/WAVE, I have many folders with names like
9780743579490
9780743579491
etc..
Inside... (7 Replies)
I have 1000's of directories which is named as numbers. Each directory contains multiple files. Each of these directories have a file named "att". I need to rename all the att files by adding the directory name followed by "_" then att for each of the directories.
Directories
120
att... (2 Replies)
Hi all,
I have a tar file and inside that tar file is a folder with additional tar.gz files. What I want to do is look inside the first tar file and then find the second tar file I'm looking for, look inside that tar.gz file to find a certain directory. I'm encountering issues by trying to... (1 Reply)
I would like to confirm my file.tar is been tar-ed correctly before I remove them. But I have very limited disc space to untar it.
Can I just do the listing instead of actual extract it? Can I say confirm folder integrity if the listing is sucessful without problem?
tar tvf file1.tar
... (1 Reply)
Hi All,
I have to requirement to write a shell script to move file from one folder (A) to another five folder (B,C,D,E,F) and destination folder should be blank. In not blank just skip.
This script will run as a scheduler every 2 minutes. It will check number of files in folder A and move 1 to... (9 Replies)
Good day, everyone!
I'm very new to bash scripting. Our teacher gave us a task to create a script that basically does the same job the 'du' command does, with the difference that 'du' command gives an output in the form of
<size> <folder name>and what we need is
<folder name> <size>As for... (1 Reply)
1. The problem statement, all variables and given/known data:
The task is to create a script that would reproduce the output of 'du' command, but in a different way: what 'du' does is:
<size> <folder name>and what is needed is
<folder name> <size>We need to show only 10 folders which are the... (3 Replies)
HI Guys,
I have some 8 files with different name and extensions. I need to check if they are present in a specific folder or not and also want that script to show me which all are not present. I can write if condition for each file but from a developer perspective , i feel that is not a good... (3 Replies)