'How to create functions for navigating paths in unix (in tch shell)
How to create functions for navigating paths in unix (in tch shell), below I have created is not working:
#!/bin/sh
proto(){
if [ $# == 2 ]
then
`cd /zz/apxxcd/$1/$2/aaaa/caaa/`
else
`cd /Vscm/nnnn/$1/saseng/aaa/`
fi
}
proto
Solution 1:[1]
Two errors:
- Your
$#has the bad comparision operator, it should be-eqnot== - You don't give parameter to
protofunction when you call it.
Changeprotoline toproto $*
#!/bin/sh
proto(){
if [ $# -eq 2 ]
then
`cd /zz/apxxcd/$1/$2/aaaa/caaa/`
else
`cd /Vscm/nnnn/$1/saseng/aaa/`
fi
}
proto $*
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Mathieu |
