[nycbug-talk] what are your usefull hacks, the real simple ones
Okan Demirmen
okan at demirmen.com
Mon May 8 10:42:37 EDT 2006
On Mon 2006.05.08 at 10:31 -0400, Steven Kreuzer wrote:
> Marc Spitzer wrote:
> > any other short and quick hacks out there?
> >
>
> I work in a shell that does everything I want with a few exceptions,
> such as pushd and popd not being a shell built-in. However, they are
> really easy to implement as a shell function:
>
> function pushd {
> dirname=$1
> cd ${dirname:?"Missing directory name."}
> DIRSTACK="$PWD ${DIRSTACK:-$OLDPWD}"
> print "$DIRSTACK"
> }
>
> function popd {
> DIRSTACK=${DIRSTACK#* }
> cd ${DIRSTACK%% *}
> print "$PWD"
> }
>
>
> Also, there is a command called seq which is part of the gnu core-utils
> which is pretty much just a program that takes a starting number and
> and ending number and outputs all the numbers in between:
try jot(1)
> $ seq 1 5
> 1 2 3 4 5
>
> which can be very very handy when doing loops in the shell. I don't have
> the core-utils installed, so I don't have seq, but its pretty easy to
> implement it as a shell function:
>
> function seq {
> local I=$1
> while [ $2 != $I ]; do
> print -n "$I "
> I=$(( $I + 1 ))
> done;
> print "$2"
> }
>
> -----
> SK
> _______________________________________________
> % NYC*BUG talk mailing list
> http://lists.nycbug.org/mailman/listinfo/talk
> %Be sure to check out our Jobs and NYCBUG-announce lists
> %We meet the first Wednesday of the month
More information about the talk
mailing list