<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 14 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
{font-family:"Lucida Console";
panose-1:2 11 6 9 4 5 4 2 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
{mso-style-priority:99;
mso-style-link:"Balloon Text Char";
margin:0in;
margin-bottom:.0001pt;
font-size:8.0pt;
font-family:"Tahoma","sans-serif";}
span.hoenzb
{mso-style-name:hoenzb;}
span.EmailStyle18
{mso-style-type:personal-reply;
font-family:"Calibri","sans-serif";
color:#1F497D;}
span.BalloonTextChar
{mso-style-name:"Balloon Text Char";
mso-style-priority:99;
mso-style-link:"Balloon Text";
font-family:"Tahoma","sans-serif";}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri","sans-serif";}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>There is also ‘pushd +<number>’ where the number is an index into the stack. You can say ‘dirs’ to get a list of the shell stack…<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>As a reminder to anyone confused – remember we are talking about commands to the SHELL. You (usually) are sitting at a command prompt doing this. I regularly have anywhere from 2 to 10 directories on my shell<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>For example, here is ‘dirs’ from my windows machine in a shell that I have done very little in:<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:"Lucida Console"'>$ dirs<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:"Lucida Console"'>/cygdrive/c/Users/rusty.carruth/Documents ~<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:"Lucida Console"'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:"Lucida Console"'>And from a linux bos:<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:"Lucida Console"'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>rusty@sr-arz-web01 ~/performance_numbers/parser/logs $ dirs<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>~/performance_numbers/parser/logs ~/performance_numbers/cairoplot-1.1<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>I have started using pushd/popd in my shell scripts when I need to change to a certain directory (to make the job easier, usually). A lot easier than “set pastdir=`pwd`;cd somewhere ; do_stuff;cd $pastdir” since I seem to get that first set wrong too often.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Also, when writing ‘keyboard scripts’ I use pushd/popd a lot when doing this sort of thing:<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>for I in `find . –type d` ; do pushd $i ; do_stuff && do_other_stuff_that_only_should_happen_if_stuff_was_ok; popd ; done<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Understanding the above ‘command-line (or keyboard) script’ is left as an exercise for the reader ;-)<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Rusty<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif";color:navy'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> plug-discuss-bounces@lists.phxlinux.org [mailto:plug-discuss-bounces@lists.phxlinux.org] <b>On Behalf Of </b>Michael Havens<br><b>Sent:</b> Friday, October 10, 2014 1:36 PM<br><b>To:</b> Main PLUG discussion list<br><b>Subject:</b> Re: pushd/popd<o:p></o:p></span></p><p class=MsoNormal><o:p> </o:p></p><div><p class=MsoNormal>I see. So it is a way to stack directories in your order so you can go in reverse a certain order and save yourself some typing. pushd is strange. if you execute it alone it reverses the last two directories on your stack. I didn't know about 'cd -'; thanks for sharing that with me.<o:p></o:p></p></div><div><p class=MsoNormal><br clear=all><o:p></o:p></p><div><p class=MsoNormal>:-)~MIKE~(-:<o:p></o:p></p></div><p class=MsoNormal><o:p> </o:p></p><div><p class=MsoNormal>On Fri, Oct 10, 2014 at 1:10 PM, James Mcphee <<a href="mailto:jmcphe@gmail.com" target="_blank">jmcphe@gmail.com</a>> wrote:<o:p></o:p></p><div><p class=MsoNormal>pushd and popd are stack-oriented. You may notice with cd that you can do "cd -" to go to your previous directory. Think of pushd and popd as a way to store those up. You pushd into various directories, which loads them up on the stack, then popd and you get cd'd back into those directories (in reverse order).<o:p></o:p></p><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>Now, you may be asking yourself "why?". It's just an old way of doing things back when the speed of stack memory meant something. I'm sure someone could figure out an actual use for it, but every time I see it implemented, it's done to be obscure, not because it couldn't be more simply implemented with an array.<o:p></o:p></p></div></div><div><p class=MsoNormal><o:p> </o:p></p><div><p class=MsoNormal>On Fri, Oct 10, 2014 at 1:06 PM, Michael Havens <<a href="mailto:bmike1@gmail.com" target="_blank">bmike1@gmail.com</a>> wrote:<o:p></o:p></p><div><p class=MsoNormal>what is the difference between pushd and pod and the command cd<br clear=all><o:p></o:p></p><div><p class=MsoNormal>:-)~MIKE~(-:<o:p></o:p></p></div></div><p class=MsoNormal><br>---------------------------------------------------<br>PLUG-discuss mailing list - <a href="mailto:PLUG-discuss@lists.phxlinux.org" target="_blank">PLUG-discuss@lists.phxlinux.org</a><br>To subscribe, unsubscribe, or to change your mail settings:<br><a href="http://lists.phxlinux.org/mailman/listinfo/plug-discuss" target="_blank">http://lists.phxlinux.org/mailman/listinfo/plug-discuss</a><o:p></o:p></p></div><p class=MsoNormal><span style='color:#888888'><br><br clear=all><span class=hoenzb><o:p></o:p></span></span></p><div><p class=MsoNormal><o:p> </o:p></p></div><p class=MsoNormal><span class=hoenzb><span style='color:#888888'>-- </span></span><span style='color:#888888'><br><span class=hoenzb>James McPhee</span><br><span class=hoenzb><a href="mailto:jmcphe@gmail.com" target="_blank">jmcphe@gmail.com</a> </span></span><o:p></o:p></p></div><p class=MsoNormal><br>---------------------------------------------------<br>PLUG-discuss mailing list - <a href="mailto:PLUG-discuss@lists.phxlinux.org">PLUG-discuss@lists.phxlinux.org</a><br>To subscribe, unsubscribe, or to change your mail settings:<br><a href="http://lists.phxlinux.org/mailman/listinfo/plug-discuss" target="_blank">http://lists.phxlinux.org/mailman/listinfo/plug-discuss</a><o:p></o:p></p></div><p class=MsoNormal><o:p> </o:p></p></div></div></body></html>