sfk filter as replacement for Unix cut -c?

  • tifiliriki

    tifiliriki - 2012-05-05

    For example: I have a file sample.txt consisting of the sole line:

    The Unix command

    #cut -c 1,13-15,26 sample.txt

    produces the output:

    How can I achieve this output with sfk (filter)?


  • stahlworks

    stahlworks - 2012-05-06

    This function is not available as a single command. A workaround could look like:

    sfk partcopy sample.txt 0 1 output.txt -yes
    sfk partcopy sample.txt -fromto 12 15 output.txt 1 -yes
    sfk partcopy sample.txt 25 1 output.txt 4 -yes
  • tifiliriki

    tifiliriki - 2012-05-13

    Thanks. After a week of trying I got this oneliner working:

    c:\>for /f %i in (sample.txt) do @(set a=%i & echo %a:~0,1%%a:~12,3%%a:~25,1%)
  • Anonymous

    Anonymous - 2012-06-05

    Erm . . Not sure that line would work, anyway . .

    I think all your %a…% variable mastication will substitute before setting a=%i. 

    Have I missed something?


  • tifiliriki

    tifiliriki - 2012-09-29

    Hi alten,

    thanks for the correction!

    c:\>for /f %i in (sample.txt) do @(set a=%i & echo %a:~0,1%%a:~12,3%%a:~25,1%)

    will only work if the command interpreter was invoked with

    c:\>cmd /v:on

Log in to post a comment.