Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Nice little script to add to the end of .bash_profile
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Gentoo Chat
View previous topic :: View next topic  
Author Message
cat5
n00b
n00b


Joined: 10 Apr 2002
Posts: 5
Location: Ottawa, On, Canada

PostPosted: Fri May 31, 2002 12:16 am    Post subject: Nice little script to add to the end of .bash_profile Reply with quote

This shows up everytime you loging if added at the end of .bash_profile in $HOME

uptime ; echo
df -h | perl -npe \
's#/dev/(scsi|ide)/host0/bus(\d)/target(\d)/lun0/part(\d)\n#$1 disk
$2/$3/$4#;s/^\s{13}//'
echo ; free -m ; echo
who ; echo

Also, I just put it in /usr/bin/ with a filename.
Pretty cool... works on all systems.
_________________
cat5@catfive.org
Back to top
View user's profile Send private message
ElCondor
Guru
Guru


Joined: 10 Apr 2002
Posts: 520
Location: Vienna, Austria, Europe

PostPosted: Fri May 31, 2002 11:59 am    Post subject: Reply with quote

what does (or should be doing) the perl script do to df -h? on my system it makes no difference.

* ElCondor pasa *
_________________
Here I am the victim of my own choices and I'm just starting!
Back to top
View user's profile Send private message
JefP@@
Apprentice
Apprentice


Joined: 09 May 2002
Posts: 179
Location: Belgium

PostPosted: Fri May 31, 2002 1:28 pm    Post subject: Reply with quote

elcondor wrote:
what does (or should be doing) the perl script do to df -h? on my system it makes no difference.

* ElCondor pasa *


Here too, no difference
Back to top
View user's profile Send private message
ealfert
Tux's lil' helper
Tux's lil' helper


Joined: 17 Jul 2002
Posts: 86
Location: Weston, FL, US

PostPosted: Tue Oct 29, 2002 2:04 am    Post subject: Reply with quote

#man df
Code:

Options
 -h, --human-readable
print sizes in human readable format (e.g., 1K 234M 2G)

ealfert-linux / # df
Code:

Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/hda5             15120616   3746536  10605988  27% /
tmpfs                     2048       192      1856  10% /mnt/.init.d
/dev/hda6              2016488    336192   1577860  18% /var
/dev/hda7              2016488    821812   1092240  43% /home
/dev/hda8             15857360     32828  15019016   1% /backup
tmpfs                   257292         0    257292   0% /dev/shm
/dev/hda2                36598      7955     26753  23% /boot

ealfert-linux / # df -h
Code:

Filesystem            Size  Used Avail Use% Mounted on
/dev/hda5              15G  3.6G   11G  27% /
tmpfs                 2.0M  192K  1.9M  10% /mnt/.init.d
/dev/hda6             2.0G  329M  1.6G  18% /var
/dev/hda7             2.0G  803M  1.1G  43% /home
/dev/hda8              16G   33M   15G   1% /backup
tmpfs                 252M     0  252M   0% /dev/shm
/dev/hda2              36M  7.8M   27M  23% /boot

_________________
Edward Alfert
RootMode, LLC
http://www.rootmode.com/
Back to top
View user's profile Send private message
lx
Veteran
Veteran


Joined: 28 May 2002
Posts: 1012
Location: Netherlands

PostPosted: Wed Nov 06, 2002 9:31 pm    Post subject: Reply with quote

ElCondor wrote:
what does (or should be doing) the perl script do to df -h? on my system it makes no difference.

* ElCondor pasa *


If filters the device string. it doesn't make a difference on your system because you probably use /dev/hda1 etc in fstab. if you use the new devfs names it makes a difference:

Code:
bash-2.05b# df -h | perl -npe 's#/dev/(scsi|ide)/host0/bus(\d)/target(\d)/lun0/part(\d)\n#$1 disk
$2/$3/$4#;s/^\s{13}//'

Filesystem            Size  Used Avail Use% Mounted on
ide disk
0/0/5         6.6G  2.3G  4.3G  35% /

Code:

bash-2.05b# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/ide/host0/bus0/target0/lun0/part5
                      6.6G  2.3G  4.3G  35% /
tmpfs                 2.0M  244K  1.8M  12% /mnt/.init.d


Cya lX
_________________
"Remember there's a big difference between kneeling down and bending over.", Frank Zappa
Back to top
View user's profile Send private message
securiteaze
Tux's lil' helper
Tux's lil' helper


Joined: 24 Oct 2002
Posts: 77
Location: Tulsa,Oklahoma

PostPosted: Fri Nov 08, 2002 3:24 am    Post subject: What about when you logout? Reply with quote

What about when you logout?

The only line in my .bash_logout:
Code:
exec clear

:)
_________________
Blah..
Back to top
View user's profile Send private message
Ka6aH
n00b
n00b


Joined: 30 Oct 2002
Posts: 4

PostPosted: Fri Nov 08, 2002 7:19 am    Post subject: Re: Nice little script to add to the end of .bash_profile Reply with quote

Quote:
perl -npe

What does it mean? From perlrun manpage:
Quote:
A -p overrides a -n switch.

So you must use -p or -n, not both. Otherwise -n option is ignored. Also sed is preferred here (smaller and faster):
Code:
df -h | sed -e '/lun0/N;s/\/dev\/\(scsi\|ide\)\/host0\/bus\(.\)\/target\(.\)\/lun0\/part\(.\)\n \{15\}/\1 disk> \2\/\3\/\4/'


This sed one-liner beautify df output and work ONLY on linux OS with mounted devfs partition when no device symlinks (like /dev/discs/disc0/part1 or /dev/hda1 for /dev/ide/host0/bus0/target0/lun0/part1) used and with no lvm/evms/nfs/samba volumes mounted; otherwise it show these volumes 'as is'
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Gentoo Chat All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum