Originally Posted by
ibizatunes
Fixed it.... a cup of tea and clear head!!
Code:
alias duf='du -sk /home/* | sort -n | perl -ne '\''($s,$f)=split(m{\t});for (qw(K M G)) {if($s<1024) {printf("%.1f",$s);print "$_\t$f"; last};$s=$s/1024}'\' | duf >> /tmp/file_useage
just pipe alias duf out to a file
this makes no sense to me.
Either:
(a) you define your alias to generate results to std out, and then when wishing to save the results you execute the alias with a redirection, e.g:
Code:
$ alias duf='du -sk /home/* | sort -n | perl -ne '\''($s,$f)=split(m{\t});for (qw(K M G)) {if($s<1024) {printf("%.1f",$s);print "$_\t$f"; last};$s=$s/1024}'\'
$ duf > /path/to/some/file
(b) Or, you define your alias with redirection to a file builtin, so that you just execute the alias.
Code:
$ alias duf='du -sk /home/* | sort -n | perl -ne '\''($s,$f)=split(m{\t});for (qw(K M G)) {if($s<1024) {printf("%.1f",$s);print "$_\t$f"; last};$s=$s/1024}'\'' > /path/to/some/file'
$ duf
you probably want > redirection rather than >> since with >> you will append results to the file each time rather than replacing what was previously there.
Bookmarks