Bash Function Problem
Hello:
I am getting the same error for both functions but I can't figure out why? They both should work! The error is: bash: syntax error near unexpected token `{place=`echo $@`' bash: syntax error near unexpected token `{tree' findlocation() {place=`echo $@`; lynx -dump "http://maps.google.com/maps/geo?output=json&oe=utf-8&q=$place" | egrep "address|coordinates" | sed -e 's/^ *//' -e 's/"//g' -e 's/address/Full Address/';} tt(){tree -pFCfa . | grep "$1" | less -RgIKNs -P "H >>> "} Thanks to all |
Hi,
Why the explicit place=`echo $@`, why not: place="$@" Hope this helps. |
Hi again,
About the tee error: Not sure what it is you are trying to accomplish with that function, but the tee command listens to standard in and I don't see anything 'feeding' it, and which file is it writing to? input -> tee -> output goes to file _and_ standard out (screen in most cases) I need new glasses! Read tee instead of tree....... Hope this helps. |
Functions have their own syntax about placing the brackets: the opening bracket must be followed by a newline or a blank space; the closing bracket must be on its own line or eventually on the same line of the preceding commands if and only if the last command is followed by semi-colon. The following alternatives should work:
Code:
tt(){ Code:
tt() Code:
tt(){ tree -pFCfa . | grep "$1" | less -RgIKNs -P "H >>> " Code:
tt(){ tree -pFCfa . | grep "$1" | less -RgIKNs -P "H >>> "; } |
All times are GMT -5. The time now is 04:05 AM. |