Grep Not Working (on some files)?
I have a MSSQL database dump I'm trying to grep through. However, grep does not seem to work on it, at all. Here is a snippet of the file.
...
ALTER DATABASE [Documents] SET RECURSIVE_TRIGGERS OFF
GO
ALTER DATABASE [Documents] SET DISABLE_BROKER
GO
ALTER DATABASE [Documents] SET AUTO_UPDATE_STATISTICS_ASYNC OFF
...
However when I do a grep on it I get nada.
$ cat Documents.sql | grep -i 'alter'
$ <nothing>
$ cat Documents.sql | grep -i 'go'
$ <nothing>
For giggles I created another document 'tempfile' with:
$ cat tempfile
alter
Alter
ALTER
$
And ran the same grep on it:
$ cat tempfile | grep -i 'alter'
alter
Alter
ALTER
Thoughts on why grep wouldn't work on certain files? Concerns me that when I have to grep through a bunch of stuff to find a small nugget, it 'may' be missing something. Thoughts?
Ahh. Thank you.
$ file -bi Documents.txt
text/plain; charset=utf-16le
$ vi Documents.txt
set encoding=utf-8
set fileencoding=utf-8
$ file -bi Documents.txt
text/plain; charset=utf-8
$ cat Documents.txt | grep -i 'alter'
ALTER DATABASE [Documents] SET COMPATIBILITY_LEVEL = 120
ALTER DATABASE [Documents] SET ANSI_NULL_DEFAULT OFF
ALTER DATABASE [Documents] SET ANSI_NULLS OFF
ALTER DATABASE [Documents] SET ANSI_PADDING OFF