Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 19 May 2002 14:25:59 +0300
From:      Giorgos Keramidas <keramida@FreeBSD.org>
To:        Alfred Perlstein <bright@mu.org>
Cc:        Bakul Shah <bakul@bitblocks.com>, Dima Dorfman <dima@trit.org>, Paul Herman <pherman@frenchfries.net>, current@FreeBSD.org
Subject:   Re: mergemaster(8) broken -- uses Perl
Message-ID:  <20020519112559.GA33290@hades.hell.gr>
In-Reply-To: <20020519091354.GR20683@elvis.mu.org>
References:  <200205190707.DAA27939@marlborough.cnchost.com> <200205190730.DAA10754@marlborough.cnchost.com> <20020519091354.GR20683@elvis.mu.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On 2002-05-19 02:13, Alfred Perlstein wrote:
> * Bakul Shah <bakul@bitblocks.com> [020519 00:30] wrote:
> > > $ stat -a stat
> >
> > Oops!  A few lines got eaten!
> >
> > $ stat -a stat
> > May 19 00:24:42 2002|48|May 19 00:24:42 2002|291846|-|bakul|0|262301|1|May 19 00:24:42 2002|rwxr-xr-x|1095744|23996|-|bakul|stat
> > $ stat -a -n stat
> > 1021793082|48|1021793082|291846|0|1001|0|262301|1|1021793082|755|1095744|23996|100000|1001|stat
>
> Bow to me.
>
> echo 'ibase=2\nobase=8\n' \
>     `ls -ld ${FILE} | cut -f 1 -d " " | \
>      sed -e 's/[rwx]/1/g' -e 's/[^rwx1]/0/g'` | \
>      bc

Great idea to use bc(1) ;-) It doesn't really parse sticky, suid or
sgid bits, but it's smaller than the awk version.  The following did
the trick nicely (but is too ``complicated'', and I'd still like
having a tool that allows userland to call stat/fstat(2):

	hades+charon:/tmp$ cat foo.sh
	#!/bin/sh

	echo 'ibase=2;obase=8;' \
	` ls -ld "$1" | \
	cut -c2-10 | \
	sed -e '/^..[sS]/ s/^.*$/&+100000000000/' \
	    -e '/^.....[sS]/ s/^.*$/&+10000000000/' \
	    -e '/^........[tT]/ s/^.*$/&+1000000000/' | \
	sed -e 's/[st]/x/g' -e 's/ST/-/g' | \
	sed -e 's/[rwx]/1/g' | \
	sed -e 's/[^1+]/0/g' ` | bc

	% sh foo.sh /tmp
	hades+charon:/tmp$ sh foo.sh /tmp
	1777

-- 
Giorgos Keramidas    - http://www.FreeBSD.org
keramida@FreeBSD.org - The Power to Serve

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020519112559.GA33290>