Operating System - HP-UX
1756704 Members
2565 Online
108852 Solutions
New Discussion

Delete Folder without name

 
Bill Hassell
Honored Contributor

Re: Delete Folder without name

I did test the recommendation.

Here's the screen captures:

 

# stty
speed 38400 baud; -parity hupcl
intr = ^C; erase = ^H; kill = ^U;
swtch <undef>;
susp = ^Z; dsusp = ^Y;
brkint -inpck icrnl ixoff onlcr tab3
-iexten echo -echoe echok
-echoctl -echoke

# mkdir ^H
  (this was: mkdir \<bs>, the shell shows ^H)

# ll -db ?
drwxr-xr-x 2 root sys 96 Jun 12 13:24 \010

# rmdir ?
# ll -db ?
? not found

This was repeated on 10.20, 11.00, 11.11, 11.23 and 11.31, PARISC and IA systems.

One could also just rmdir -i ? in case there are several one-character directories.



Bill Hassell, sysadmin
Steven Schweda
Honored Contributor

Re: Delete Folder without name

> Think again? If "stty -a" says "erase = ^H", then a backspace will
> erase the previous character, which can easily be a backslash.  So long
> as the terminal interface treats certain a character as special, the
> shell won't see it. [...]

 

   I must have been thinking of VMS, where the terminal driver deals
with this stuff, not the command-line interpreter (shell analogue).  On
a UNIX(-like) OS, the shell apparently does all the work.  Which is the
crucial fact.

 

> # mkdir ^H
>   (this was: mkdir \<bs>, the shell shows ^H)

 

   Exactly.  The _shell_ shows "^H".  You're just using the wrong shell.
Around here, for example, "\<bs>" can look like yours or mine,
depending:

 

dyi# /sbin/sh
dyi# ^H

 

   But:


dyi# /usr/local/bin/bash
dyi#

 

> This was repeated on [...]

 

   Yeah.   I tried it here on AIX, GNU/Linux (Debian), HP-UX, Solaris,
and Tru64, and I got the (my) expected result everywhere, too, but I use
"bash" everywhere.  (On HP-UX, the root user uses it only when it's
available, of course.)  So, perhaps neither of us is a complete moron,
after all.  (Or perhaps both?)

 

> > Everything's complicated.

 

   That remains true, I claim.

 

   For the record:

 

dyi# uname -a
HP-UX dyi B.11.31 U ia64 4235313755 unlimited-user license

Mat_Name
Occasional Contributor

Re: Delete Folder without name

Thank you very much for your information.

 

I tried but I failed ;-(

 

 

# rm -i *

Didn’t work, backslash-folder didn’t appear.

 

 

# rm -ir *

directory: ? (y/n) y

: ? (y/n) y

rm: directory not removed.  Directory not empty

 

 

# rmdir -i ?

?: ? (y/n) y

rmdir: ?: No such file or directory

 

 

# rmdir -i \^H

: ? (y/n) y

rmdir:: Directory not empty

 

(^H is my real backslash and not ^ and H)

 

 

 

PS:

# ll -ld ?
Is working. Sorry, I forgot question mark.

Bill Hassell
Honored Contributor

Re: Delete Folder without name

>> # rmdir -i \^H

>> : ? (y/n) y

>> rmdir:: Directory not empty

 

OK, there is something in the directory. rmdir just removes empty directories.

 

So this should work OK:

 

# rm -ir \<bs>

 

where <bs> is the backspace character. It will appear as ^H which is the shell's way of displaying the backspace.

 

If this still says directory not empty, let's see what is in that directory:

 

# ll -b \<bs>

 

There may other directories or files with bad characters.



Bill Hassell, sysadmin
Bill Hassell
Honored Contributor

Re: Delete Folder without name

>> The _shell_ shows "^H".  You're just using the wrong shell.

 

Actually, the vast majority of HP-UX systems run /sbin/sh as the root shell since this is the only functional shell in single user mode (archived libraries). If the root shell is changed to ksh, csh or BASH, the system will not have a usable shell in single user mode (a critical problem as single user mode usually means there is already a problem to solve). The rest of the users start with /usr/bin/sh (the POSIX shell, not Bourne), or may use chsh to change to /usr/bin/ksh. BASH is not part of the HP-UX distribution so it must be downloaded and installed -- assuming that data center policies allow open source tools like BASH. Where BASH is allowed, sysadmins will login as ordinary users with the BASH shell, then use sudo for root commands. Or they may simply run BASH after logging either with exec or as a child process. Supporting thousands of HP-UX servers in dozens of data centers, the standard tools (ie, POSIX shell, vi, etc) are always there. BASH has a number of useful features but availability to other data centers is not guarantied.



Bill Hassell, sysadmin
Dennis Handly
Acclaimed Contributor

Re: Delete directory with backspace in name

>So this should work OK:  rm -ir \<bs>

 

Since this works, you could simply rename the directory:

# mv \<bs> better-name

 

And in ksh and sh and vi, you can use control-V before the backspace.