Need some script if possible

Discussion in 'Programming/Scripts' started by karabaja, Aug 18, 2006.

  1. karabaja

    karabaja New Member

    I need some files to be copied to a different folder. I have to setup a script which downloads a file called, but the problem is that this file is extracted every time to a folder with different name. I think this file is updated weekly and and then folder in which files are extracted is for example

    Now is there a way for me to copy all files in that folder to another location. It contains like 50 txt files. I only need to copy txt files, not the folder itself.
    I'd like to setup a cron which would copy these files. But I am not sure how since I can't specify a path which would change every week, even though the name of txt files is always the same.

    Another thing I could use a help with is, is there some command or more of them I could use to insert two words at the very beginning and the end of those files. Like to insert "start" and "end" in each file.

    One last thing is how could I rename all .txt files in a folder to .html ?

    Thank you in advance, I hope my question is understandable. I am a beginner and English is not my native language.
  2. karabaja

    karabaja New Member

    Ok, you can scratch that last one out. I found a way to use them in txt form. But I need to wrap that text with <pre> tag to display it properly on the page. I can use sed to replace first word of the document they all have in common and that is not needed anyway.
    But I still need a way to copy them and the way to insert </pre> at the end of each file.
  3. karabaja

    karabaja New Member

    Ok, I am narrowing it down :)

    I found out that I could use unzip -j to so that folder structure is not recreated.

    Now I need a way to insert </pre> at the end of each file.
  4. falko

    falko Super Moderator ISPConfig Developer

    How about
    echo "</pre>" >> /path/to/file
  5. karabaja

    karabaja New Member

    Yes. That works, thx.
    Another thing please if someone could answer. Can I have sed save output to the same file.
    Like if I want to change first word of a file now I have to specify it to create output in another file.
    Last edited: Aug 19, 2006

Share This Page