Problem in deleting files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Problem in deleting files
# 1  
Old 04-26-2010
Problem in deleting files

Hi Guys,

In one of my folders i have 10000 log files starting with sqlfile.....

Iam trying to delete the log files alone from the folder using for loop but i am getting an error

Code:
ksh: /usr/bin/ls: 0403-027 The parameter list is too long.

For loop i used

Code:
 for i in `ls sqlfile*`
more>do
more>rm $i
more>done

Even i tried below command, even that also gave the same error
Code:
ls sqlfile* | head -100 |xargs rm

Guys help me in this.

Thanks for your help in advance.

Regards,
Magesh.
# 2  
Old 04-26-2010
Try:
Code:
for i in sqlfile*
do
  rm "$i"
done

# 3  
Old 04-26-2010
Try this

Code:
find /path -name sqlfile* -type f -exec rm -f {} \;

# 4  
Old 04-26-2010
Thanks Guys.. that solved the issue.
# 5  
Old 04-26-2010
use below perl code:-

Code:
perl -wle 'opendir(DH,"/path/to/related/directory") or die "can not open DIR $!;";
@FILES = readdir DH ;
@SQLFILES = grep { /sqlsuffix/ } @FILES ;
unlink @SQLFILES ;
'

SmilieSmilieSmilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash script deleting my files, and editing files in subdirectories question

#!/bin/bash # name=$1 type=$2 number=1 for file in ./** do if then filenumber=00$number elif then filenumber=0$number fi tempname="$name""$filenumber"."$type" if (4 Replies)
Discussion started by: TheGreatGizmo
4 Replies

2. Homework & Coursework Questions

Problem with Shell Scripts deleting text in files.

Me and a friend are working on a project, and We have to create a script that can go into a file, and replace all occurances of a certain expression/word/letter with another using Sed. It is designed to go through multiple tests replacing all these occurances, and we don't know what they will be so... (1 Reply)
Discussion started by: Johnny2518
1 Replies

3. UNIX for Dummies Questions & Answers

problem deleting multiple files using rm in UNIX

I'm baffled..... the system I work on creates files every Mon-Friday I'm trying to delete all files older than 30 days old from a Unix prompt, the command I'm using is: find /directory/ -mtime +30 -exec rm {} \; however it returns /directory/filename: 644 mode ? (y/n) for every file! ... (1 Reply)
Discussion started by: bquattrone
1 Replies

4. Shell Programming and Scripting

AIX system.... deleting files in remote directory after retrieving files

Hi Friends, I am new to this , I am working on AIX system and my scenario is to retrive the files from remote system and remove the files from the remote system after retreving files. I can able to retrieve the files but Can't remove files in remote system. Please check my code and help me out... (3 Replies)
Discussion started by: vinayparakala
3 Replies

5. Shell Programming and Scripting

Problem with deleting

Hi, I have a folder A which contains files 1,2,3... I also have a file xyz under a diff folder B containg the entries 1,2,3... I am trying to compare and delete the nonexisting ones from xyz using the below code: QFILE=/B/xyz cd A ls -1 > /tmp/file1 for fname in `cat $QFILE` do if ... (4 Replies)
Discussion started by: swasid
4 Replies

6. Web Development

Deleting databases in MYSQL problem asking...

Hi, I'm the new user of mysql. I facing one problem to delete one of the database in mysql. Hope can get all of your suggestion and advice. Input: mysql> show databases; +-------------------------+ | Database | +-------------------------+ | information_schema | |... (3 Replies)
Discussion started by: patrick87
3 Replies

7. UNIX for Advanced & Expert Users

problem with deleting a file

hi friends, i need to delete a file named "-vyxx-.0.sdct.txt" i'm unable to use "rm -vyxx-.0.sdct.txt" jus give me your suggesstions thanks in advance (5 Replies)
Discussion started by: rprajendran
5 Replies

8. UNIX for Dummies Questions & Answers

problem while deleting a file

Hi , In a particular path the below mentioned three files has been created. -rw-r--r-- 1 edwprod edw 0 Jun 5 00:06 -f%*lock.clock -rw-r--r-- 1 edwprod edw 151 Jun 5 00:06 -f.log -rw-r--r-- 1 edwprod edw 4 Jun 5 00:06 -f%conn_err.out ... (5 Replies)
Discussion started by: anupam_jash
5 Replies

9. UNIX for Dummies Questions & Answers

problem in deleting a file

Hello: I made this mistake on my tru64 machine, I renamed a file from: binary.errlog to binary.errlog(B3) now when im tryign to move or delete the file Im getting: # rm binary.errlog(B3) ksh: syntax error: `(' unexpected 4# mv binary.errlog(B3) log ksh: syntax error: `(' unexpected ... (3 Replies)
Discussion started by: aladdin
3 Replies

10. UNIX for Dummies Questions & Answers

Problem while Deleting file

All, I am trying to delete a user created file from specified folder. This folder is using for my Team member (i.e, Public folder). For example, $ ls -l total 1336 -rw-rw-r-- 1 g_btha customer 2655 Dec 06 12:35 A_COL_1001 While deleting/moving this file I am getting the following... (3 Replies)
Discussion started by: nvkuriseti
3 Replies
Login or Register to Ask a Question