Dear friends,
When I list the files in my machine with SUN solaris 5.8 I can see an unidentified file like.....
-rwxr-xr-x 1 isos staff 566952 Oct 12 2001 sendapi*
-rw-r--r-- 1 isos staff 3471 Oct 12 2001 set_environ.inst
-rw-r--r-- 1 isos staff 1534 Oct 12 2001 setenv.site
-r-xr-xr-x 1 isos staff 6795 Oct 12 2001 setup*
-rw-rw-r-- 1 isos staff 28718 Mar 29 18:02

-rw-r--r-- 1 isos staff 4710 Sep 12 2001 slot3.cfg
-rwxr-xr-x 1 isos staff 753 May 5 2001 *
-rwxr-xr-x 1 isos staff 315672 Oct 12 2001 sockclnt*
-rwxr-xr-x 1 isos staff 189412 Oct 12 2001 sockserv*

the space as shown above is the file name which is 28 MB. I dont know how this has been created and how to access this file!!!
Can neone help me to find out what is inside and way to delete?

Regards,
Shankar.

Dani AI

Generated

This thread shows a classic case: a regular file whose name is made of non‑printing bytes (spaces, tabs, or other characters), so it prints as an empty name in ls but still has size (about 28 MB in 's report). was right that shell escaping/tab completion can work when you know the bytes; was also right that inode-based handling is the safest approach. Below are Solaris-friendly, practical steps to (1) reveal exactly what bytes make up the filename and (2) safely rename or remove it without guessing how many spaces.

First, reveal filename length and the bytes in hex (so you can tell whether the name is spaces 0x20, tabs 0x09, CR/LF, or UTF-8 sequences):

perl -le 'opendir(D,".") or die $!; while(defined($f = readdir D)) {
  next if $f =~ /^\.\.?$/;
  $hex = join(" ", map { sprintf "%02x", ord($_) } split(//,$f));
  printf "%4d bytes\t\"%s\"\t%s\n", length($f), $f, $hex;
}'

The third column shows the byte sequence. If it prints lots of "20" you have spaces; "09" is tab; multi‑byte UTF-8 will show multiple hex bytes.

Once you know the inode or the hex, avoid typing the whitespace: use a short Perl script to target the file by its inode and either rename it to a safe name or unlink it. Do a dry run first (print only), then perform the action:

# dry run: replace 123456 with the inode you saw above
perl -e 'opendir(D,".") or die $!; $target=123456;
while(defined($f=readdir D)) { next if $f=~/^\.\.?$/;
  if ((stat($f))[1] == $target) { print "match: <$f>\n" } }'

# to rename once verified:
perl -e 'opendir(D,".") or die $!; $target=123456;
while(defined($f=readdir D)) { next if $f=~/^\.\.?$/;
  if ((stat($f))[1] == $target) { rename $f, "fixed_name" or die $! } }'

After renaming, run file, strings, or your usual inspection tools on the safe name to see what it contains before deciding to delete. Note: these Perl approaches avoid relying on specific GNU find options (handy on Solaris 5.8) and let you operate deterministically without guessing whitespace.

Recommended Answers

All 5 Replies

To access the file put a \ before the space so that it will read "\ " (without the quotes of course) Then, you can rm/file/vi/etc. the file and figure out what it is. Special characters are often needed to be prepended with a \ in order to be used from the CLI/Regexps/etc.

HI, thats fine,
but I dont know how many spaces to be included cos single space is not working!!! But i came across some other way like ftp..i have moved that file to my windows machine then easily renamed it then put back in to the solaris machine!!!


Thanx a lot

In the future, if your shell supports tab completion (assuming that you only have one file with a leading space) you can first type the "\ " and then using tab or escape, can automatically complete the file name for you.

The best way to manipulate a file with a name that consists of an arbitrary amount of whitespace is to reference the file by it's inode number.

Find the file's inode number with "ls -i" then use the find command to remove it using the inode number: "find -inum <inode number> -exec rm {} \;"

You might also want to add a "-maxdepth 1" predicate to the above find command to limit the search to your current working directory.

Yeah, thanx for the idea.
Chao,
Shankar

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.