4 ms·
Well, if you "want" that, you could also have a look at busybox -- which does cp,ls,mv and more -- in a single binary (optionally statically linked). I actuall
by e12e 13y ago
Well, if you "want" that, you could also have a look at busybox -- which does cp,ls,mv and more -- in a single binary (optionally statically linked).
I actually tend to do a switch on the first argument for certain shell scripts, such as this little thing for switching between single display on a couple of laptops/netbooks:
#!/usr/bin/env sh
INTERNAL=LVDS
EXTERNAL=VGA-0
for monitor in `xrandr|grep connected|awk '{ print $1 }'`
do
case "${monitor}" in
"LVDS")
INTERNAL="LVDS"
;;
"DFP1")
EXTERNAL="DFP1"
;;
"CRT1")
EXTERNAL="CRT1"
;;
"VGA-0")
EXTERNAL="VGA-0"
;;
esac
done
twoscreen()
{
xrandr --output ${EXTERNAL} --auto --rotate normal --pos 0x0 \
--output ${INTERNAL} --auto --rotate normal --pos 768x1152
}
vgaonly()
{
xrandr --output ${EXTERNAL} --auto --rotate normal --pos 0x0 \
--output ${INTERNAL} --off
}
laptoponly()
{
xrandr --output ${INTERNAL} --auto --rotate normal --pos 0x0 --output ${EXTERNAL} --off
}
fn=`basename "$0"`
case $fn in
"twoscreens")
twoscreen
;;
"onescreen")
laptoponly
;;
"vgaonly")
vgaonly
;;
*)
echo "Usage: vgaonly|onescreen|twoscreen"
echo "called as: $0 ($fn)"
;;
esac
As a side note, for those running Debian (or Ubunut, I think) there's a couple of utilities to help search for binaries/files -- namely apt-file and dlocate. Eg:
apt-file search -F bin/cp #returns coreutils
# -F does a fixed string search, otherwise you'll
# get a list of all packages which contains files
# that *contain* bin/cp in their name such as:
# passwd: /usr/sbin/cpgr
Dlocate works with regular expressions and an index, so it's much faster and you can do:
$ dlocate bin/cp\$
coreutils: /bin/cp
- vram22 13y ago>if you "want" that, you could also have a look at busybox Don't want or need it, just mentioned it as an interesting bit of Unix history. I guess the 3 files are not links but separate files nowadays due to much cheaper and more plentiful disk space compared to those days. Your script is interesting. Didn't know about apt-file or dlocate, good to know, thanks. >Ubunut Sort of Freudian slip? Just kidding :)