New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus Advice and insight from world-class Apple enthusiasts Exclusive access to members-only contests, giveaways and deals

Join today!

 
Start a Discussion
 

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
Running Windows (or anything else) on your Mac Discussion of Classic or running Windows, Linux and other OSes on the Mac.

linux tcsh interactive and argv


Post Reply New Thread Subscribe

 
Thread Tools
newdaddy

 
Member Since: Sep 28, 2007
Posts: 8
newdaddy is on a distinguished road

newdaddy is offline
Hi all,

I have, in a .cshrc file ported from my old unix .alias file, some aliases like this;

alias oneCol 'tr " " "\012" < $1 > $2'

I'm running interactive tcsh on my Tiger OS X, and these aliases fail here, like this;

> oneCol test1 testOut
tcsh: $1: Ambiguous.

I believe this is because argv is not set for these interactive tcsh commands. Is there some way to force argv to be set in OS X tcsh? Or what would an equivalent tcsh alias be? (Please, please, don't tell me to use some other shell.)

Thanks -
QUOTE Thanks
rman

 
rman's Avatar
 
Member Since: Dec 24, 2002
Location: Los Angeles, California
Posts: 12,589
rman has much to be proud ofrman has much to be proud ofrman has much to be proud ofrman has much to be proud ofrman has much to be proud ofrman has much to be proud ofrman has much to be proud ofrman has much to be proud ofrman has much to be proud ofrman has much to be proud of
Mac Specs: 2 x 3.0GHz Quad-Core, 6GB OS X 10.6.8 | 15in MacBook Pro 2.2GHz OS X 10.6.8 | 64GB iPad 2 WiFi

rman is offline
What I see is that the ' should be a `. I could be wrong thou.

Life isn't about waiting for the storm to pass, It's about learning to dance in the rain!
QUOTE Thanks
newdaddy

 
Member Since: Sep 28, 2007
Posts: 8
newdaddy is on a distinguished road

newdaddy is offline
rman,

I can't make your suggestion work, if I understand you correctly. I tried

alias oneCol `tr " " "\012" < $1 > $2'

also

alias oneCol `tr " " "\012" < $1 > $2`

and

alias oneCol `tr " " "\012" < \$1 > \$2`

LMK if I'm doing something stupid here -
QUOTE Thanks
rman

 
rman's Avatar
 
Member Since: Dec 24, 2002
Location: Los Angeles, California
Posts: 12,589
rman has much to be proud ofrman has much to be proud ofrman has much to be proud ofrman has much to be proud ofrman has much to be proud ofrman has much to be proud ofrman has much to be proud ofrman has much to be proud ofrman has much to be proud ofrman has much to be proud of
Mac Specs: 2 x 3.0GHz Quad-Core, 6GB OS X 10.6.8 | 15in MacBook Pro 2.2GHz OS X 10.6.8 | 64GB iPad 2 WiFi

rman is offline
Try this

alias oneCol "`tr ' ' '\012' < $1 > $2`"

Life isn't about waiting for the storm to pass, It's about learning to dance in the rain!
QUOTE Thanks
newdaddy

 
Member Since: Sep 28, 2007
Posts: 8
newdaddy is on a distinguished road

newdaddy is offline
/Users/crose1 > alias oneCol "`tr ' ' '\012' < $1 > $2`"
tcsh: Missing name for redirect.
/Users/crose1 > alias oneCol "`tr ' ' '\012' < \$1 > \$2`"
/Users/crose1 > oneCol test1 test1.out
tcsh: test1: Permission denied.
/Users/crose1 > which oneCol
oneCol: aliased to
/Users/crose1 > alias oneCol "tr ' ' '\012' < $1 > $2"
/Users/crose1 > oneCol test1 test1.out
tcsh: Missing name for redirect.
/Users/crose1 > alias oneCol
tr ' ' '\012' < >
/Users/crose1 > alias oneCol "tr ' ' '\012' < \$1 > \$2"
/Users/crose1 > oneCol test1 test1.out
tcsh: : No such file or directory.
/Users/crose1 > alias oneCol
tr ' ' '\012' < \ > \
/Users/crose1 > alias oneCol `tr ' ' '\012' < $1 $2`
tcsh: $1: Ambiguous.
/Users/crose1 > alias oneCol `tr ' ' '\012' < \$1 \$2`
tcsh: $1: No such file or directory.

OK, I give up. Instead, I just put this in my bin directory, instead, as a file named oneCol (and then gave it execute permission, and did a rehash).

!#/bin/sh
tr ' ' '\012' < $1 > $2

This command isn't such a great example, because it's a command you might otherwise want to pipe to something else (but because of the argv redirection, you can't). There are other commands which are much more appropriate for this, and for each of those, I'll just move them each to their own file in my local bin dir.

Thanks rman for trying to help me out - I appreciate it.
QUOTE Thanks
newdaddy

 
Member Since: Sep 28, 2007
Posts: 8
newdaddy is on a distinguished road

newdaddy is offline
FINALLY, I have the answer I was looking for. Here is a correct alias that uses command line arguments;

alias oneCol 'tr " " "\012" < \!:1 > \!:2'

I don't know why this works, but it does. I found a syntax example for this in article 10.03 of O'Reilly's UNIX POWER TOOLS.

I realize it is a waste of time to agonize over something that there's a dozen different ways to otherwise do, but I feel so much better having found the answer I originally set out to look for.
QUOTE Thanks
rman

 
rman's Avatar
 
Member Since: Dec 24, 2002
Location: Los Angeles, California
Posts: 12,589
rman has much to be proud ofrman has much to be proud ofrman has much to be proud ofrman has much to be proud ofrman has much to be proud ofrman has much to be proud ofrman has much to be proud ofrman has much to be proud ofrman has much to be proud ofrman has much to be proud of
Mac Specs: 2 x 3.0GHz Quad-Core, 6GB OS X 10.6.8 | 15in MacBook Pro 2.2GHz OS X 10.6.8 | 64GB iPad 2 WiFi

rman is offline
Glad to see you found a solution. I would have never thought of the bang colon.

Life isn't about waiting for the storm to pass, It's about learning to dance in the rain!
QUOTE Thanks

Post Reply New Thread Subscribe


« Ubuntu Gutsy along with GRUB away from Leopard's way | VM Fusion ? »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

All times are GMT -4. The time now is 08:44 PM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
X

Welcome to Mac-Forums.com

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!


(4 digit year)

Already a member?