Find the answer to your Linux question:
Results 1 to 3 of 3
Hello. I have a question and I wasn't sure in which thread I should write about it, so I open a new thread. I hope that's okay. I'm new in ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Mar 2013
    Posts
    2

    Sync files


    Hello.

    I have a question and I wasn't sure in which thread I should write about it, so I open a new thread. I hope that's okay.

    I'm new in Linux and I have a homework to do a task: . Write a script that keeps your startup files ('~/.[a-z]*') synchronized among all the machines on which you have an account. Schedule this script to run regulary from cron. (Is is safe to blindly copy every file whose name starts with a dot? How will you handle directories? Should files being replaces on the destination machines be backed up before they are overwritten?)

    I asked the teacher what exactly I have to do but I don't know if I understood it good. I found a command crontab, for example * * * * * /somefile and this means that the file will be sync every minute, hour and so on.. So first I must found files which start with . I tried to found these files which started with . : ls -a | grep '~/.[a-z]*', but nothing happened, so I don't know if I did it right. I don't understand what should I do: "Schedule this script to run regulary from cron" ? I have an idea how to connect a command which finds files which start with . and then a command I wrote before (* * * * */files_which_start_with_point). Then I would create a ramdisk (mount) and copy all files there. But I don't know how to check which files I should copy...

    Please help me, I would be thankful if you give me some links which would explain this "easy to understand".
    Have a nice day,
    Talijana

  2. #2
    Linux Guru
    Join Date
    Oct 2007
    Location
    Tucson AZ
    Posts
    3,190
    Although posting homework questions is against forum rules, you seem to have made some effort and are looking for sources so, for finding hidden files (which start with . see the link below for several examples) This will display hidden files in the current working directory.

    Bash Shell: Display All Hidden Dot Files In a Directory

    You seem to be referring to startup files per user rather than system startup files, correct? To list hidden directories in the current working directory:

    Code:
    ls -d .*/
    I'm not sure what your question is about 'blindly copying files which begin with a ." means. Copying should not be a problem, moving or deleting definitely will be.
    cron is use to run a script at a scheduled date/time and there are thousands of sites with specific, detailed tutorials including examples.
    Last edited by yancek; 03-27-2013 at 12:46 AM.

  3. #3
    Just Joined!
    Join Date
    Mar 2013
    Posts
    2
    Thank you a lot! I did something, but I will also one more time ask the teacher for more informations and help. But now I have a problem and I don't know what is wrong. If I'm writing in the wrong thread please remind me. It's about awk. I did the simple test. I wrote this script:
    #!/bin/awk -f
    BEGIN{
    printf $1;
    exit;}
    END {}
    test.txt

    And nothing happend. But when I wrote this command in the terminal: echo | awk '{print $1}' test.txt it works! What's wrong with my script? I also tried printf system($1) and nothing..I tried to set the FS separator and nothing..I run the script: awk -f test.awk. Please help me.
    Thank you for everything!
    Talijana

  4. $spacer_open
    $spacer_close

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •