Simple archiving


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Simple archiving
# 1  
Old 03-24-2012
Simple archiving

Hi,

I am a UNIX novice and was trying to write a bash script that would read two parameters, $1 would be the archive file path where the archiving path is passed, so the archiving script will write to this file path. The second parameter will be the directory path to the library which will contain the files to be archived. For this exercise I am using James Goseling's archiving script:
Code:
for i do
  echo"echo x-$i"
  echo"cat>$i<<'Stop!Here!'"
  cat $i
  echo"Stop!Here!"
done

I know that I will have to call this script recursively if I am to use it as a function and pass on to it the above mentioned parameters, but I don't know how to do it recursively. Could anyone please give me a hint?
Thank you!

I am running into a new problem, namely I am getting : line 32: syntax error: unexpected end of file
I have modified the original code to:
Code:
#!/bin/bash



NONE='\033[0m'
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'

#alias chdir="cd $2"

if (( $# != 2 ))
  then
  printf "${RED}Error: There should be exactly two command-line arguments.\n${NONE}"
  read junk
fi

#cd "$2"

chmod 700 $1
function archive {

   echo "echo x - $i"
   echo "cat>$i<<'Stop!Here!'"
   cat $i
   echo "Stop!Here!" }

for i do
    archive ./$2 * > ./$1
done

Can anyone please help me understand why I am getting this error.
Thank you

Moderator's Comments:
Mod Comment How to use code tags when posting data and code samples.

Last edited by pernuntium; 03-26-2012 at 03:58 PM.. Reason: Please use code tags for data and code samples, thank you
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Logs archiving

Hi , Might be the very basic question and most frequent one also.. wanted to archive the logs/files older than one month or older than 30 days to some particular location. File/log format is like below ABCD_EF_GHIJ_Defaulter_Report_(06-Jun-2014_11-50-20_AM) Source : /test/ABC... (3 Replies)
Discussion started by: Riverstone
3 Replies

2. Shell Programming and Scripting

Archiving the files

hi, Am trying to acrhive a bunch of files on some ftp site and somehow managed to come out with the below logic. I'm getting "syntax error: unexpected end of file" error. Interestingly this below snipeet works fine if run for the first time but the subsequent runs fail! Anybody has any idea... (3 Replies)
Discussion started by: Amee5
3 Replies

3. Shell Programming and Scripting

Archiving in Perl

Hi Guys i am experiencing this problem when trying to archive a file in perl. the files name is created dynamically. (my $date = `date +"%d%m%Y"`;) `tar czf /opt/memex/backups/Complete$date.tar.gz /opt/memex/backups/Complete$date`; error message: tar: Cowardly refusing to create an empty... (4 Replies)
Discussion started by: Grant Pryor
4 Replies

4. Shell Programming and Scripting

Archiving the files

Hi, Suppose I have 2 files of yesterday's. And today I have received 3 files. Before processing anything I want to archieve the 2 files of yesterday's into a different folder. How can this be done? Regards, Sunitha (1 Reply)
Discussion started by: Sunitha_edi82
1 Replies

5. Shell Programming and Scripting

Archiving by Time

Hi all. I am trying to set up archiving of directories, such that I keep every directory made in the past week, but just one directory per week beyond that. Using the find command, I can easily delete everything more than one week old, but can not figure out how to save one. Each directory... (4 Replies)
Discussion started by: aefskysa
4 Replies

6. Shell Programming and Scripting

creating a simple archiving script

Im trying to create a script to archive specified directories into a specified tarball backup file. This is what i want the input to look like ex. save -i '/bin/b*' -i '/bin/ls' -o backup this is what i have #!/bin/bash #save - backup file script unset myInput unset myOutput while... (3 Replies)
Discussion started by: lensmen
3 Replies

7. Shell Programming and Scripting

Archiving

Hi, I want to archive below directory ex: /home/oracle/dd0 sub-directories in dd0 /home/oracle/dd0/backup/backup1 /home/oracle/dd0/backup/backup2 /home/oracle/dd0/dmp ....etc I want a command(tar) which will let me archive the above directory excluding *.dmp(dump files), *.log(log... (1 Reply)
Discussion started by: dreams5617
1 Replies

8. Shell Programming and Scripting

Archiving Users

Hello Gurus, I have a requirement where I have to remove users that have not logged into our unix box last 90 days. I want to script this one and remove the users automatically now and then. Has any one ever done this before, if so please give me some sample code. I am not a good unix... (2 Replies)
Discussion started by: suseesk
2 Replies

9. UNIX for Dummies Questions & Answers

Archiving

I am looking for some advice. I have some files on a Unix server, which contain symbolic links. I need to copy these over to a nfts environment, but wish to keep the symbolic links intact. Any ideas? (7 Replies)
Discussion started by: rmasonuk
7 Replies
Login or Register to Ask a Question