LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-30-2013, 04:31 AM   #1
rstorer27
LQ Newbie
 
Registered: Dec 2013
Posts: 2

Rep: Reputation: Disabled
Unhappy ls and rm commands produce "argument"


Hi
I have just taken over "admin" of a Linux server running SLES SP10.3.
I can see the /var area is at 87% (df -k). Poking around i have found a directory /var/ncc/hicom/out is huge and i know looking at other servers on our network, that this area should be empty (it appears that files are updating here in error!).
Because of the size of this directory I cannot list or remove files using ls or rm commands (argument error). Is there a way i can remove all the files from this directory or at least list them? i cannot even find a name for one of the files as there are far too many.
Many Thanks
Ritch(new to unix but enjoying)!
 
Old 12-30-2013, 04:49 AM   #2
divyashree
Senior Member
 
Registered: Apr 2007
Location: bbsr,orissa,India
Distribution: RHEL5 ,RHEL4,CENT OS5,FEDORA,UBUNTU
Posts: 1,363

Rep: Reputation: 135Reputation: 135
HI rstore, Welcome to LQ.

Try the options in runlevel 1. Or boot from a live CD and try it.
 
Old 12-30-2013, 05:02 AM   #3
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=14, FreeBSD_10{.0|.1|.2}
Posts: 4,081
Blog Entries: 1

Rep: Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148
Quote:
Originally Posted by rstorer27 View Post
Hi
I have just taken over "admin" of a Linux server running SLES SP10.3.
I can see the /var area is at 87% (df -k). Poking around i have found a directory /var/ncc/hicom/out is huge and i know looking at other servers on our network, that this area should be empty (it appears that files are updating here in error!).
Because of the size of this directory I cannot list or remove files using ls or rm commands (argument error). Is there a way i can remove all the files from this directory or at least list them? i cannot even find a name for one of the files as there are far too many.
Many Thanks
Ritch(new to unix but enjoying)!
To list those files try this:

Code:
find /var/ncc/hicom/out/ -type f
That will let you safely show what is there.

To remove them - FIRST THINK CAREFULLY, be sure that you want to do that! Then...

Code:
find /var/ncc/hicom/out/ -type f |xargs rm
 
Old 12-30-2013, 05:11 AM   #4
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389
@rstorer27: Assuming you are getting the argument list too long error, you can list and remove them if you limit the amount of files given to ls or rm. Example:
Code:
$ ls [a-d]*
$ ls [e-h]*

$ rm [0-9]*
$ rm [i-m]*
You might need to adjust the above rough example, but I hope you get the idea.
 
Old 12-30-2013, 07:45 AM   #5
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,661

Rep: Reputation: 1256Reputation: 1256Reputation: 1256Reputation: 1256Reputation: 1256Reputation: 1256Reputation: 1256Reputation: 1256Reputation: 1256
You can look at the oldest files using "ls -ltr | more", if the files are really old you cant hen create either a pattern to select just those files, or use one of the time options (atime, mtime, mmin) to identify the files in question. When you get the files you want, you can then add the -delete option to actually delete the files.

Alternatively, you can use "ls -ltr | head -n" to print oldest "n" files. If you want to delete them you can use "ls -tr | head -n" to get just that many file names( the command "rm `ls -tr | head 15`" will delete the oldest 15 files).

Evidently you have a LOT of files (more than about 8 thousand in a directory) so it will take a while to decide which files you want to delete.

The argument error is that you are overflowing the number of parameters to a command allowed. Now this isn't a hard count as it depends on the amount of memory needed to actually hold the parameters. The usual count size is around 10,000 files - but long file names will cut that down.

That is why workarounds like using find (with various options) work - they cut the parameter count down to one. The "ls -ltr | head -n" trick cuts the number down to "n" parameters at a time.
 
Old 12-31-2013, 05:21 AM   #6
rstorer27
LQ Newbie
 
Registered: Dec 2013
Posts: 2

Original Poster
Rep: Reputation: Disabled
Smile

Guys,
Thankyou all for the responses. @astrogeek - your command is running now (find), and i cannot believe the number of files in this area! Hopefully the remove will work they all start with FM*********** (* being a date format), i believe we are collecting errors from somewhere which is storing them in this directory. I will find the reasons why.
Again thanks all.Hope to learn lots more from this site/blog.
Ritchie
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I convert makefile argument "toupper" (and "tolower")? daat99 Programming 4 12-04-2010 10:49 AM
spamassassin: sa-learn --sync -> "Argument "M-HM-JM-J" isn't numeric" XXLRay Linux - Server 8 06-22-2010 10:10 AM
error: Error for wireless request "Set Mode" (8B06) : invalid argument "roaming" penguin chick Linux - Wireless Networking 5 08-22-2008 01:16 PM
Standard commands give "-bash: open: command not found" even in "su -" and "su root" mibo12 Linux - General 4 11-11-2007 10:18 PM
"cp -p" fails with "cp: setting permissions for `/home/svbld/t': Invalid argument" mkhesin Red Hat 1 02-28-2007 12:57 AM


All times are GMT -5. The time now is 03:15 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration