Skip to main content

Questions tagged [pushd]

0 votes
0 answers
57 views

pushd within a pipeline says it's adding to the stack, but it's not? [duplicate]

I'm working on a modification of this approach to automatically saving and restoring bash's directory stack state when using pushd and popd. For some reason, my code to restore the saved state isn't ...
Dan Drake's user avatar
  • 151
1 vote
1 answer
47 views

`pushd` inside a while loop from file contents does not behave the same depending on read method [duplicate]

I'm pushing directories to my stack using a while loop that reads the contents of a file. I've tried two approaches that should be equivalent, but they behave different. Approach 1 export ...
Jorge Ricardo Alonso Fernández's user avatar
2 votes
3 answers
521 views

Confusing pushd/popd behaviour when sourcing script in zsh

I have a script which I source while in bash. It does various things and retains the $PWD I was in before sourcing it. pushd ~/.dotfiles >/dev/null || exit 1 # Do various things popd >/dev/...
paradroid's user avatar
  • 1,265
0 votes
1 answer
106 views

how to "execute command on file in multiple subdirectories within containing folder" i.e cd into each subdirectory containing file and execute command

I have a file named filename.sh in different directories. I am trying to simultaneously submit this file to run on a number of cluster nodes. I need to find this file wherever they may be, cd into ...
Daniel Ajuzie's user avatar
2 votes
2 answers
406 views

What is the zsh equivalent of "pushd -n" in bash?

I want to push a directory onto the directory stack in order to refer to it using "tilde shorthand" (eg. ~1 refers to the second entry in the directory list), but I don't want to actually ...
chb's user avatar
  • 709
1 vote
1 answer
91 views

Getting tcsh dextract-like pushd functionality in bash

I love bash (4.1.2(1)-release) but I strongly prefer the way tcsh implements pushd +N with the dextract option enabled, so much so that I refuse to use bash as my default shell because of it. Has ...
Vercingatorix's user avatar
7 votes
1 answer
851 views

How is the pushd directory stack stored?

In a related question somebody states that the directory stack of the pushd command is emptied when your shell terminates. But how is the stack actually stored? I use fish instead of bash and the ...
jallersma's user avatar
2 votes
2 answers
3k views

Directory stack (pushd and popd) behaviour in bash scripts

If I poorly write a script that uses pushd /etc but I don't finish it with popd: Will /etc still be in the pushd+popd directory stack/in RAM after the bash script has finished executing and Bash has ...
Bean6754's user avatar
0 votes
1 answer
107 views

$@ in alias inside script: is there a "local" $@?

I have aliased pushd in my bash shell as follows so that it suppresses output: alias pushd='pushd "$@" > /dev/null' This works fine most of the time, but I'm running into trouble now using it ...
Théophile's user avatar
3 votes
1 answer
111 views

Can I rearrange the directories in `dirs` in the order of their most recent visits?

What is the order for the pathnames of the directories stored in the stack shown by dirs -l? Are they ordered by their last pushd commands? Is it possible to order them so that they are ordered by ...
Tim's user avatar
  • 107k
-4 votes
2 answers
868 views

Why does `pushd` always output the stack to stdout? [closed]

pushd push a directory into the directory stack, and change the working directory. I guess that is all we need. But besides, why does pushd always output the stack to stdout? I think that is ...
Tim's user avatar
  • 107k
2 votes
1 answer
2k views

Why can't I which pushd

I've been using pushd and popd for a long time while writing bash script. But today when I execute which pushd, I get nothing as output. I can't understand this at all. I was always thinking that ...
Yves's user avatar
  • 3,411
1 vote
1 answer
780 views

`mktemp -d` followed by `pushd` works fine on command line, but not when in a script

If I paste these lines into a command prompt on Debian... DIR=$(mktemp -d -t bbbrtc.XXXXXX) || exit 1 echo "tmpdir = $DIR" cd "$DIR" They make a new temp directory, print the directory name, and then ...
bigjosh's user avatar
  • 599
2 votes
2 answers
4k views

Difference between pushd/popd and sub-shell+cd

I'm trying to understand if there are any benefits of using: pushd my_dir make all # ... or something else popd vs ( cd my_dir make all # ... or something else ) or is it merely a ...
ahmet alp balkan's user avatar
0 votes
1 answer
66 views

How shall we reproduce the stack in `dirs -v`?

I have a file whose content is the output of dirs -v, i.e. pathnames to directories: 0 ~/program_files/OS/dirs/recentVisitedDirs 1 ~/cs/security/computer security/OS security/user management/...
Tim's user avatar
  • 107k

15 30 50 per page