Announcement

Collapse
No announcement yet.

Convert Sed in Shell Script into Batch File

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Convert Sed in Shell Script into Batch File

    Hi All,

    Is there anyone who can help me with this problem? Actually, I want to convert a shell script to the batch file. Everything seems to be easy until I found this line:

    sed '1d' create_idx_temp.sql > create_idx.sql

    My question: Is there a way to convert this so that I can use it in my batch file?

    Thanks before.

  • #2
    Re: Convert Sed in Shell Script into Batch File

    sed '1d' create_idx_temp.sql > create_idx.sql
    I think (cmiaw) this is wat that line is doing (?):
    Redirect all lines except line(s) 1 from file "create_idx_temp.sql" to a new file "create_idx.sql"

    batch:
    Code:
    FOR /f "usebackq skip=1 delims=" %%a in ("create_idx_temp.sql") do (@echo.%%a)>>"create_idx.sql"


    OR... when it is doing (?):
    Redirect just line(s) 1 from file "create_idx_temp.sql" to a new file "create_idx.sql"

    batch:
    Code:
    SetLocal ENABLEDELAYEDEXPANSION
    (Set iCnt=0)
    
    FOR /f "usebackq delims=" %%a in ("create_idx_temp.sql") do (
      (Set/a iCnt=!iCnt!+1)
      If [!iCnt!] LEQ [1] @echo.%%a>>"create_idx.sql"
    )
    EndLocal


    Where 1 is the number of lines to eighter exclude or include in the destination file.
    (counting the line numbers is started from the first line to the last line in the source file)

    \Rems

    EDIT,
    or, you can download and use 'SED for windows',
    = same command line (you just have to replace single quote signs to double-quote sign);
    sed.exe "1d" "create_idx_temp.sql" > "create_idx.sql"
    _
    Last edited by Rems; 9th March 2012, 18:39.

    This posting is provided "AS IS" with no warranties, and confers no rights.

    __________________

    ** Remember to give credit where credit's due **
    and leave Reputation Points for meaningful posts

    Comment

    Working...
    X