Visit Our UNIX and Linux User Community


Problems removing files with semicolons in the filename


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Problems removing files with semicolons in the filename
# 8  
Old 09-04-2013
If the file system is not corrupted in the sense that an fsck won't find an error,
then you still have got a bug in the file system handler (in the Unix kernel): it allows to create directory entries (names) that cannot be handled afterwards.
What does a
Code:
df bad

show?
# 9  
Old 09-04-2013
added unlink to my code

Code:
printf("%li\t%s\n", di->d_ino, di->d_name);
if(unlink(di->d_name) == -1)
{
        err = errno;
        printf("unlink rc=%i %s\n", err, strerror(err));
}

and I am getting same
Code:
129935  000025;001;1377795616;^A
unlink rc=2 No such file or directory

Any ideas?
# 10  
Old 09-04-2013
If unlink is puking on valid filenames, I'm not sure what you can do; those files are effectively blocked off, to the kernel, invisible, it can't see them. You may need to work with things at a lower level than that, dangerous things, disk-editing sort of things.
# 11  
Old 09-05-2013
You might want to consult a little tutorial of mine.

I hope this helps.

bakunin
# 12  
Old 09-05-2013
Thanks, I don't have filedb on this system, but I do have clri, will investigate.

Just a side note - someone moved this thread and I found it just by luck. Why? How people follow their threads when topics are moved?

Moderator's Comments:
Mod Comment edit by bakunin: In fact colleague Scott moved it, perhaps because he is convinced that this thread belongs to this forum.

How to find your thread is easy: there is an (expiring) redirect in the original place, but it is removed after some time (default is 6 hours).

You can also access your "subscribed threads" from the UserCP (have a look at the top of this page, horizontal main menu, second item from the left side) once you have placed a post (which automatically subscribes you to a thread). This is how i keep track of the threads i am engaged in. Threads with new posts will be displayed in emphasized fashion.

Finally you can use the search function (in the same horizontal menu, third item from the right side) and search for either keywords or/and user-IDs.

Last edited by bakunin; 09-05-2013 at 03:59 PM..
# 13  
Old 09-05-2013
You might want to try one of the less complicated methods first, namely the variant using "find" and the inode-number.

Use an "ls -i" to list the files with inode-numbers, capture that to a file and delete all the lines with files which should stay. Then read this file and execute for every line the "rm", like in this sketch of a script:

Code:
while read inum ; do
     find -inum "$inum" -exec rm -f {} \;
done

I hope this helps.

bakunin
# 14  
Old 09-05-2013
Quote:
Originally Posted by bakunin
You might want to try one of the less complicated methods first, namely the variant using "find" and the inode-number.
Suggested and failed (posts #3 and #4).

Even passing readdir's pathnames directly to unlink doesn't work. Whatever is going on here, if going directly from readdir to unlink doesn't work, then nothing that depends on the syscall interface will work.

Regards,
Alister
 

Previous Thread | Next Thread
Test Your Knowledge in Computers #83
Difficulty: Easy
BSD, Linux, Mac OS X, and other Unix-like operating systems did not inherit aspects of the original Unix design.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

[Solved] Modifying/Removing Timestamps from a filename

So given filenames of varying lengths, I was wondering how I would remove or modify appended timestamps of the current date DD-MM-YY. So say: test_DD-MM-YY.txt coolbeans_DD-MM-YY.pdf And what I expect the output to be: test.txt coolbeans.pdf Thanks :) (2 Replies)
Discussion started by: sodaboyz
2 Replies

2. UNIX for Dummies Questions & Answers

BASH - Removing the very last character(s) extension of a filename

Hello. I would like to know how to do this in bash script : A_WORD="ABCD_EFGH.0.100.40.123" NEW_WORD=remove_last_ext("A_WORD") NEW_WORD --> ABCD_EFGH.0.100.40 A_WORD="ABCD_EFGH.0.50.3" NEW_WORD=remove_last_ext("A_WORD") NEW_WORD --> ABCD_EFGH.0.50 A_WORD="ABCD_EFGH.3.100.50." ... (2 Replies)
Discussion started by: jcdole
2 Replies

3. Shell Programming and Scripting

removing a range of characters in a filename

hi, I have quite a bunch of files with annoyingly long filenames. I wanted to cut the range of characters from 9-18 and just retain the first 8 characters and the .extension. any suggestion how to do it. thanks much. original filename: 20000105_20000105_20100503.nc.asc output filename:... (4 Replies)
Discussion started by: ida1215
4 Replies

4. Shell Programming and Scripting

removing the filename extension

Is there an easy way to strip off a filename's extension? For example, here's a filename: blahblahblah.thisisok.thisisnotok I want to get rid of .thisisnotok from the filename, so that what's left is blahblahblah.thisisok Thanks. I have a directory full of filenames that need to be... (5 Replies)
Discussion started by: daflore
5 Replies

5. UNIX for Dummies Questions & Answers

Removing the trailing date from a filename

Hi I have 3 files (say) in a folder as in the example below abc_01012011.csv def_01012011.csv xyz_01012011.csv I need to move these files to a different folder as follows abc.csv def.csv xyz.csv I am trying to put together a script with a for loop which reads the source filenames... (5 Replies)
Discussion started by: bobsn
5 Replies

6. UNIX for Dummies Questions & Answers

Help with Removing extra characters in Filename

Hi, It's my first time here... anyways, I have a simple problem with these filenames. This is probably too easy for you guys: ABC_20101.2A.2010_01 ABD_20103.2E.2010_04 ABE_20107.2R.2010_08 Expected Output: ABC_20101 ABD_20103 ABE_20107 The only pattern available are the ff: 1) All... (9 Replies)
Discussion started by: Joule
9 Replies

7. AIX

removing 8th and 9th character of a FILENAME

Hi everyone, I have a file called pdf.txt which has the following list inside: 7110412_1_31122012.pdf 7286510_4_46667100.pdf 4002176_1_00018824.pdf ... I need a looping script to REMOVE the 8th and 9th character of the filenames listed, no matter what character that is. So... (4 Replies)
Discussion started by: chipahoys
4 Replies

8. Shell Programming and Scripting

Filename from splitting files to have the same filename of the original file with counter value

Hi all, I have a list of xml file. I need to split the files to a different files when see the <ko> tag. The list of filename are B20090908.1100-20090908.1200_CDMA=1,NO=2,SITE=3.xml B20090908.1200-20090908.1300_CDMA=1,NO=2,SITE=3.xml B20090908.1300-20090908.1400_CDMA=1,NO=2,SITE=3.xml ... (3 Replies)
Discussion started by: natalie23
3 Replies

9. Shell Programming and Scripting

Removing spaces within Filename

Hello, I have a Folder (myfile) which contain the following files: P$12789865KR +N+01+OM+16102009165416.nu P$M1-508962GD +N+01+ALP+14102009094417.nu Is there a sed command(s) that will loop through this folder and remove the spaces that exists in the filename? Any help would be... (7 Replies)
Discussion started by: Fishn
7 Replies

10. AIX

Removing a filename which has special characters passed from a pipe with xargs

Hi, On AIX 5200-07-00 I have a find command as following to delete files from a certain location that are more than 7 days old. I am being told that I cannot use -exec option to delete files from these directories. Having said that I am more curious to know how this can be done. an sample... (3 Replies)
Discussion started by: jerardfjay
3 Replies

Featured Tech Videos