How to clear directory stack in csh

Barton E. Schaefer schaefer at ogcvax.ogc.edu
Wed May 18 03:15:45 AEST 1988


In article <phri.3269> roy at phri.UUCP (Roy Smith) writes:
} 
} Is there any way to clear the directory stack in csh without doing popd?

No, but there's a way to do popd without causing the csh to change to the
directory being popped.

} 	The problem was that my directory stack was "/ /mnt/etc".  I was
} allowed to umount /mnt because while /mnt/etc was in my dirstack because it
} wasn't actually the current directory of any proces, but I couldn't clear
} the dirstack because a popd would try to cd back to /mnt/etc which no
} longer existed.

To remove a bogus directory from the stack, use

	popd +N

where N is the stack position of the bogus directory.  Position 0 (zero) is
the top of the stack.  In the example above,

	% dirs
	/ /mnt/etc
	% popd +1
	/
	%

For those interested, pushd can also take a +N argument, which rotates the
directory stack N positions.

} Roy Smith, System Administrator
} Public Health Research Institute
} 455 First Avenue, New York, NY 10016
} {allegra,philabs,cmcl2,rutgers}!phri!roy -or- phri!roy at uunet.uu.net

-- 
Bart Schaefer			CSNET	schaefer at cse.ogc.edu
				UUCP	...{tektronix,verdix}!ogcvax!schaefer
    Hobbes:  "How come we play war and not peace?"
    Calvin:  "Too few role models."



More information about the Comp.unix.wizards mailing list