[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: display variable multiple times




> "while [ $variable < $1 ]; do"

Actually, I meant "-lt" instead of "<". Sorry.


Anyway, this script does what you've mentioned, except for one problem:

#!/bin/bash

UP="/.."
COMMAND="cd .."
NUM=1

while [ $NUM -lt $1 ]; do
   COMMAND=$COMMAND$UP
   NUM=$((NUM+1))
done

$COMMAND



The problem is that your concept is inherently hosed. The *program*
changes directories (you can prove this by making "ls" your final
command), but YOU do not. Therefore, YOU will be back in the same
directory when the program finishes.

To accomplish what you want, why not make some aliases?

alias back1='cd ..'
alias back2='cd ../..'

etc. Then you'll basically have what you want.


-J

-
To unsubscribe, send email to majordomo@luci.org with
"unsubscribe luci-discuss" in the body.