- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Help regarding a shell script
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
Discussions
Discussions
Forums
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
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
тАО08-17-2006 09:42 PM
тАО08-17-2006 09:42 PM
Help regarding a shell script
I have got a dir structure in my home dir for FTP users which is ---
/home
|
/ftp
|
-------------USERS---------------
| | | | | |
A B C D E F |
|
|-/2006 - /Month - /Date - /1 & /2
| | |
| /a & /b /a & /b
|
|
|-/2007 - /Month - /Date - /1 & /2
| |
/a & /b /a & /b
The dir structure present under A is replicated under every user's home directory.
What I want is ---
FILES MODIFIED 7 OR MORE DAYS BACK SHOULD GET COPIED FROM "/home" TO "/archive" DIRECTORY USING THE SCRIPT.
The simple script that I could write is given below but it is not doing as to what I want
__________________________________________
DURATION=7
BACKUP=/tmp/ftp
HOME_DIR=/home/ftp
cp -rf -p `find $HOME_DIR -mtime +$DURATION | sed 's/\.\///' | sed '/.*\/.*/d'` $BACKUP
__________________________________________
It gets executed but gives me an error message at the end which is ---
./copy_file.sh: line 5: /bin/cp: Argument list too long
I also counted the no. of lines that it parses and it is 78916.
Kindly help me in resolving this problem.
Thanks in advance!!
ATUL
- Tags:
- Arg list too long
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-17-2006 10:20 PM
тАО08-17-2006 10:20 PM
Re: Help regarding a shell script
I'm attaching a .doc file depicting the directory structure for your convenience.
Kindly help me.....
Thanks....
Atul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-17-2006 11:07 PM
тАО08-17-2006 11:07 PM
Re: Help regarding a shell script
Well it seems to be OK, but how many files could be used as source for cp command? I mean how long can be the list of coping files? I think it have limited count...
So try to use FOR cycle and coping one file from list after another.
I hope you know and use this but: http://www.tldp.org/LDP/abs/html/
(nice "book" about scripting)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-17-2006 11:26 PM
тАО08-17-2006 11:26 PM
Re: Help regarding a shell script
As I know it will be....
List of file not modified in last 7 days but modified before that time.
--
Atul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-17-2006 11:35 PM
тАО08-17-2006 11:35 PM
Re: Help regarding a shell script
for File in `find $HOME_DIR -mtime +$DURATION | sed 's/\.\///' | sed '/.*\/.*/d'`; do cp $File $BACKUP; done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-17-2006 11:38 PM
тАО08-17-2006 11:38 PM
Re: Help regarding a shell script
As you suggested...I also did the same thing but removed the "sed" portion from it....
Mine looks like dis.....
DURATION=7
BACKUP=/tmp/ftp
HOME_DIR=/home/ftp
for file in [ `find $HOME_DIR -mtime +$DURATION` ]
do
cp -rf -p $file $BACKUP
done
Thank u vereeeee much for your valuable help....
--
Atul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-17-2006 11:43 PM
тАО08-17-2006 11:43 PM
Re: Help regarding a shell script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-19-2006 07:13 AM
тАО08-19-2006 07:13 AM
Re: Help regarding a shell script
find $HOME_DIR -mtime +$DURATION` -exec cp -rf -p {} $BACKUP \;
or
find $HOME_DIR -mtime +$DURATION` | xargs cp -rf -p $BACKUP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-21-2006 09:21 PM
тАО08-21-2006 09:21 PM
Re: Help regarding a shell script
The command that you mentioned is not working as I want.
What I want is that "the files or directories that are being searched for should get copied in the same way as they are present.
In other other words I should say that the directory hierarchy should be maintained at the destination as well.
I appreciate your help. Your command did work, but it doesn't copy the files as per their hierarchy.
Thanks!!
ATUL
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-21-2006 09:41 PM
тАО08-21-2006 09:41 PM
Re: Help regarding a shell script
I've attached a file with the output of few of my file names that I want to copy from the home directory location and wanna paste them inside /archive directory in the same hierarchy as they are present.
Atul