|
|
|
|
||||||
| comp.unix.shell Using and programming the Unix shell. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Hi all
on study bash I 've got an other problem: ================================================== ====== test.sh #!/bin/bash if [ -z "$1" ]; then # using pipe as input : awk $1 symbol is not sh's $1 # also ignore error checking here. awk '{print $1 }' else echo $($1 | awk '{print $1}') fi ================================================== ====== $echo "10 this is 10" | ./test.sh 10 but ../test.sh '10 this is 10' do not work how to do that in right grammar? |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
Hard to know what you are trying to do but play around with this.
#!/bin/bash if [ -z "$1" ]; then # using pipe as input : awk $1 symbol is not sh's $1 # also ignore error checking here. awk '{print $1 }' else echo "$1" | awk '{print $1}' fi key9 wrote: > Hi all > > on study bash I 've got an other problem: > > ================================================== ====== > test.sh > #!/bin/bash > if [ -z "$1" ]; then > > # using pipe as input : awk $1 symbol is not sh's $1 > # also ignore error checking here. > > awk '{print $1 }' > > > else > > echo $($1 | awk '{print $1}') > > fi > ================================================== ====== > > > > > $echo "10 this is 10" | ./test.sh > 10 > > but > > ./test.sh '10 this is 10' > > do not work > > how to do that in right grammar? |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
2006-12-7, 16:14(+08), key9:
> Hi all > > on study bash I 've got an other problem: > > ================================================== ====== > test.sh > #!/bin/bash Why call bash for an sh script? That's confusing even though it'd OK. > if [ -z "$1" ]; then if [ "$#" -eq 0 ] You were testing whether $1 was empty > > # using pipe as input : awk $1 symbol is not sh's $1 > # also ignore error checking here. > > awk '{print $1 }' > > > else > > echo $($1 | awk '{print $1}') printf '%s\n' "$@" | awk '{print $1}' > > fi > ================================================== ====== [...] If you replace #! /bin/bash with #! /bin/sh - you remove the dependency on bash that is not needed here. -- Stéphane |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
> Hard to know what you are trying to do but play around with this.
just study :-) Sorry for my knowledge, I understand things like Unix shell ,and UNIX desgin philosophy only 2 month also I am not computer specialty before that , when I want to solve some problem , I always using VBScripts. and now I found another way- shell programming pretty cool,like playing toy bricks. so the situation is I have concept of what I want to solve (modeing), but I have no idea how to do that in shell. especially in grammar details. I think it's good news for me there's so much warmhearted people here :-) appreciate |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
key9 wrote: > > Hard to know what you are trying to do but play around with this. > > just study :-) > > Sorry for my knowledge, > > I understand things like Unix shell ,and UNIX desgin philosophy only 2 month > also I am not computer specialty > > before that , when I want to solve some problem , > I always using VBScripts. > > and now I found another way- shell programming > pretty cool,like playing toy bricks. > > so the situation is I have concept of what I want to solve (modeing), > but I have no idea how to do that in shell. especially in grammar details. > > I think it's good news for me there's so much warmhearted people here > :-) > > appreciate Are you trying to do something along these lines? http://www.datasavantconsulting.com/...ripts/derprogs |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
> Are you trying to do something along these lines? > http://www.datasavantconsulting.com/...ripts/derprogs no , but that's a great :-) thank you actually I want to design a mechanism which can simulate network node's actions. First I put everyting into a very large c++ application, That almosted kill me. more than 200 classes which make one application and accept input and get the resoult. which still can not run ,I am sorry to say. finally I got the idea : who cares how fast the scripts run , I just want the simulate resoult to me judge the next step. so shell scripting is the best way. since I've got no experience about shell coding , so grammar will be the biggest problem. |
|
![]() |
| Outils de la discussion | |
|
|