1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Inline backreference?

Discussion in 'T&T - Miscellaneous' started by nickles, Nov 16, 2011.

  1. nickles

    Joined:
    Jun 24, 2008
    Messages:
    220
    Likes Received:
    0
    Is there a possibility to backreference the command line tokens in TCC?

    Sample:

    grep -g <file>test.txt -o [backref#3].new

    which would expand to:

    grep -g test.txt <file> -o test.txt<file>.new</file></file>
    </file>
     
  2. Steve Fabian

    Joined:
    May 20, 2008
    Messages:
    3,520
    Likes Received:
    4
    From: nickles
    | Is there a possibility to backreference the command line tokens in
    | TCC?
    |
    | Sample:
    |
    | grep -g test.txt -o [backref#3].new
    |
    | which would expand to:
    |
    | grep -g test.txt -o test.txt.new

    It is easy to do in aliases and batch files - your example would use %2. No method I am aware of to do it in the command line, i.e., interactively. When I need something like this the token to be repeated is usu. a file or directory name, so I just use tab-expansion. My most common use is when I want to use the RENAME command to move a file or a directory to a new location.
    --
    Steve
     
  3. nickles

    Joined:
    Jun 24, 2008
    Messages:
    220
    Likes Received:
    0
    Thanks for the answer Steve.

    I'd like to do it from the command line however, w/o the need to write a BTM file for all such occasions.

    nickles
     
  4. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,312
    Likes Received:
    39
    I thought that was what the F12 key was for. But now that I try it, it doesn't seem to work the way I thought it did....
     
  5. Steve Fabian

    Joined:
    May 20, 2008
    Messages:
    3,520
    Likes Received:
    4
    From: nickles
    | I'd like to do it from the command line however, w/o the need to
    | write a BTM file for all such occasions.

    If you have the same command structure with only a single parameter changing for each invocation, you could write an alias. E.g. for your original example:

    alias grepg=`grep -g %1 -o %1.new`

    which you can use thus:

    grepg text.txt

    I know this is much less than what you'd like, but it is all I can think of off-hand.
    --
    HTH, STeve
     
  6. samintz

    samintz Scott Mintz

    Joined:
    May 20, 2008
    Messages:
    1,191
    Likes Received:
    11
    Well, if you know you are going to need a second reference to a file, then the combination of TAB and F12 will help.

    HTML:
    basically you type: grep -g text.txt<TAB><F12><Ctrl+Left>-o <END>.new
    


    While slightly cumbersome, it's still less typing than having to type the name again.

    But if that command is something you do often, then making an alias will ease your life. Plus you could always implement the alias, then type the command like Steve suggested, then press CTRL+X (or Ctrl+F I can never remember) to expand the alias and edit it.
    -Scott-----Steve Fabian <> wrote: -----


    From: nickles| I'd like to do it from the command line however, w/o the need to| write a BTM file for all such occasions. If you have the same command structure with only a single parameter changing for each invocation, you could write an alias. E.g. for your original example:alias grepg=`grep -g %1 -o %1.new`which you can use thus:grepg text.txtI know this is much less than what you'd like, but it is all I can think of off-hand.-- HTH, STeve
     
  7. samintz

    samintz Scott Mintz

    Joined:
    May 20, 2008
    Messages:
    1,191
    Likes Received:
    11
    Well, that sure got mangled in translation. The text originally contained
    angle brackets. Looks like it's okay on the web page though.

    I'll try square brackets instead of angle brackets and see if it comes
    through.

    Code:
    basically you type: grep -g text.txt[TAB][F12][Ctrl+Left]-o [END].new
    
    -Scott



    Well, if you know you are going to need a second reference to a file, then
    the combination of TAB and F12 will help.

    HTML Code:
    basically you type: grep -g text.txt-o .new
    While slightly cumbersome, it's still less typing than having to type the
    name again.

    But if that command is something you do often, then making an alias will
    ease your life. Plus you could always implement the alias, then type the
    command like Steve suggested, then press CTRL+X (or Ctrl+F I can never
    remember) to expand the alias and edit it.
    -Scott-----Steve Fabian <> wrote: -----


    From: nickles| I'd like to do it from the command line however, w/o the
    need to| write a BTM file for all such occasions. If you have the same
    command structure with only a single parameter changing for each
    invocation, you could write an alias. E.g. for your original example:alias
    grepg=`grep -g %1 -o %1.new`which you can use thus:grepg text.txtI know
    this is much less than what you'd like, but it is all I can think of
    off-hand.-- HTH, STeve
     

Share This Page