Operating System - HP-UX
1832957 Members
2473 Online
110048 Solutions
New Discussion

ksh -i vi instead of -o option

 
SOLVED
Go to solution
Dan Copeland
Regular Advisor

ksh -i vi instead of -o option

How can I get back my clean files and directory. I mistakenly typed
ksh -i vi instead of ksh -o vi on my directory.

My directory is now unreadable. though I could change to the directories that I know. within the same gabbled directories.

Please, do not try it on a production system or a dirctory with useful files if you do not know how to resolve.
5 REPLIES 5
Tim D Fulford
Honored Contributor

Re: ksh -i vi instead of -o option

I THINK you just need to exit & re-enter your session...

from the man page...
Invoking ksh
If the shell is invoked by exec (see exec(2)), and the first character
of argument zero ($0) is -, the shell is assumed to be a login shell
and commands are read first from /etc/profile. The expression
${HOME:-.}/.profile is then evaluated and an attempt to open the
resulting filename is made. If the file is opened successfully, the
file is read. Next, commands are read from the file named by
performing parameter substitution on the value of the environment
parameter ENV, if the file exists. If the -s option is not present
and arg is, a path search is performed on the first arg to determine
the name of the script to execute. When running ksh with arg, the
script arg must have read permission and any setuid and getgid
settings are ignored. Commands are then read as described below. The
following options are interpreted by the shell when it is invoked:
:
:
-i
If the -i option is present or if the shell input
and output are attached to a terminal (as reported
by tty(3C)), the shell is interactive. In this
case SIGTERM is ignored (so that kill 0 does not
kill an interactive shell) and SIGINT +1 is caught
and ignored (so that wait is interruptible). In
all cases, SIGQUIT is ignored by the shell. (See
signal(5).)


Tim
-
Stefan Farrelly
Honored Contributor
Solution

Re: ksh -i vi instead of -o option

Cor, what mess! youre dead right, this command makes a real mess out of your file listing.

Anyway, all its done is created lots of files with strange filenames and control characters in them which each time you list them screw up your display.

To display them without screwing up your display do;

cd
ls -l | vis | more

From this you will see any control characters shown as \xxx. These are the files you need to delete. You can firstly try;

rm -i ./*

And it will ask for confirmation on each file in turn if you want to delete it. Delete any which look like garbage. I tried this first and still my display got corrupted when using rm -i ./* !! So instead I had to do;

ls -l | vis | more

and look for any files with \xxx (control characters in them) and try to remove them first with rm, ie. if they start with a\001\034.. then rm a*
Once I did this a few times rm -i ./* worked and I could remove the rest of the funny filenames, then all was back to normal.
Im from Palmerston North, New Zealand, but somehow ended up in London...
Dan Copeland
Regular Advisor

Re: ksh -i vi instead of -o option

Stefan,

Wonderful, Thanks for the assistance. I have my directories back now.

You are the man.

brian_31
Super Advisor

Re: ksh -i vi instead of -o option

Hi Stefan:

Can you explain what ls -l|vis does?

Thanks & Regards
Brian.
Bill Hassell
Honored Contributor

Re: ksh -i vi instead of -o option

man vis

However, the ls/ll command has the equivalent feature:

ll -b

The idea is to make special characters visible.

A note for user that find themselves in this situation (a lot of files with control characters)...HP terminals (and HP terminal emulators such as WRQ's Reflection/1 for HP) have a setting to turn on the display of every character including nuls and dels. It's called DISPLAY FUNCTIONS. When turned on, all characters will be displayed.


Bill Hassell, sysadmin