Tiny Core Base > TCB Tips & Tricks

How to find which extension provides a file

<< < (12/14) > >>

GNUser:
Hi Rich. Thanks for sharing this improved version. I have put it on all my TCL boxes :)

It would be helpful if the Usage() function also outputted provides.sh's version number and/or release date.

Rich:
Hi GNUser
I've been meaning to add that. Now that it's pretty much
stabilized, I'll do that.

Rich:
Hi GNUser
After further testing I added the period to the list of
punctuation I'm escaping.

Version information has also been added:

--- Code: ---tc@E310:~/Scripting/Provides$ ./provides.sh

Version 0.3 Nov 25, 2024

Find extension(s) that provide a filename.
Filenames in list being searched include full paths, for example:
        usr/local/bin/grep

Usage:
   provides.sh [ -nz ] FileName

   -nz    Skip updating (zsync) the provides.db file. This speeds up
          the search, but might miss items if provides.db is outdated.

Examples:
   provides.sh cal           Finds cal anywhere in FileName
   provides.sh bin/cal       Finds bin/cal anywhere in FileName
   provides.sh bin/cal$      Finds FileName that ends in bin/cal
   provides.sh Black Gnome   Finds FileName with embedded spaces

Searches are case sensitive.
The $ sign can only be used at the end of your search term.

tc@E310:~/Scripting/Provides$
--- End code ---

The updated version is attached. The previous version will be removed.

GNUser:
Hi Rich. It looks great! Thanks again for adding all this polish to this script.

patrikg:

--- Quote from: patrikg on November 15, 2024, 11:00:08 AM ---Sorry for not getting the performance working with sqlite3 :( ---
Tried to get it working so the command line should report the performance.

I can't getting it working with the ".timer on" with the command line version of sqlite3.
The ".timer on" doesn't report the speed sadly when executing from the command line.

But if you get into the interactive mode of sqlite3 it just works so you get a report how many seconds the question took.

It says in "man" you could supply the -cmd ".timer on" but it doesn't work for me, but some another commands like -cmd ".help" works out of the box.

And if "you" choose sqlite3 you could also store some more metadata like version, date and so on.

Maybe also store ldd output of the executable, so you can easily see the dependency's.

--- End quote ---

Now when i looked at it again, i see that sqlite need the select command to stdin, so
if i make the command like this i get the performance with sqlite3.
I think i can be useful for another to see it can be done.

So the search.sh file should be like this:


--- Code: ---echo "SELECT * FROM tcz_files WHERE file LIKE '%$1%';" | sqlite3 -cmd ".timer on" -box files.db
--- End code ---

make.sh

--- Code: ---cat << 'EOF' > make.sh
#!/bin/bash
sqlite3 files.db "CREATE TABLE tcz_files (name TEXT NOT NULL,file TEXT NOT NULL);"
for filename in $(ls *.tcz)
do
   tczfile=$filename;for file in $(unsquashfs -lc $tczfile); do sqlite3 files.db "INSERT INTO tcz_files ( NAME , FILE ) VALUES ( '$tczfile' , '$(basename $file)' );" ; done
done
EOF

chmod u+x make.sh
--- End code ---

search.sh

--- Code: ---cat << 'EOF' > search.sh
#!/bin/bash
echo "SELECT * FROM tcz_files WHERE file LIKE '%$1%';" | sqlite3 -cmd ".timer on" -box files.db
EOF

chmod u+x search.sh
--- End code ---

PS, so I take back what I said before it's sqlite bug, I have to read RTFM, to get it :)

Happy coding !!! :)

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version