Find the answer to your Linux question:
Results 1 to 2 of 2
This is stupid. I'm trying to recursively copy all files from one main directory to another. Example: directory1 contains: a.txt b/c.txt b/d.txt directory2 contains: e.txt b/f.txt The end result for ...
  1. #1
    Just Joined!
    Join Date
    Dec 2004
    Location
    localhost
    Posts
    56

    Help with cp command!

    This is stupid. I'm trying to recursively copy all files from one main directory to another.

    Example:
    directory1 contains:
    a.txt
    b/c.txt
    b/d.txt

    directory2 contains:
    e.txt
    b/f.txt

    The end result for directory2 should be:
    a.txt
    e.txt
    b/c.txt
    b/d.txt
    b/f.txt

    Well, whatever I do with the cp command, it doesn't work. Here's my current script:
    Code:
    echo Copying /addons
    cp -rf mods/addons/* cstrike/addons/
    echo Copying /cfg
    cp -rf mods/cfg/* cstrike/cfg/
    echo Copying /materials
    cp -rf mods/materials/* cstrike/materials/
    echo Copying /sound
    cp -rf mods/sound/* cstrike/sound/
    echo ----------------
    echo Done.
    echo ----------------
    Edit: Okay, it works when it's NOT in a shell (ie, I manually input each command into the command-line). I'd like it to work in a shell script.

  2. #2
    Linux Newbie jpalfree's Avatar
    Join Date
    Jul 2005
    Location
    Montreal, CA
    Posts
    198
    every shell script must have the following line at the top of the file:
    Code:
    #!/bin/bash
    You must also make the script executable: chmod +x YOURSCRIPT

    Hope that helps.
    Avatar from xkcd.com, a hilarious computer related webcomic.

Posting Permissions

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