BASH alias not working...
mathbymath at aol.com
Tue Jun 21 00:14:41 UTC 2005
On Jun 20, 2005, at 7:57 PM, Colin Watson wrote:
> On Mon, Jun 20, 2005 at 07:43:24PM -0400, Matthew S-H wrote:
>> This is the code I added to my "~/.bashrc":
>> alias "choose_to_edit"="cat /dev/null &&
>> cd ~/Documents/ &&
>> command ls | grep -n -v 'randomcraptonotmatch' | column &&
>> echo 'Choose which one to edit:' &&
>> read &&
>> if test $REPLY -eq 1 ;
>> then cat /dev/null &&
>> echo 'test';
>> Before I continued any further with this script, I wanted to test to
>> see if that worked. However, it didn't...
>> It gives we the following error:
>> -bash: test: -eq: unary operator expected
> You should quote "$REPLY" thus so that it expands to an empty word
> rather than disappearing altogether if it's empty. You should probably
> also use = rather than -eq so that test does string matching and
> therefore doesn't complain about non-numeric arguments.
This didn't do it. This compared the string "$REPLY" to 1.
When it executes "read", it gets a line of input from the user and
places it in the environment variable "$REPLY".
The "if test $REPLY -eq 1 ;" should compare this variable to the
A revised version of my code:
alias "choose_to_edit"="cat /dev/null &&
cd ~/Documents/ &&
command ls | grep -n -v 'randomcraptonotmatch' | column &&
echo 'Choose which one to edit:' &&
if test '$REPLY' = 1 ;
then cat /dev/null &&
More information about the ubuntu-users