Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm trying to use the dirs command with the +N option. The manual says:

 dirs [-clpv] [+n] [-n]
          Without options, displays the list of currently remembered directories.  The default display is on a single line with directory names separated by spaces.   Direc-
          tories are added to the list with the pushd command; the popd command removes entries from the list.
          +n     Displays the nth entry counting from the left of the list shown by dirs when invoked without options, starting with zero.

dirs -v shows:
0 /dir1/
1 /dir2/
2 /dir3/

However, dir +n 1, dir +N 1, dir -v +n 1, dir -v +N 1 all give:

bash: dirs: +n: invalid number
dirs: usage: dirs [-clpv] [+N] [-N]

Does anyone know what I'm doing wrong?

Thanks

Taras

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

The command dirs +N means that you actually have to put a number there:

$ dirs -v
 0  /usr/local
 1  /usr
 2  /etc/init.d
 3  /etc
 4  /
 5  ~

$ dirs +3
/etc
share|improve this answer
add comment

If you look closely, you will see that the n is underlined, which means it's a variable, not a string that you type verbatim.

In this case, the n stands for any number

e.g. dirs +1 or pushd +1.

share|improve this answer
    
Both correct - probably should have inown that :*) –  Taras Feb 10 '11 at 0:30
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.