Delete from supplied list of files


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Delete from supplied list of files
# 1  
Old 04-06-2011
Question Delete from supplied list of files

Hi,

I have a file that contains >4000 inode numbers. Each inode number is on separate row. I'd like to delete all this files. Any idea how could I do it?

Thank you.

Andrej
# 2  
Old 04-06-2011
Code:
while read LINE; do
    find /somefs -inum $LINE -exec rm {} \;
done < inode.list

You could change the rm vs an echo to check if this is what you want. You'll might have to adjust the starting directory ie. file system of course.
This User Gave Thanks to zaxxon For This Post:
# 3  
Old 04-06-2011
In the above example, the find is launched for each and every nodes (not optimal).

So another way that "may" be faster (but ok, it may depends on some other stuff off course) is to generate a big list of inode/file once and then grep the matching inode from it

Code:
find $YOUR_SEARCH_PATH -exec ls -di {} + >ifile.lst 2>/dev/null

Code:
fgrep inode.list ifile.lst

or
Code:
grep -f inode.list ifile.lst

and the grep the filename from that list based on inode matching.

Last edited by ctsgnb; 04-06-2011 at 10:39 AM..
This User Gave Thanks to ctsgnb For This Post:
# 4  
Old 04-06-2011
Bug Thank you

It works, thank you very much!

Andrej
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Changing information supplied when running file

In unix systems I can call `file` to return me the file type. file cel.vik $ cel.vik: ASCII text How can I append additional information when I create a file such that when I call `file` it returns me that additional information. (2 Replies)
Discussion started by: kristinu
2 Replies

2. Shell Programming and Scripting

List and Delete Files which are older than 7 days, but have white spaces in file name

I need to list and delete all files in current older which are olderthan 7 days. But my file names have white spaces. Before deleting I want to list all the files, so that I can verify.find . -type f -mtime +7 | xargs ls -l {} But the ls command is the working on the files which have white... (16 Replies)
Discussion started by: karumudi7
16 Replies

3. Shell Programming and Scripting

Script needed to delete to the list of files in a directory based on last created & delete them

Hi My directory structure is as below. dir1, dir2, dir3 I have the list of files to be deleted in the below path as below. /staging/retain_for_2years/Cleanup/log $ ls -lrt total 0 drwxr-xr-x 2 nobody nobody 256 Mar 01 16:15 01-MAR-2015_SPDBS2 drwxr-xr-x 2 root ... (2 Replies)
Discussion started by: prasadn
2 Replies

4. UNIX for Advanced & Expert Users

Help with a shell script? List files, delete them and log them

Hello, i'm trying to solve this script. List, one at a time, all files larger than 100K in the /home/username directory tree. Give the user the option to delete or compress the file, then proceed to show the next one. Write to a logfile the names of all deleted files and the deletion times. I... (7 Replies)
Discussion started by: jose2802
7 Replies

5. Programming

Checking which arguments are supplied

I have written this C++ program and I am using getopt_long and want to chech when the user supplies the arguments so that I can put a default or otherwise. Currently I am using hasargv or Pc.get_string("key",s), Pc.get_real("key",s), etc to detect whether the user supplied a value. For... (3 Replies)
Discussion started by: kristinu
3 Replies

6. Programming

Checking which arguments are supplied

I have written this C++ program and I am using getopt_long (2 Replies)
Discussion started by: kristinu
2 Replies

7. Programming

Checking which arguments are supplied

I have written this C++ program and I am using getopt_long and (0 Replies)
Discussion started by: kristinu
0 Replies

8. Shell Programming and Scripting

Delete old files but with exclusion with file list

Hello Can you please help and check what im missing on script below the goal is to delete the old files more than 7 days old but not the excluded file list inside excluded.dat file #!/bin/sh EXCLUDE=/path/to/exclude/exclude.dat FIND=/bin/find for xfile in '(read $EXCLUDE)' do $FIND... (9 Replies)
Discussion started by: angst_nu
9 Replies

9. AIX

Get the list, filter and delete the files on remote server

Hi, I need to login to a remote server. Go to a particular path. Get the lists of files on that path.There may be n number of files. I need to delete only those files from above created list which are 7 days older. I have achieved above using ftp protocol, but now the constraint has... (0 Replies)
Discussion started by: mail_amitnagpal
0 Replies

10. Shell Programming and Scripting

unix question: user supplied input for 'alias'

I have a program to scan the log files and I want to pipe the output to 'less'. I want to create an alias such that following are equivalent scanlog chunky.lst = /udd/n2man/utils/scanlog chunky.lst|less where chunky is user supplied file which can change. Is this possible as an alias or... (1 Reply)
Discussion started by: ospreyeagle
1 Replies
Login or Register to Ask a Question