perl beginner on windows - problems executing perl -n -e in windows command prompt

StackOverflow https://stackoverflow.com/questions/15989269

  •  03-04-2022
  •  | 
  •  

سؤال

I use W7 64bit and I just installed strawberry perl. I need to execute a simple script from windows command line for manipulation of text files:

perl -ne 'chomp; print "$_ O O O O\n"' test.txt > textformatted.txt

I get error:

Can't find string terminator "'" anywhere before EOF at -e line 1.

It's in the PATH and also I can call perl -v. I tried adding spaces, replacing ' with ", backslashs etc. but no use.

I looked at tutorials and searched on the web and I found a lot of statements like this so it seems that this statement should work. But it doesn't.

Can somebody please help me? Where is the mistake?

هل كانت مفيدة؟

المحلول

You need to change your single quotes to double quotes.

perl -ne "chomp; print qq($_ O O O O\n)" test.txt > textformatted.txt
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top