Tiny Core Linux
Tiny Core Base => TCB Talk => Topic started by: Rich on July 06, 2026, 12:20:37 AM
-
In the past, I've used commands like this:
tce-status -i | grep ExtensionNameto see if an extension was installed.
I decided to add a Find (-f) option.
It allows searching for specific names as well as wildcards:
tc@E310:~/tce-status$ ./tce-status -f openssl
openssl
tc@E310:~/tce-status$ ./tce-status -f openssl*
openssl
openssl-1.1.1
Or all extensions with 86 in their name:
tc@E310:~/tce-status$ ./tce-status -f *86*
libXxf86dga
libXxf86vm
xf86-input-evdev
xf86-video-intel
xf86-video-vesa
It can also handle multiple extensions:
tc@E310:~/tce-status$ ./tce-status -f Xprogs Xlib* grabber util*
Xprogs
Xlibs
grabber
util-linux
util-linux_base-dev
I also made the help message a little more user friendly.
Old message:
tc@E310:~/tce-status$ /usr/bin/tce-status
Usage tce-status -i | -u | -o
New Message:
tc@E310:~/tce-status$ ./tce-status
Display installed (-i), uninstalled (-u), orphaned (-o), or find installed (-f name [ name ... ])
Also remove this unused variable definition:
TCELIST="/tmp/tcelist"
The size increased from 1115 to 1334 bytes.
A copy is attached to this post in case anyone wants to try it out
or review my changes. Comments would be appreciated.
-
>In the past, I've used commands like
on a bit of a tangent
this sentiment reminded me of
mount | grep -v loop ;
often
mnt() { mount | grep -v loop ; }
wrt: tce-status
i like the idea!
... if you shift on each original OPTION
..and.. test for *extra args*
concatenate the extra strings in to an or regexp
something like
while $# -gt 0
extra_arg_exp="$extra_arg_exp""|""$1"; shift
eg
echo -e "ab\nd\nz" | busybox grep -E "z|ab"
ab
z
then *you could* ( i think ** )
| grep -E "$extra_arg_exp"
eg
f2(){
[ $# -gt 0 ] && {
export _exp="$( mk_exp "$@" )";
grep -E "$_exp"
} || \
cat ;
}
mk_exp(){
while [ $# -gt 0 ] ; do [ -z "$1" ] || { [ -z "$s" ] && s="$1" || s="$s|$1" ; } ; shift; done ; echo "$s" ;
}
while getopts iuof OPTION
do
case ${OPTION} in
i) shift ;installed ;;
u) shift uninstalled ;;
o) shift orphaned ;;
f) Find "$@";;
esac
done | { shift $OPTIND; f2 "$@" ;}
sh ./tce-status-mod -i ^z ^s
sed
shared-mime-info
sqlite3
zlib_base-dev
zstd
zstd-dev
so just filter *whatever* original output
like the first example
but also for each extra arg
was my initial impression
tbh
the shift's in the case are i think not needed
https://superuser.com/questions/541644/bash-how-to-use-while-shift-do-case-1-in
and i found about $OPTIND !
and i dont recall seeing
>Params=${@/-f/}
trick before !
-
Hi mocore
Sorry for the delay and this long winded reply.
I originally did something similar to mk_exp() to load the search
terms into a variable. Only I wanted to use built in commands so I
was using a case statement. Problem was the case statement won't
interpret the or symbol when it's embedded in a variable.
That lead me to a simpler solution, parse /usr/local/tce.installed
directly. The ls command is not needed for this, so it can still
be done using only built in commands.
Like yours, I can also search for extensions beginning with z and s:
tc@E310:~/tce-status$ ./tce-status -f z* s*
zip-unzip
zlib_base-dev
zstd
zsync
schumacher-clean-fonts
sed
shared-mime-info
slang
socat
sox
speex
sqlite3
sqlite3-bin
squashfs-tools
strace
submitqc
syslinuxbut I don't need anchors to do it.
or starting with o and ending with l:
tc@E310:~/tce-status$ ./tce-status -f o*l
openssl
That doesn't work with your version:
tc@E310:~/tce-status$ ./tce-status2 -i o*l | wc -l
202
That's because grep needs the asterisk escaped with a period:
tc@E310:~/tce-status$ ./tce-status2 -i o.*l
Xorg-7.7-lib
alsa-modules-4.19.10-tinycore
cdrtools
compiletc
coreutils
dosfstools
getlocale
glibc_i18n_locale
hicolor-icon-theme
inotify-tools
libopenal
mtools
net-tools
openldap
openssl
openssl-1.1.1
poppler07
poppler07-bin
postgresql-12-client
rollcall
squashfs-tools
twolame
xdotool
xf86-video-intel
Still not what I was looking for, you need anchors at both ends of the search term:
tc@E310:~/tce-status$ ./tce-status2 -i ^o.*l$
openssl
Even adding -w (Match whole words only) to your grep command didn't quite fix it:
tc@E310:~/tce-status$ ./tce-status2 -i o.*l
openssl
openssl-1.1.1That second entry ends with a 1, not an l.
Piping the while getopts loop through your f2 function and testing for extra parameters
was clever, but I see other issues.
The 3 options output different data formats.
-i ExtensionName
-u ExtensionName.tcz
-o ExtensionName.tcz and/or ExtensionName.tcz.md5.txt and/or ExtensionName.tcz.dep
It checks every *.tcz* file it finds.
I chose -i because:
1. I use it fairly often.
2. It shows up in the forum sometimes.
3. It was simple to implement, all of the info is in /usr/local/tce.installed.
I avoided -u because:
1. I don't think I've ever used it.
2. I didn't have a plan for dealing with the 2 different data formats.
3. I was not aware of your clever piping trick.
I avoided -o because:
1. It can take a very long time to run (about 8 minutes on one of my machines).
2. If you use the wrong search filter, it can take a very long time to run again.
In light of your piping trick, I may take another look at -u.
I also feel the globbing patterns are easier for the average person to understand
than the regex patterns.
... and i dont recall seeing
>Params=${@/-f/}
trick before !
It can be quite useful:
Find/replace pattern in variable
${var/Pattern/Replacement} First match of Pattern, within var replaced with Replacement.
${var//Pattern/Replacement} All matches of Pattern, within var replaced with Replacement.
${var/#Pattern/Replacement} Prefix of var matches Pattern, Pattern replaces Replacement.
${var/%Pattern/Replacement} Suffix of var matches Pattern, Pattern replaces Replacement.
# If Replacement is omitted, then Pattern is replaced by nothing, that is, deleted.
-
Hi mocore
I've modified tce-status to allow searching for installed extensions:
tc@E310:~/tce-status$ ./tce-status3 -i *7.7*
Xorg-7.7
Xorg-7.7-3d
Xorg-7.7-bin
Xorg-7.7-lib
and uninstalled extensions:
tc@E310:~/tce-status$ ./tce-status3 -u *7.7*
Xorg-7.7-3d-dev
Xorg-7.7-dev
In both cases I output extension names without the .tcz extension.
If you run tce-status3 -u without a search term, it outputs the
extension names with the .tcz extension, just like it used to. That's
because apps uses tce-status and I didn't want to change its format.
I attached a copy to this post. Its size is 1307 bytes.