Help removing output from .sh script

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help removing output from .sh script
# 8  
Old 08-12-2013
Your colleague told you nonsense!
du -sk *

does the same as
du -sk ./*

but reports the plain file names instead of prefixing them with ./.
And tell him you are running du -sk ././* for double safetySmilie

Last edited by MadeInGermany; 08-12-2013 at 10:40 AM..
# 9  
Old 08-12-2013
Some variation using awk
du -sk * | sort -rn | awk '{if ($1>1048576) {$1=$1/1048576;t="GB"} else if ($1>1024) {$1=$1/1024;t="MB"} else {t="KB"}} NR < 11 {printf "% 10s %s %s\n",$1,t,$2}'

du -sk * | sort -rn | awk '{
	if ($1>1048576) {$1=$1/1048576;t="GB"} 
	else if ($1>1024) {$1=$1/1024;t="MB"} 
	else {t="KB"}
	NR < 11 {printf "% 10s %s %s\n",$1,t,$2}'

# 10  
Old 08-12-2013
With two efficiency tricks and extended range it becomes
du -sk * | sort -rnk1 | awk '
NR>10 {exit}
  if ($1>1073741824) {$1=$1/1073741824; t="TB"}
  else if ($1>1048576) {$1=$1/1048576; t="GB"}
  else if ($1>1024) {$1=$1/1024; t="MB"}
  else {t="KB"}
{printf "%10s %s %s\n",$1,t,$2}

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Removing characters and some output

Hi guys, So I am using an awk command to return a specific column in a file. I also need to remove some extra characters. What I have is :: (http-/|23:00:41 And what I want is : http-/ I tried using the td command but it is only removing the ( ,... (5 Replies)
Discussion started by: Junaid Subhani
5 Replies

2. Shell Programming and Scripting

Help in removing control M and Line feed in output file.

Hi All, In my output file i am getting control m character and also the line feeds at different places and with different combinations, the content of the file is supposed to be in a single line but if there is a line feed in between then from there onwards it's going into new line. I tried... (7 Replies)
Discussion started by: Bipin Kumar
7 Replies

3. UNIX for Dummies Questions & Answers

Removing unnecessary eol ($) character from Oracle sql query output

Hi All, I am fetching oracle query result in shell variable. As columns numbers are more the output wraps in unix terminal .i.e one complete record in db gets store in multiple lines. with each line ends with $ character. I want to remove these unnecessary $ character but to keep required $... (8 Replies)
Discussion started by: Harshal22
8 Replies

4. Shell Programming and Scripting

script to mail monitoring output if required or redirect output to log file

Below script perfectly works, giving below mail output. BUT, I want to make the script mail only if there are any D-Defined/T-Transition/B-Broken State WPARs and also to copy the output generated during monitoring to a temporary log file, which gets cleaned up every week. Need suggestions. ... (4 Replies)
Discussion started by: aix_admin_007
4 Replies

5. Shell Programming and Scripting

Removing Characters From finger Output

Hi Does anyone know of a command that will extract only the Login name alison and year 2005 from the following output. jamesm> finger alison Login name: alison In real life: Alison Smith - Queensland Directory: /data/home/alison Shell: /usr/bin/ksh... (2 Replies)
Discussion started by: jamba1
2 Replies

6. Shell Programming and Scripting

Removing spaces from the output of a head command

Im running the below commands in a script. Total_confirms=`cat $OUTPATH/count_po* | head -4 | tail -1` # echo "Total Confirms records we need: $Total_confirms" >> $LOG2 The problem is its always returning 4 spaces before the result.. Can I pipe the result into something else to remove the... (5 Replies)
Discussion started by: Jazmania
5 Replies

7. Shell Programming and Scripting

help removing characters for output file in shell script

hi i'm new to shell scripts and have a small problem i am running a batch converter that returns all flash .flv files in a directory and create a png image from each one the problem i have is the $1 variable , its ok on the first call but on the secound call $1.png , i have extra... (1 Reply)
Discussion started by: wingchun22
1 Replies

8. Shell Programming and Scripting

Removing Null data in output

Hello all, I have a script that has an infile with system package information. For the most part the script is looking well. The only thing i need help is in testing for null entries and removing null data. #!/usr/bin/ksh for i in `cat /mwncps/bin/eco_pack` do NAME=`pkginfo -l |... (2 Replies)
Discussion started by: liketheshell
2 Replies

9. Shell Programming and Scripting

Removing Garbage output

I am using following code to read myfile.ddl line by line. But the thing is it is printing lot of garbage which are the names of the files and directories in which myfile.ddl is present. Kindly refine the code so that only myfile.ddl contents are only read LOGFILE="logfile.txt"... (4 Replies)
Discussion started by: skyineyes
4 Replies

10. Shell Programming and Scripting

Removing first line from output

my script gives 10 outputs continuously..In each output i have to remove the first line in the output.How to do that. for eg : below is my output 0.00 1.00 5.00 0.00 7.00 i have to remove the first line of this output ie;0.00 (3 Replies)
Discussion started by: Krrishv
3 Replies
Login or Register to Ask a Question