|
|
|
|
||||||
| comp.unix.shell Using and programming the Unix shell. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
How to explain the following?
$ pwd /home/user1 $ which ./a.sh ../a.sh $ which ./a.sh | grep '.*' /home/user1/a.sh $ which ./a.sh | tee /dev/null /home/user1/a.sh It gives the full path as long as it's piped. |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
Please, redo and confirm:
$ which ./a.sh ../a.sh If yes, and this: $ which ./a.sh | cat troyzeng wrote: > How to explain the following? > $ pwd > /home/user1 > $ which ./a.sh > ./a.sh > $ which ./a.sh | grep '.*' > /home/user1/a.sh > $ which ./a.sh | tee /dev/null > /home/user1/a.sh > > It gives the full path as long as it's piped. |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
On 25 Apr, 11:55, mop2 <mop2bky4mz5tyjwa8ersp7hrg5u...@gmail.com>
wrote: > Please, redo and confirm: > $ which ./a.sh > ./a.sh > > If yes, and this: > $ which ./a.sh | cat > > troyzeng wrote: > > How to explain the following? > > $ pwd > > /home/user1 > > $ which ./a.sh > > ./a.sh > > $ which ./a.sh | grep '.*' > > /home/user1/a.sh > > $ which ./a.sh | tee /dev/null > > /home/user1/a.sh > > > It gives the full path as long as it's piped. $ which ./a.sh | cat /home/user1/a.sh It also returns the full path. |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
2008-04-24, 18:35(-07), troyzeng:
> How to explain the following? > $ pwd > /home/user1 > $ which ./a.sh > ./a.sh [...] "which" is a non-standard command. You could get anything, there exist a lot of implementations behaving differently. Try "command -v" instead. -- Stéphane |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
In article <slrng12ule.4qn.stephane.chazelas@spam.is.invalid> ,
Stephane CHAZELAS <this.address@is.invalid> wrote: >2008-04-24, 18:35(-07), troyzeng: >> How to explain the following? >> $ pwd >> /home/user1 >> $ which ./a.sh >> ./a.sh >[...] > >"which" is a non-standard command. You could get anything, there >exist a lot of implementations behaving differently. > >Try "command -v" instead. That don't work at all: % command -v instead command: Command not found. % |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
2008-04-26, 16:02(+00), Kenny McCormack:
> In article <slrng12ule.4qn.stephane.chazelas@spam.is.invalid> , > Stephane CHAZELAS <this.address@is.invalid> wrote: >>2008-04-24, 18:35(-07), troyzeng: >>> How to explain the following? >>> $ pwd >>> /home/user1 >>> $ which ./a.sh >>> ./a.sh >>[...] >> >>"which" is a non-standard command. You could get anything, there >>exist a lot of implementations behaving differently. >> >>Try "command -v" instead. > > That don't work at all: > > % command -v instead > command: Command not found. [...] You forgot the quotes and the dot, and your prompt is incorrect: $ "command -v" instead. ../a.sh Having said that, it's true that csh and zsh will probably be the shells with which "which" will work best as which at least traditionnaly was only intended for csh users (as it was a csh script reading the user's cshrc) and it's also built in zsh (alias for "whence -c"). -- Stéphane |
|
|
|
#7 |
|
Messages: n/a
Hébergeur: |
In article <slrng16pi8.919.stephane.chazelas@spam.is.invalid> ,
Stephane CHAZELAS <this.address@is.invalid> wrote: >2008-04-26, 16:02(+00), Kenny McCormack: >> In article <slrng12ule.4qn.stephane.chazelas@spam.is.invalid> , >> Stephane CHAZELAS <this.address@is.invalid> wrote: >>>2008-04-24, 18:35(-07), troyzeng: >>>> How to explain the following? >>>> $ pwd >>>> /home/user1 >>>> $ which ./a.sh >>>> ./a.sh >>>[...] >>> >>>"which" is a non-standard command. You could get anything, there >>>exist a lot of implementations behaving differently. >>> >>>Try "command -v" instead. >> >> That don't work at all: >> >> % command -v instead >> command: Command not found. >[...] > >You forgot the quotes and the dot, and your prompt is incorrect: My prompt is incorrect??? Are you saying that the code that you post is dependent on what the user has set his prompt to? Bizarro! |
|
![]() |
| Outils de la discussion | |
|
|