- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Shell script of copy files from one directory to a...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2002 08:35 PM
10-13-2002 08:35 PM
It copies the files from the first argument directory to the second argument directory and deletes all the files in the first argument directory.
The script must do the right level of checking of the arguments first. For example: when the second directory does not exist, or when the second directory exists, but not the first one.
Can someone help?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2002 10:51 PM
10-13-2002 10:51 PM
Re: Shell script of copy files from one directory to another
-b-
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2002 11:22 PM
10-13-2002 11:22 PM
Solutionif [ ! -d "$1" ]
then
echo "Source directory $1 does not exist"
exit 1
fi
if [ ! -d "$2" ]
then
echo "Destination dir $2 does not exist"
exit 2
fi
mv $1 $2 # mv copies first then deletes $1
Save it to a script called say copy.sh then run it as ./copy.sh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2002 11:28 PM
10-13-2002 11:28 PM
Re: Shell script of copy files from one directory to another
If this an assignment / question then Stefan has shown you how, so look at the structute and then make it your own by useing copy instead of move with check routines to ensure that the files in the destination dirs match the files in the target dirs and perhaps also log the results.
Paula
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2002 03:56 AM
10-15-2002 03:56 AM
Re: Shell script of copy files from one directory to another
To move a directory structure:
Let's move /a/b/c/dir1 to /x/y/dir1
cd /a/b/c
find dir1 -print | cpio -pdumvc /x/y
This will create "dir1" under /x/y.
Then to remove /a/b/c/dir1,
cd /a/b/c
rm -r dir1
Why would you do something like this?
The current filesystem of /a/b/c/dir1 is being reassigned to another computer. Or /a/b/c is running out of room. Or you set up a project at /a/b/c, and someone later says they want it at another spot.
Of course you have to be careful. "rm -r" is obviously powerful. Have backups. Do this when no one is on the system. Coordinate the action, etc.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2002 06:08 AM
10-15-2002 06:08 AM