English 中文(简体)
Grep doesn t work correctly with .as files
原标题:

Here s the statement I m running:

grep -i -H  ConfigureControls  *.as

Note that I m forcing file names with the -H flag.

What I get back is:

}       }   trac}   }   this.chairControls.debug.appendText("
An error occured when communicating with server:
" + err.message);l);his.chairXML.storeResult;
{ackage {ublic cpublic frequest = new URLRequest(this.chairXML.store);to: " + this.chairXML.store;noll

No filename, and the text also looks very mangled (package has become {ackage, for example). What s going on?

最佳回答

It sounds like you re grepping old Mac (OS <= 9) CR eol-style files on a machine that s expecting LF (unix) or CR/LF (DOS/Windows).

In that case, it s actually grepping properly but your terminal is interpreting the CR newlines as "move the cursor to the start of the line" without advancing to an empty line while displaying.

If you re on a unix-like system (OSX should work too), try converting the eol-style:

grep  pattern  file | tr  
   
 

If that works, you can actually convert the file s eol-style with:

tr  
   
  < file.as > fixed-file.as
问题回答

暂无回答




相关问题
Really strange grep 2.5.1 bug in cat d reading long lines

Recently a peer and I discovered an interesting bug in GNU grep 2.5.1 in which standard input with lines greater than 200,000,000 characters causes grep to fail, even if the pattern is not in one of ...

grep a tab in UNIX

How do I grep tab ( ) in files on the Unix platform?

how to grep a variable in the shell program? [duplicate]

#!/bin/bash for ((var=0; var<20; var++)) do echo " Number is: $(grep Multiple_Frame = echo **$var** 20mrf.txt | wc -l)" >>statisic.txt done This shell program cannot produce correct ...

GREP - finding all occurrences of a string

I am tasked with white labeling an application so that it contains no references to our company, website, etc. The problem I am running into is that I have many different patterns to look for and ...

Grep doesn t work correctly with .as files

Here s the statement I m running: grep -i -H ConfigureControls *.as Note that I m forcing file names with the -H flag. What I get back is: } } trac} } this.chairControls.debug....

热门标签