Computing.Net > Forums > Unix > Files with equal names

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Files with equal names

Reply to Message Icon

Name: Bard
Date: November 13, 2002 at 03:15:15 Pacific
OS: Solaris 2.7
CPU/Ram: ?
Comment:

Hi,

My shell-script wrongly called the same log-file twice!
Now I'm not able to get rid of the old one - help?

-rw-rw-r-- 1 inst psh 455 Nov 7 14:09 script_log.txt
exitrw-r-- 1 oper psh 19886 Nov 6 15:05 script_log.txt

Thanx in advance!

Regards
Bard



Sponsored Link
Ads by Google

Response Number 1
Name: Don Arnett
Date: November 13, 2002 at 08:48:53 Pacific
Reply:

You can't have two files with the same name. The OS won't allow that. Apparently there are hidden characters in one of the file names. That also happens when the OS seems to not find a file.

To you it looks like the filename is "script_log.txt" but the filename may well be something like "scri^bpt_log.txt"

To remove it, you'll have to use wildcards, something like

rm *.txt

You may have to try different wildcard combinations to finally delete it because you don't know where the hidden character is.

For example, if the hidden character is between the t & x (script_log.t^ext), using *.txt won't work.

Test any wildcard combinations with 'ls' before you use 'rm' to see what other files are found.

ls *.txt might show you files that you don't want deleted. Sometimes you have to rename files to stop them from being effected.


0

Response Number 2
Name: James Boothe
Date: November 17, 2002 at 07:57:39 Pacific
Reply:

ls -b will show non-printing characters as octal values. This will help you isolate the filename using a pattern, so that you can rename or remove it, as Don explained:

ls -b
myf\002ile.txt myfile.txt

ls myf?ile.txt
myfile.txt

rm myf?ile.txt

A space will not show as an octal value since it is a printing character. Of course, leading or embedded spaces are easy to spot, but a trailing space is harder to see. To check for filenames that end in a space, this works for me:

ll *" "


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Files with equal names

Concatenate Files with similar name www.computing.net/answers/unix/concatenate-files-with-similar-name/5940.html

rm files with same prefix, diff suf www.computing.net/answers/unix/rm-files-with-same-prefix-diff-suf/5644.html

Hosts file and domain name www.computing.net/answers/unix/hosts-file-and-domain-name/2728.html