save.dat space usage help needed [Solved]

Post here if you are a new Porteus member and you're looking for some help.
User avatar
Ed_P
Contributor
Contributor
Posts: 8341
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

save.dat space usage help needed [Solved]

Post#1 by Ed_P » 04 Aug 2014, 04:25

When I use the command:

Code: Select all

du -h /mnt/live/memory/images/changes/home/guest*|grep  'M'
to find the larger users of my save.dat space in addtion to the

Code: Select all

11M	/mnt/live/memory/images/changes/home/guest/Backups/FireFox
11M	/mnt/live/memory/images/changes/home/guest/Backups
1.4M	/mnt/live/memory/images/changes/home/guest/.mozilla/firefox/c3pp43bg.default/extensions
16M	/mnt/live/memory/images/changes/home/guest/.mozilla/firefox/c3pp43bg.default
16M	/mnt/live/memory/images/changes/home/guest/.mozilla/firefox
16M	/mnt/live/memory/images/changes/home/guest/.mozilla
files I am also getting

Code: Select all

0	/mnt/live/memory/images/changes/home/guest/.cache/keyring-tKSMbQ
0	/mnt/live/memory/images/changes/home/guest/.cache/keyring-H9jOtM
0	/mnt/live/memory/images/changes/home/guest/.cache/keyring-SinMoc
0	/mnt/live/memory/images/changes/home/guest/.cache/keyring-MIzaGW
0	/mnt/live/memory/images/changes/home/guest/.cache/keyring-YUdMg8

files because they have an 'M' in the file name or path. How do I get just the 'M /mnt' ones?
Last edited by Ed_P on 04 Aug 2014, 17:18, edited 1 time in total.
Ed

User avatar
Ed_P
Contributor
Contributor
Posts: 8341
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

Re: save.dat space usage help needed

Post#2 by Ed_P » 04 Aug 2014, 05:08

I think I found a way.

Code: Select all

 du -h /mnt/live/memory/images/changes/home/guest*|grep  '[0-9]M'
And this works well for finding just the larger files/folders.

Code: Select all

 du -h /mnt/live/memory/images/changes/home/guest*|grep  '[0-9][0-9]M'
Ed

go2null
White ninja
White ninja
Posts: 25
Joined: 19 Aug 2014, 18:28
Distribution: LXDE-v3.0.1-i486.iso
Location: Canada

Re: save.dat space usage help needed [Solved]

Post#3 by go2null » 19 Aug 2014, 19:48

Code: Select all

du -haxt 10M /mnt/live/memory/images/changes/home/guest
I have a function in $HOME/.bashrc which also strips the containing parent directories.

Code: Select all

du_dummy() {
# Removes containing directories
# usage: [THRESHOLD DIR]|[DIR]
	[ "$2" ] && { opts="t $1"; dir="$2"; } || { unset opts; dir="$1"; }
	[ -z "$dir" ] && { dir="$PWD"; }
	du -hax$opts "$dir" 2>/dev/null | awk '
	BEGIN { printf "%6s %s\n", "Size","File or Directory/" }
	{
		dir=$2
		if ( prev_dir !~ dir ) {
			if (system("test -d \""dir"\"") == 0) { dir=dir"/" }
			printf "%6s %s\n", $1, dir
		}
		prev_dir=$2
	}'
}
alias du-='du_dummy'
(I know that I do not need to define an alias pointing to the function, but this gives me any easy way to see what's in my environment by just typing alias.)

User avatar
Ed_P
Contributor
Contributor
Posts: 8341
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

Re: save.dat space usage help needed [Solved]

Post#4 by Ed_P » 20 Aug 2014, 02:53

go2null wrote:

Code: Select all

du -haxt 10M /mnt/live/memory/images/changes/home/guest
An interesting command go2null. Thank you.
I have a function in $HOME/.bashrc
Interesting. I don't see this directory on my system.
Ed

go2null
White ninja
White ninja
Posts: 25
Joined: 19 Aug 2014, 18:28
Distribution: LXDE-v3.0.1-i486.iso
Location: Canada

Re: save.dat space usage help needed [Solved]

Post#5 by go2null » 20 Aug 2014, 07:54

$HOME is a more generic way of referring to your home directory. ~ is also used in some shells like bash and dash.

In the case of the Porteous guest user, it is
/home/guest

There you will find your. bashrc file.
/home/guest/.bashrc

You can copy and paste that into Geany's open file dialog.

Or you can enable showing hidden files in PCManFM or Geany Open File dialod.
(files that begin with a dot are hidden by default. )

User avatar
Ed_P
Contributor
Contributor
Posts: 8341
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

Re: save.dat space usage help needed [Solved]

Post#6 by Ed_P » 20 Aug 2014, 15:17

go2null wrote:In the case of the Porteous guest user, it is
/home/guest

There you will find your. bashrc file.
/home/guest/.bashrc
Oh. Ok. I thought .bachrc was referring to a directory not a file. This is what I see.

Code: Select all

# Setup color scheme for list call <brokenman>
alias ll='/bin/ls --color=auto -lF'
alias la='/bin/ls --color=auto -axF'
alias ls='/bin/ls --color=auto -xF'

# Append any additional sh scripts found in /etc/profile.d/:
for y in /etc/profile.d/*.sh ; do [ -x $y ] && . $y; done
unset y

# Setup shell prompt for guest <wread and fanthom>
PS1='\[\033[01;36m\]\u@\h:\[\033[01;32m\]\w\$\[\033[00m\] '
PS2='> '
Ed

go2null
White ninja
White ninja
Posts: 25
Joined: 19 Aug 2014, 18:28
Distribution: LXDE-v3.0.1-i486.iso
Location: Canada

Re: save.dat space usage help needed [Solved]

Post#7 by go2null » 20 Aug 2014, 18:27

If you wish to add the function above, or any other function or alias, then you can directly add them to the $HOME/.bashrc file.
However, to make it easier to maintain your customizations, it's normal practice to use a separate $HOME/.bashrc_aliases or $HOME/.bashrc_personal file.

Here's a simple walk through for Porteous. (I'm using Porteous LXDE.)
(You can just copy and paste the entire code below into a terminal shell.)

Code: Select all

# add a hook so that your personal customizations will be 
#   automatically loaded whenever you launch a terminal.
echo '[ -e "$HOME/.bashrc_personal" ] && . "$HOME/.bashrc_personal"' >> $HOME/.bashrc

# create the personal file
cat > $HOME/1.bashrc_personal <<EOF
#!/bin/sh
# ^ not required, but allows for automatic syntax highlighting

du_dummy() {
# Removes containing directories
# usage: [THRESHOLD DIR]|[DIR]
	[ "$2" ] && { opts="t $1"; dir="$2"; } || { unset opts; dir="$1"; }
	[ -z "$dir" ] && { dir="$PWD"; }
	du -hax$opts "$dir" 2>/dev/null | awk '
	BEGIN { printf "%6s %s\n", "Size","File or Directory/" }
	{
		dir=$2
		if ( prev_dir !~ dir ) {
			if (system("test -d \""dir"\"") == 0) { dir=dir"/" }
			printf "%6s %s\n", $1, dir
		}
		prev_dir=$2
	}'
}
alias du-='du_dummy'
EOF

# source your personal file
. "$HOME/.bashrc_personal"

# see all your current aliases
alias

# now test your new function
du- 10M /

# And finally, open the file in a GUI editor
# for your enjoyment :-)
xdg-open "$HOME/.bashrc_personal"


User avatar
Ed_P
Contributor
Contributor
Posts: 8341
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

Re: save.dat space usage help needed [Solved]

Post#8 by Ed_P » 20 Aug 2014, 22:11

go2null wrote:(You can just copy and paste the entire code below into a terminal shell.)
Really!! Single lines I have done but never realized that multiple lines could be done.

The terminal window.

Code: Select all

guest@porteus:~$ # add a hook so that your personal customizations will be
guest@porteus:~$ #   automatically loaded whenever you launch a terminal.
guest@porteus:~$ echo '[ -e "$HOME/.bashrc_personal" ] && . "$HOME/.bashrc_personal"' >> $HOME/.bashrc
guest@porteus:~$ 
guest@porteus:~$ # create the personal file
guest@porteus:~$ cat > $HOME/1.bashrc_personal <<EOF
> #!/bin/sh
> # ^ not required, but allows for automatic syntax highlighting
> 
> du_dummy() {
> # Removes containing directories
> # usage: [THRESHOLD DIR]|[DIR]
>    [ "$2" ] && { opts="t $1"; dir="$2"; } || { unset opts; dir="$1"; }
>    [ -z "$dir" ] && { dir="$PWD"; }
>    du -hax$opts "$dir" 2>/dev/null | awk '
>    BEGIN { printf "%6s %s\n", "Size","File or Directory/" }
>    {
>       dir=$2
>       if ( prev_dir !~ dir ) {
>          if (system("test -d \""dir"\"") == 0) { dir=dir"/" }
>          printf "%6s %s\n", $1, dir
>       }
>       prev_dir=$2
>    }'
> }
> alias du-='du_dummy'
> EOF
guest@porteus:~$ 
guest@porteus:~$ # source your personal file
guest@porteus:~$ . "$HOME/.bashrc_personal"
bash: /home/guest/.bashrc_personal: No such file or directory
guest@porteus:~$ 
guest@porteus:~$ # see all your current aliases
guest@porteus:~$ alias
alias d='dir'
alias dir='/bin/ls $LS_OPTIONS --format=vertical'
alias la='/bin/ls --color=auto -axF'
alias ll='/bin/ls --color=auto -lF'
alias ls='/bin/ls $LS_OPTIONS'
alias mc='. /usr/share/mc/bin/mc-wrapper.sh'
alias v='vdir'
alias vdir='/bin/ls $LS_OPTIONS --format=long'
guest@porteus:~$ 
guest@porteus:~$ # now test your new function
guest@porteus:~$ du- 10M /
bash: du-: command not found
guest@porteus:~$ 
guest@porteus:~$ # And finally, open the file in a GUI editor
guest@porteus:~$ # for your enjoyment :-)
guest@porteus:~$ xdg-open "$HOME/.bashrc_personal"
xdg-open: file '/home/guest/.bashrc_personal' does not exist
guest@porteus:~$ alias
alias d='dir'
alias dir='/bin/ls $LS_OPTIONS --format=vertical'
alias la='/bin/ls --color=auto -axF'
alias ll='/bin/ls --color=auto -lF'
alias ls='/bin/ls $LS_OPTIONS'
alias mc='. /usr/share/mc/bin/mc-wrapper.sh'
alias v='vdir'
alias vdir='/bin/ls $LS_OPTIONS --format=long'
guest@porteus:~$ dir
1.bashrc_personal                modules.sh*
AnInitialLog.txt*                mychanges.sh*
Backups/                         nukesdb.sh*
Desktop/                         paths.txt
Downloads/                       pathupdate.sh*
Fixes.sh*                        poptrayu.sh*
 :
etc
The revised .bashrc.

Code: Select all

# Setup color scheme for list call <brokenman>
alias ll='/bin/ls --color=auto -lF'
alias la='/bin/ls --color=auto -axF'
alias ls='/bin/ls --color=auto -xF'

# Append any additional sh scripts found in /etc/profile.d/:
for y in /etc/profile.d/*.sh ; do [ -x $y ] && . $y; done
unset y

# Setup shell prompt for guest <wread and fanthom>
PS1='\[\033[01;36m\]\u@\h:\[\033[01;32m\]\w\$\[\033[00m\] '
PS2='> '
[ -e "$HOME/.bashrc_personal" ] && . "$HOME/.bashrc_personal"
And the new 1.bashrc_personal

Code: Select all

#!/bin/sh
# ^ not required, but allows for automatic syntax highlighting

du_dummy() {
# Removes containing directories
# usage: [THRESHOLD DIR]|[DIR]
   [ "" ] && { opts="t "; dir=""; } || { unset opts; dir=""; }
   [ -z "" ] && { dir="/home/guest"; }
   du -hax "" 2>/dev/null | awk '
   BEGIN { printf "%6s %s\n", "Size","File or Directory/" }
   {
      dir=
      if ( prev_dir !~ dir ) {
         if (system("test -d \""dir"\"") == 0) { dir=dir"/" }
         printf "%6s %s\n", , dir
      }
      prev_dir=
   }'
}
alias du-='du_dummy'
I'm unclear how this line "'[ -e "$HOME/.bashrc_personal" ] && . "$HOME/.bashrc_personal"' relates to the file named 1.bashrc_personal. Shouldn't the line have had "1.bashrc_personal" in it?
Ed

Post Reply