Delete files beginning with *


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Delete files beginning with *
# 22  
Old 04-16-2013
1.7.11 is newer than 1.7.2. Unless that's a typo of 1.7.1.

Whatever the version, your cygwin does not seem to be able to stat those files. This would explain why ls succeeds but ls -l fails.

The short form ls only reads the contents of the directory. The directory is itself just a file with contents. The directory can be opened because its name is a valid windows name. Reading its contents does not require opening any of those files, so the fact that those contents are strings that represent invalid windows filenames is not relevant. ls is just using basic i/o to print those strings.

However, ls -l passes those strings to the kernel in an attempt to stat those invalid windows filenames. This is necessary to obtain data required by the long listing, such as file size, timestamps, ownership information, permissions, etc.

rm needs to use those filenames to unlink.

I could very well be mistaken, but it fits.

Regards,
Alister
# 23  
Old 04-16-2013
I am updating as I type, just to be sure..I guess it will be a while. Will post back after checking again.

Thanks again guys! You are awesome!
# 24  
Old 04-16-2013
Quote:
Originally Posted by jamie_123
I probably missed seeing the question, these files were created by tcpdump, with basic filename being * and a value that increments and creates a new file each time the file reaches beyond a value. These were created on a unix system and then moved to another harddisk without any trouble.


Tried that, get a response saying the filename is not valid or too long.
Upon further reflection, since you mentioned that even the windows file manager cannot remove the files, I don't think this is a cygwin issue. I now believe that the unix system used to create these files allowed you to use characters which windows forbids but which ntfs can handle.

Windows does not allow the asterisk at all. When creating a file which contains an asterisk, Cygwin translates it and in its stead writes a utf8 character that looks like a solid dot (which is a valid character as far as windows is concerned). When reading the filename, Cygwin then translates it back to an asterisk for cygwin apps. The windows file manager does not do this and will show you the solid dot.

From what you said about creating the files on unix, I suspect that it wrote a literal asterisk into the filename. The NTFS implementation supports the asterisk, but windows will not accept it when it reads it. And, since ultimately cygwin depends on windows, it fails as well.

If this is correct, the most expedient solution may be to mount that filesystem with the unix system that created it and rename those files.

Regards,
Alister

Last edited by alister; 04-16-2013 at 01:23 PM..
This User Gave Thanks to alister For This Post:
# 25  
Old 04-16-2013
Quote:
Originally Posted by jamie_123
These were created on a unix system and then moved to another harddisk without any trouble.
You may not have used Linux ntfs-3g, but perhaps your driver has similar functionality (to prevent future headaches):
Quote:
Windows Filename Compatibility

NTFS supports several filename namespaces: DOS, Win32 and POSIX. While the ntfs-3g driver handles all of them, it always creates new files in the POSIX namespace for maximum portability and interoperability reasons. This means that filenames are case sensitive and all characters are allowed except '/' and '\0'. This is perfectly legal on Windows, though some application may get confused. The option windows_names may be used to apply Windows restrictions to new file names.

...

windows_names
This option prevents files, directories and extended attributes to be created with a name not allowed by windows, either because it contains some not allowed character (which are the nine characters " * / : < > ? \ | and those whose code is less than 0x20) or because the last character is a space or a dot. Existing such files can still be read (and renamed).
It seems whatever you used employed the POSIX namespace but your Windows machine insists on using the Win32 namespace.

For the record, I have no clue about how these namespaces are utilized or if Windows' notion of which namespace to use when mounting a partition can be overridden.

Please do report back when you sort it out. Your solution may help someone in the future.

Regards,
Alister

---------- Post updated at 12:47 PM ---------- Previous update was at 12:45 PM ----------

Quote:
Originally Posted by Corona688
cygwin isn't an OS backdoor, it can't create filenames which ordinary applications cannot. Which means Windows was willing to create filenames it cannot delete -- which is faintly hilarious but not all that surprising.
In post #15, the OP states that the files were created on a unix system.

Regards,
Alister

Last edited by alister; 04-16-2013 at 02:04 PM..
# 26  
Old 04-16-2013
I wonder if doing a Windows filesystem integrity check would "fix" the file names? Whatever is the Microsoft equivalent of fsck... is it chkdsk.exe?

Else, yeah, I think a Linux boot CD is your only option, one that has the ntfs-3g module so you can access this ntfs filesystem.

Out of curiosity, why did you create file names with the '*' character in the name? Was it intentional (i.e. there is some legitimate reason to do so), or was this an accidental mistake?
This User Gave Thanks to lupin..the..3rd For This Post:
# 27  
Old 04-16-2013
Quote:
Originally Posted by alister
In post #15, the OP states that the files were created on a unix system.

Regards,
Alister
I missed that, sorry!

Yeah, agreed, rescue disk time.
This User Gave Thanks to Corona688 For This Post:
# 28  
Old 04-16-2013
Quote:
Originally Posted by lupin..the..3rd
I wonder if doing a Windows filesystem integrity check would "fix" the file names?
This post implies that it will, but the resulting filenames may not bear any resemblance to the originals: ntfs-3g-devel mailing list: Windows chkdsk and invalid filenames

Regards,
Alister
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Removing characters from beginning of multiple files

Hi, I have been searching how to do this but I can't seem to find how to do it. Hopefully someone can help. I have multiplr files, 100's example 12345-zxys.213423.zyz.txt. I want to be able to take all these files and remove the first '12345-' from each of the files. '12345-' these characters... (5 Replies)
Discussion started by: israr75
5 Replies

2. 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

3. Shell Programming and Scripting

Append Multiple files with file name in the beginning of line

Hi, I have multiple files having many lines like as bvelow: file Name a.txt abc def def xyz 123 5678 file Name b.txt abc def def xyz 123 5678 I would like to append files in the below format to a new file: file Name c.txt (7 Replies)
Discussion started by: rramkrishnas
7 Replies

4. Shell Programming and Scripting

Append variable texts to the beginning of each line in all files in a directory

I am writing a code to append some numbers in the beginning of each line in all the files present in a directory. The number of files are really huge. The files are numbered as 1.sco, 2.sco, 4.sco (Note: 3.sco is missing). The files currently look like this: 1.sco 2 3 5 6 6 7My task is to... (4 Replies)
Discussion started by: shoaibjameel123
4 Replies

5. UNIX for Dummies Questions & Answers

How to use wild cards to find files beginning with upper and lower case

Im trying to use wild cards to find files that start with either an upper or lower case letter e.g. list files that beginning with b or B, i also want to sort them by the time they were last modified. e.g latest file created first. At the moment i have the following code that ls -d... (3 Replies)
Discussion started by: parker4001
3 Replies

6. Shell Programming and Scripting

renaming files or adding a name in the beginning of all files in a folder

Hi All I have a folder that contains hundreds of file with a names 3.msa 4.msa 21.msa 6.msa 345.msa 456.msa 98.msa ... ... ... I need rename each of this file by adding "core_" in the begiining of each file such as core_3.msa core_4.msa core_21.msa (4 Replies)
Discussion started by: Lucky Ali
4 Replies

7. UNIX for Dummies Questions & Answers

Command to delete numbers at beginning of txt file line

Hello. I have the following issue: my txt file has the following format: train/dr4/fklc0/sx175.txt 0 80282 Severe myopia contributed to Ron's inferiority complex. train/dr4/fklc0/sx355.txt 0 42906 Dolphins are intelligent marine mammals. train/dr4/fklc0/sa2.txt awk 'NR%2==0' test1.txt >... (4 Replies)
Discussion started by: li_bi
4 Replies

8. Shell Programming and Scripting

Detect lines beginning with double-byte characters (Japanese) and delete

Greetings, I want to use a script (preferably awk) which determines if the first character in a line is double-byte (as in Japanese or Chinese) and deletes it. For example: (in the above quote, I see Japanese on my screen for two lines - with 2 characters in the first and 3 characters in the... (8 Replies)
Discussion started by: ubbeauty
8 Replies

9. Shell Programming and Scripting

delete beginning field.

I want to script out deleting the first field of a file when it is created. I'm looking to store the output of an ls -l commad to a file but leaving off the permissions so when the file is opened I see something like; 2 bin bin 256 Feb 6 2005 mnt 5 root system 256... (2 Replies)
Discussion started by: daveisme
2 Replies

10. Shell Programming and Scripting

delete lines from file2 beginning w/file1

I've been searching around here and other places, but can't put this together... I've got a unique list of words in file 1 (one word on each line). I need to delete each line in file2 that begins with the word in file1. I started this way, but want to know how to use file1 words instead... (13 Replies)
Discussion started by: michieka
13 Replies
Login or Register to Ask a Question