Re: [sqlite] The best way to check if a file is a sqlite3 DB file?

2019-09-19 Thread Dominique Devienne
On Thu, Sep 19, 2019 at 10:20 AM Rowan Worth wrote: > On Thu, 19 Sep 2019 at 16:03, Dominique Devienne > > On Wed, Sep 18, 2019 at 6:43 PM Clemens Ladisch > > > Peng Yu wrote: > > > > Is there a better way to just return an exit status of 0 for > > > > a sqlite3 DB file and 1 otherwise? > > > >

Re: [sqlite] The best way to check if a file is a sqlite3 DB file?

2019-09-19 Thread Rowan Worth
On Thu, 19 Sep 2019 at 16:03, Dominique Devienne wrote: > On Wed, Sep 18, 2019 at 6:43 PM Clemens Ladisch > wrote: > > > Peng Yu wrote: > > > Is there a better way to just return an exit status of 0 for > > > a sqlite3 DB file and 1 otherwise? > > > > Extract the magic header string from a known

Re: [sqlite] The best way to check if a file is a sqlite3 DB file?

2019-09-19 Thread Dominique Devienne
On Wed, Sep 18, 2019 at 6:43 PM Clemens Ladisch wrote: > Peng Yu wrote: > > Is there a better way to just return an exit status of 0 for > > a sqlite3 DB file and 1 otherwise? > > Extract the magic header string from a known DB file: > > dd bs=16 count=1 < some.db > sqlite3-signature > > Then y

Re: [sqlite] The best way to check if a file is a sqlite3 DB file?

2019-09-18 Thread Clemens Ladisch
Peng Yu wrote: > Is there a better way to just return an exit status of 0 for > a sqlite3 DB file and 1 otherwise? Extract the magic header string from a known DB file: dd bs=16 count=1 < some.db > sqlite3-signature Then you can compare it against the beginning of the file: cmp --bytes=16 s

[sqlite] The best way to check if a file is a sqlite3 DB file?

2019-09-18 Thread Peng Yu
Hi, I use `file` to check if a file is a sqlite3 DB file. But I have to parse the result. Is there a better way to just return an exit status of 0 for a sqlite3 DB file and 1 otherwise? Thanks. $ file /tmp/tmp.erZ5aS6PUX.sqa /tmp/tmp.erZ5aS6PUX.sqa: SQLite 3.x database, last written using SQLite