Separate the apache user file and move or copy some were


 
Thread Tools Search this Thread
Operating Systems Linux Red Hat Separate the apache user file and move or copy some were
# 1  
Old 03-29-2014
RedHat Separate the apache user file and move or copy some were

Hi all,

I'm Using Centos 6.4

/opt/my_aplication/entry/data/0/

There are Thousands of files in this Directory, Only i need to copy or move the apache User's file from this to /tmp/backup , I have listed apache user's file using
Code:
find . -user apache -type f

, its gave me the only apache user's files, How can i move it are copy the file to /tmp/backup , Will any one guide me ..

Code:
-rw-r--r-- 1 root   root    5.9K May 20  2013 0_zbdon0vx_0_ccueldeq_0.conv.log
-rwxrwxrwx 1 apache apache   24M May 20  2013 0_x92m4dn5_0_te65kj69_2.mp4
-rwxrwxrwx 1 root   root    171K May 20  2013 0_x92m4dn5_0_kfemau7m_2.jpg
-rwxrwxrwx 1 root   root    7.2M May 20  2013 0_x92m4dn5_0_4xwn4t6g_1.flv
-rw-r--r-- 1 root   root    7.4K May 20  2013 0_x92m4dn5_0_4xwn4t6g_0.conv.log
-rwxrwxrwx 1 root   root     15M May 20  2013 0_x92m4dn5_0_n1pqrefn_1.flv
-rw-r--r-- 1 root   root    7.6K May 20  2013 0_x92m4dn5_0_n1pqrefn_0.conv.log
-rwxrwxrwx 1 apache apache   24M May 20  2013 0_v0me8g8s_0_mw5psypq_2.mp4
-rwxrwxrwx 1 root   root     12M May 20  2013 0_x92m4dn5_0_cgvgijm1_1.mp4
-rw-r--r-- 1 root   root     11K May 20  2013 0_x92m4dn5_0_cgvgijm1_0.conv.log


Last edited by babinlonston; 03-29-2014 at 03:51 AM.. Reason: spell mistake and code format Cleared
# 2  
Old 03-29-2014
You will extend the find command :
Code:
find . -type f -user apache -exec echo mv {} /tmp/backup/ \;

Remove echo if the result satisfies.
Change \; for \+ for performance if you need it.

Also, storing backups in /tmp is a bad idea since it is deleted after every reboot.

I would recommend making a new filesystem for backup.
This User Gave Thanks to Peasant For This Post:
# 3  
Old 03-29-2014
Quote:
Originally Posted by Peasant
You will extend the find command :
Code:
find . -type f -user apache -exec echo mv {} /tmp/backup/ \;

Remove echo if the result satisfies.
Change \; for \+ for performance if you need it.

Also, storing backups in /tmp is a bad idea since it is deleted after every reboot.

I would recommend making a new filesystem for backup.
Yes its worked for me , Could you please give me little explanation what this will do ?
Code:
{} /tmp/backup/ \;

Can't understand what is {} will do and \;
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to move file from one directory to other of only particular user?

I written unix script where a pdf file generates. But if the script is used by multiple people at a time it generates same pdf with two different owner names and creating a problem with permission while moving the file. is there a way where i can move the file filtering with the user? (4 Replies)
Discussion started by: lakers646
4 Replies

2. Solaris

Can't erase/move/copy file!

Hey everyone!. I have a problem with a file that doesn't allow any operation on it. I can't rm,mv,cp nor any other operation to it, I get the following errors: bash-2.05# mv ora_2527.aud /bkp mv: cannot access ora_2527.aud bash-2.05# cp ora_2527.aud /bkp cp: cannot access ora_2527.aud... (4 Replies)
Discussion started by: dragonov7
4 Replies

3. Shell Programming and Scripting

Calling DB user from separate file in Shell script

Hi All, I need to execute a SQL via shell script and i am connecting to Oracle DB by this way $USERNAME1/$PASSWORD1@$STRING1 and i need to get username, password and string from someother file stored in the Unix Directory. $Username, $Password and $String is stored in File A in Path A and i want... (3 Replies)
Discussion started by: sathish.tn
3 Replies

4. UNIX for Dummies Questions & Answers

need assistance on Calling DB user from separate file in Shell script

Hi All, I need to execute a SQL via shell script and i am connecting to Oracle DB by this way $USERNAME1/$PASSWORD1@$STRING1 and i need to get username, password and string from someother file stored in the Unix Directory. $Username, $Password and $String is stored in File A in Path A and i want... (1 Reply)
Discussion started by: sathish.tn
1 Replies

5. Shell Programming and Scripting

Copy/move file which are not currently in use.

Hello experts, I'm doing a shell script that able to copy or move files. My situation is i have a drive ( lets say its S drive) where its receive all the files from mainframe i need to copy all the file from S drive to T drive. but only those files that are finished copied from mainframe... (5 Replies)
Discussion started by: CelvinSaran
5 Replies

6. Shell Programming and Scripting

Search through subfolders and move them into separate folder on the base of file size

Hello guys I am sure that you will help me on this issue as you did earlier::) Scenario : I have a folder named "XYZ". It consist many sub-folders and subfolder contain severals files. there may be abc.dat in each subfolder. Now i want to seperate subfolders on follwing conditions- if abc.dat... (12 Replies)
Discussion started by: infiant
12 Replies

7. UNIX for Dummies Questions & Answers

Unable to copy or move file

I am trying to move a file that is in the root directory. I suspect it is an old file created by someone when the system was installed. I am testing accessing the file by doing a copy but the command does not find the file. I am operating as root. We are HP-UX B.11.23 I do long listing and... (3 Replies)
Discussion started by: phcorn
3 Replies

8. UNIX for Dummies Questions & Answers

tar, zip multiple separate directories and move the results to another volume

TIA, I'm using FreeBSD 6 I have a series of Directories (A,B,C,...Z). Each directory has files and other directories within it. I want to compress the contents of each top directory into a single file so that I get an archive of each directory (for example, A.gzip) AND and want to move... (5 Replies)
Discussion started by: jccbin
5 Replies

9. UNIX for Dummies Questions & Answers

How to copy/move to a file with a special character as the 1st char in the filename?

I am trying to create files with special characters in its filenames for testing purposes. This is on a Linux RHEL4 but this should also be applicable on a Unix shell. I am able to create files with special characters in the filenames...e.g. cp -pv foo.gif \*special.gif cp -pv foo.gif \... (6 Replies)
Discussion started by: sqa777
6 Replies

10. Shell Programming and Scripting

Bash Copy-Move file problem

Hello, I made a script to copy files from one directory to another and move file after the copy is done. When files are present in the source directory there is no problem but when no file are present I'm getting an error. Please help !! --------------------- #!/bin/bash ... (2 Replies)
Discussion started by: lsimoneau
2 Replies
Login or Register to Ask a Question