* Need a UNIX expert to create a new UNIX command
@ 2000-06-06 4:00 Jocelyn Burget
2000-06-07 4:00 ` Joerg Bruehe
2000-06-07 4:00 ` Andrew Moar
0 siblings, 2 replies; 3+ messages in thread
From: Jocelyn Burget @ 2000-06-06 4:00 UTC (permalink / raw)
I do not know if it is the right place to post this article
but it's the only one I found.
I like to create my "own" UNIX command similar to the command: du
I do not want to create an alias.
I'd like to create a command, let's call it "diskfull", that does
exactly the same thing as du but the output will be in my own format.
Example:
[nautilus:jxb] 11% diskfull -M filename
Result: The reported occupied space is in Mbytes
OR
[nautilus:jxb] 11% diskfull -G filename
Result: The reported occupied space is in Gbytes
The way I see it the only operation to do is
(Output from du -k)*512/1E6
OR
(Output from du -k)*1024/1E9
Does anyone have an idea on how to do that?
Thanks
Regards
JB
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Need a UNIX expert to create a new UNIX command
2000-06-06 4:00 Need a UNIX expert to create a new UNIX command Jocelyn Burget
@ 2000-06-07 4:00 ` Joerg Bruehe
2000-06-07 4:00 ` Andrew Moar
1 sibling, 0 replies; 3+ messages in thread
From: Joerg Bruehe @ 2000-06-07 4:00 UTC (permalink / raw)
Hi Jocelyn !
Jocelyn Burget wrote:
>
> I do not know if it is the right place to post this article
> but it's the only one I found.
Not quite, IMHO - your desire is not specific to Tru64.
However, I do not know an international group on Unix programming,
only the German one, so let us stay here (if nobody complains).
>
> [...]
>
> I'd like to create a command, let's call it "diskfull", that does
> exactly the same thing as du but the output will be in my own format.
>
> Example:
>
> [nautilus:jxb] 11% diskfull -M filename
> Result: The reported occupied space is in Mbytes
>
> OR
>
> [nautilus:jxb] 11% diskfull -G filename
> Result: The reported occupied space is in Gbytes
>
> The way I see it the only operation to do is
>
> (Output from du -k)*512/1E6
> OR
> (Output from du -k)*1024/1E9
>
> Does anyone have an idea on how to do that?
Your approach of using standard 'du' and post-process the output would
work, but I propose something different:
Get the source for the GNU version of 'du' (from
http://www.gnu.ai.mit.edu or
http://www.gnu.org/order/ftp.html )
and modify the output routine so that some argument like your '-M' or
'-G' will let the program do the conversion.
I do not know the size unit in which GNU's 'du' operates, but it might
use the traditional 512 byte blocks by default and switch to 1 kB by
an option '-k' (that is how AIX 'du' does/did it). In that case, you
would already find the proper place for your modification: look how
they handle '-k' and add your option(s).
If you feel there might be other users interested as well, you might
feed back your modification to the GNU maintainers.
Regards, Joerg Bruehe
--
Joerg Bruehe, SQL Datenbanksysteme GmbH, Berlin, Germany
(speaking only for himself)
mailto: joerg@sql.de
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Need a UNIX expert to create a new UNIX command
2000-06-06 4:00 Need a UNIX expert to create a new UNIX command Jocelyn Burget
2000-06-07 4:00 ` Joerg Bruehe
@ 2000-06-07 4:00 ` Andrew Moar
1 sibling, 0 replies; 3+ messages in thread
From: Andrew Moar @ 2000-06-07 4:00 UTC (permalink / raw)
In article <8his5s$ing$1@miranda.gmrc.gecm.com>,
jxb@unconfigured.xvnews.domain (Jocelyn Burget) writes:
> I'd like to create a command, let's call it "diskfull", that does
> exactly the same thing as du but the output will be in my own format.
>
> Example:
>
> [nautilus:jxb] 11% diskfull -M filename
> Result: The reported occupied space is in Mbytes
>
> OR
>
> [nautilus:jxb] 11% diskfull -G filename
> Result: The reported occupied space is in Gbytes
How about something like:
#!/bin/sh
if [ "$1" = "-M" ]
then
du -k $2 | awk '{print ($1 / 1024) " " $2}'
else
du -k $2 | awk '{print ($1 / 1048576) " " $2}'
fi
or something along those lines...
Cheers,
Andrew
--
Andrew Moar : Ph +61 3 9479 1505 email A.Moar@latrobe.edu.au
Unix Environment Specialist, Information Technology Services
La Trobe University, Bundoora
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2000-06-07 4:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2000-06-06 4:00 Need a UNIX expert to create a new UNIX command Jocelyn Burget
2000-06-07 4:00 ` Joerg Bruehe
2000-06-07 4:00 ` Andrew Moar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox