2

I have being trying to write some scripts in both unix and windows environment. I am facing problem when trying to write equivalent windows command for:

cmd = "cat raw_data.txt | awk -F\"}\" '{for(i =1; i<=NF-1; i++){print $i\"}\"}}' | sed 's/^,//' | sed 's/^[ \t]*//;s/[ \t]*$//' | sed 's/^{//; s/}$//'"
Michael
  • 32,527
  • 49
  • 210
  • 370
Deepak Thota
  • 87
  • 1
  • 2
  • 13
  • stop using `cat` when you don't need to. `awk '....' raw_data.txt | sed ...` Also, what is your intent with `cmd = "cat ...` Just to initialize a variable with the string literal `cat raw_...` ? OR to assign the output of the that command chain to the variable `cmd`? I'll be surprized if others can show you a way to achieve a common syntax between Windows and Unix, unless you're using a Unix on Windows platform, like cygwin, mingw or Uwin. Good luck. – shellter May 05 '15 at 16:35
  • Hey @shellter I am sorry but I didn't get all of what you asked me there! But, I am trying to convert a python program developed in Linux environment to Windows environment and was lost when it came to this particular point. – Deepak Thota May 05 '15 at 18:01
  • if you're " trying to convert a python program developed in Linux environment to Windows environment", then you should include that information in your question and probably include a python tag as well. BUT, as is, your question is to vague to be answerable. You need to reduce the problem to so that others can help solve it. right now there are too many unknowables about your problem and situation. Good luck. – shellter May 05 '15 at 19:09
  • As a standard windows environment doesn't have `awk` (or many other unix tools available), you might search for "convert unix script to powershell". Good luck. – shellter May 05 '15 at 19:10
  • 2
    There's a similar SO question [here](http://stackoverflow.com/questions/60244/is-there-replacement-for-cat-on-windows). – DeveloperDan Feb 03 '16 at 16:18

2 Answers2

5
type file1 >> file2
as 
cat file1 file2 > file3

type is the one used equivalent to cat command but it can have only part of its functionality

zulc22
  • 337
  • 2
  • 7
  • 17
Coder_Wolfy
  • 124
  • 10
0

You can use copy /b like this:

copy /b file1+file2 newfile
ishant kaushik
  • 891
  • 6
  • 18