Results 1 to 7 of 7
  1. #1
    linux tcsh interactive and argv

    Member Since
    Sep 28, 2007
    Posts
    8
    linux tcsh interactive and argv
    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 -

  2. #2
    linux tcsh interactive and argv
    rman's Avatar
    Member Since
    Dec 24, 2002
    Location
    Los Angeles, California
    Posts
    12,584
    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
    Cool
    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!

  3. #3
    linux tcsh interactive and argv

    Member Since
    Sep 28, 2007
    Posts
    8
    leading ` instead of '
    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 -

  4. #4
    linux tcsh interactive and argv
    rman's Avatar
    Member Since
    Dec 24, 2002
    Location
    Los Angeles, California
    Posts
    12,584
    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
    Cool
    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!

  5. #5
    linux tcsh interactive and argv

    Member Since
    Sep 28, 2007
    Posts
    8
    /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.

  6. #6
    linux tcsh interactive and argv

    Member Since
    Sep 28, 2007
    Posts
    8
    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.

  7. #7
    linux tcsh interactive and argv
    rman's Avatar
    Member Since
    Dec 24, 2002
    Location
    Los Angeles, California
    Posts
    12,584
    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
    Cool
    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!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Dual boot mac os x and linux linux on external hard drive
    By Magus10 in forum Running Windows (or anything else) on your Mac
    Replies: 11
    Last Post: 10-06-2012, 10:33 PM
  2. Mount a linux (ext3) drive in a VM instance of Linux
    By garycarroll in forum Running Windows (or anything else) on your Mac
    Replies: 4
    Last Post: 01-13-2009, 10:22 AM
  3. tcsh - questions about alias, dotfiles
    By newdaddy in forum OS X - Operating System
    Replies: 4
    Last Post: 09-28-2007, 07:20 PM
  4. Running Linux apps on my Mac or Linux itself
    By Nightblade in forum OS X - Development and Darwin
    Replies: 2
    Last Post: 05-24-2004, 01:24 PM
  5. Fixing tcsh in OS X 10.2.x
    By gatorparrots in forum OS X - Development and Darwin
    Replies: 0
    Last Post: 12-23-2002, 04:29 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •