views:

317

answers:

2

Duplicate: http://stackoverflow.com/questions/1259545/let-me-know-alternate-command-in-dos-for-following-sed-and-perl-commands-closed


the following commands have unique implementation in unix box.

Need to implement in informatica(etl tool). If not any windows solution for the same

sed 's/^#//g' < kam_account_calls.txt > kam_account_calls1.txt

perl -pi -e 's/#//' /coe/informatica/v712_OMJ/FAD/TgtFiles/C3i/CNTDEMO.csv
+2  A: 

Those two commands look quite similar and (at the same time) a bit strange.

Both look like they're trying to remove a line containing '#', but the first one will only remove a single '#' at the start of a line and the second will only remove a single '#' anywhere in the line - neither will remove the whole line!

What you probably want is either the Perl version or the sed version.

sed is a little more lightweight than Perl. You can get it for Windows.

The sed version of the command I'd expect to do what you want:

sed -i -e '/^#.*$/d' -e 's/[ \t]*#.*$//g' kam_account_calls.txt

That'll do the whole job in place. You'll need to use GNU sed for the "-i" (inplace) functionality. The above command turns this:

 a,b,c
 # a comment
 d,e,f
 # another comment
 g,h,i  # test comment
 j,k,l # test comment with space

into this:

 a,b,c
 d,e,f
 g,h,i
 j,k,l

Perl can do a similar thing for you, but it's a lot more heavyweight to install.

Michael van der Westhuizen
A: 

Or get MKS Toolkit (or cgywin), we've had good success reusing our same Unix scripts on Windows. sqplus with single quote wasn't liked.

Joe K