Files Removes Issue

Taking care of your Linux box.

Files Removes Issue

Postby refra » Fri Apr 22, 2011 11:47 am

AOA,

I want to delete large # of files from

/d01/oracle/PROD/inst/apps/PROD_ebs/logs/appl/conc/out

The Size of the path is:
613M /d01/oracle/PROD/inst/apps/PROD_ebs/logs/appl/conc/out

Total # of files is: 76301

when i delete the files under /out directory:

it gives me error:

"Argument list is too long"

what is the issue or How can i resolve it.
refra
Naik
 
Posts: 69
Joined: Wed Dec 06, 2006 3:51 pm

Postby CyberBob » Sat Apr 23, 2011 12:52 pm

As the total number of files is too high that is why you are facing this error msg. Try deleting files by minimizing the number of files in deletion batch i.e. try deleting files 500 to 1000 at a time.

Or if you are damn sure what you are going to do try this command to delete all files in your desired location

find -name '*' | xargs rm
Registered Linux User # 511059
http://imranbhullar.blogspot.com
Follow me on Twitter! http://twitter.com/imranbhullar

"If 386BSD had been available when I started on Linux, Linux would probably never had happened." Linus Torvalds
CyberBob
Cadet
 
Posts: 8
Joined: Wed Mar 12, 2008 11:44 am
Website: http://imranbhullar.blogspot.com
Location: End of Road. . . .

Postby lambda » Sun Apr 24, 2011 7:33 pm

better solution:

Code: Select all

find /path/to/directory -type f -print0 | xargs -0 rm
read the man pages for what -print0 and -0 do.
Watch out for the Manners Taliban!
Isn't it amazing how so many people can type "linuxpakistan.net" into their browsers but not "google.com"?
lambda
Major General
 
Posts: 3452
Joined: Tue May 27, 2003 7:04 pm
Website: http://www.hungry.com/~fn/
Location: Lahore

Postby refra » Mon Apr 25, 2011 10:34 am

Dear lambda,


From your command how can i remove the all files for the month of
Jaunary 2011.

I used this command:

ls -ltra | grep "Jan 2011" | awk `{print $9}` > a
rm -f `cat a`

but faced a error like:

"Argument list is too long"
refra
Naik
 
Posts: 69
Joined: Wed Dec 06, 2006 3:51 pm

Postby lambda » Mon Apr 25, 2011 4:18 pm

you're still trying to delete using one command. that's what xargs helps you with. read its man page.

try this:

Code: Select all

cd /the/directory; ls -lU | grep '2011-01' | awk '$6 ~ /2011-01/ {print $8}' | xargs rm
it will not work with files that have spaces in them, and you might have to adjust $6 and $8 to something else. my ls -lU says

Code: Select all

-rw-r--r--   1 pkf       pkf            4898 2011-04-25 16:14 tmpbxdueo
-rw-r--r--   1 pkf       pkf          372337 2011-03-11 17:38 update-log.12336
-rw-r--r--   1 pkf       pkf          376173 2010-11-01 16:13 update-log.20637
-rw-r--r--   1 pkf       pkf            1114 2011-04-06 07:55 stockjsvars.mako.pyc
-rw-r--r--   1 pkf       pkf            1510 2011-04-25 12:05 tmpwKsEx4
-rw-r--r--   1 pkf       pkf           15383 2009-11-10 16:46 update-log.11540
column 6 is the date for me.
Watch out for the Manners Taliban!
Isn't it amazing how so many people can type "linuxpakistan.net" into their browsers but not "google.com"?
lambda
Major General
 
Posts: 3452
Joined: Tue May 27, 2003 7:04 pm
Website: http://www.hungry.com/~fn/
Location: Lahore

Postby refra » Mon Apr 25, 2011 5:29 pm

Thanks, but my directory files are look like:

-rw-rw-r-- 1 applprod applprod 31765 Apr 25 16:59 o70356816.out
-rw-rw-r-- 1 applprod applprod 31765 Apr 25 17:00 o70357816.out
-rw-rw-r-- 1 applprod applprod 0 Apr 25 17:00 o70350820.out
-rw-rw-r-- 1 applprod applprod 31765 Apr 25 17:00 o70358818.out
-rw-rw-r-- 1 applprod applprod 31765 Apr 25 17:00 o70359816.out
-rw-rw-r-- 1 applprod applprod 31760 Apr 25 17:01 o70360816.out
-rw-rw-r-- 1 applprod applprod 31765 Apr 25 17:01 o70360817.out
-rw-rw-r-- 1 applprod applprod 31765 Apr 25 17:01 o70361816.out
-rw-rw-r-- 1 applprod applprod 0 Apr 25 17:01 o70360818.out
-rw-rw-r-- 1 applprod applprod 31765 Apr 25 17:02 o70362816.out
-rw-rw-r-- 1 applprod applprod 0 Apr 25 17:04 o70363816.out
-rw-rw-r-- 1 applprod applprod 0 Apr 25 17:05 o70350816.out
-rw-rw-r-- 1 applprod applprod 0 Apr 25 17:06 o70358817.out
-rw-rw-r-- 1 applprod applprod 0 Apr 25 17:11 o70364817.out
-rw-rw-r-- 1 applprod applprod 0 Apr 25 17:17 o70365816.out
refra
Naik
 
Posts: 69
Joined: Wed Dec 06, 2006 3:51 pm

Postby lambda » Tue Apr 26, 2011 2:35 am

try doing

Code: Select all

export LANG=en_US.UTF-8
before running ls.
Watch out for the Manners Taliban!
Isn't it amazing how so many people can type "linuxpakistan.net" into their browsers but not "google.com"?
lambda
Major General
 
Posts: 3452
Joined: Tue May 27, 2003 7:04 pm
Website: http://www.hungry.com/~fn/
Location: Lahore


Return to “%s” Administration

Who is online

Users browsing this forum: No registered users and 1 guest

cron