Sep 06
I love writing shell commands and functions. Everyone does something with ‘ll’ mine is:
alias ll=’ls -lart’ # because I want to see the newest file last.
Lots of times I also want the full path of a file. I could just type
it, but I make a lot of errors when I type long things. A long time
ago I decided cut-and-paste are a dyslexsics best friend. Here are a
couple of helper tools:
’lll’ gets me a full path
’llll’ gets me a path suitable for use in scp.
I do this a lot:
tony-ws:log> llll setup.log
tony-ws:/var/log/setup.log
On another box:
betlong:log> scp tony-ws:/var/log/setup.log .
#quick demo
for i in lll llll
do echo “this is what $i does: “
$i hacked-footertracking.html foo.*
echo
done
this is what lll does:
/home/tony/tmp/hacked-footertracking.html
/home/tony/tmp/foo.idx
/home/tony/tmp/foo.pl
/home/tony/tmp/foo.pl~
/home/tony/tmp/foo.sh
/home/tony/tmp/foo.sh~
this is what llll does:
tony-ws:/home/tony/tmp/hacked-footertracking.html
tony-ws:/home/tony/tmp/foo.idx
tony-ws:/home/tony/tmp/foo.pl
tony-ws:/home/tony/tmp/foo.pl~
tony-ws:/home/tony/tmp/foo.sh
tony-ws:/home/tony/tmp/foo.sh~
############
# often want full path to file(s), this gets it for me
# Tony Hansmann (t o n y replacewith-at-sign open source consulting com)
lll ()
{
if [ ! -z "$*" ]
then
for i in $*;
do
if (echo $i |egrep -q “^/|\.\./”)
then
ls $i
else
\ls `pwd`/$i;
fi
done
else
pwd;
fi
}
##########
# often need to have a file or dir name in scp format
# box:/full/path/to/file, this gets it for me
# Tony Hansmann (t o n y replacewith-at-sign open source consulting com)
llll () {
if [ ! -z "$*" ]
then
if [ ! -z "$*" ]
then
for i in $*
do
if (echo $i |egrep -q “^/|\.\./”)
then
echo $(hostname):$(\ls $i);
else
echo $(hostname):$(\ls `pwd`/$i);
fi
done
fi
else
echo $(hostname):`pwd`;
fi
}