Need help in echo output


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need help in echo output
# 1  
Old 07-22-2011
Need help in echo output

Hi All,

I have code to get the UUID and capacity for the LUN from CX -arry. I need the output in this format
Code:
LUN Number    UUID                                                      Space in MB
 
LUN 238 60:06:01:60:C2:56:11:00:28:36:67:59:11:04:DE:11 122880


But Now iam getting this output format
Code:
LUN 270
 
60:06:01:60:C2:56:11:00:E6:B2:3D:C5:11:04:DE:11
307200

Code for this script is

Code:
***********************************************
host=$1 
array=$2
for f in `cat /opt/emc/cxarray/${host}`
do
  echo LUN ${f}
  naviseccli -h ${array} getlun $f -uid |awk '{print $2}'
  naviseccli -h ${array} getlun $f |grep "LUN Capacity(Megabytes)"|awk '{print $3}'
done
***************************************************


Last edited by Franklin52; 07-22-2011 at 06:57 AM.. Reason: Please use code tags for code and data samples, thank you
# 2  
Old 07-22-2011
Example from array file ?
if input line include spaces, for is not easy. While is better
Code:
while read line
# or while read var1 var2 var3 endstr
do
    # you can set line to array
    flds=($line)
   # or set -A flds -- $line # => $1 is 1st fld and $* is all and $# is number of values
    echo 1st value is ${flds[0]}
    #...
done < /opt/emc/cxarray/$host

# 3  
Old 07-22-2011
Code:
 
echo -n LUN ${f}
naviseccli -h ${array} getlun $f -uid |awk '{printf(" %s ",$2)}'
naviseccli -h ${array} getlun $f |grep "LUN Capacity(Megabytes)"|awk '{print $3}'

---------- Post updated at 01:37 PM ---------- Previous update was at 01:20 PM ----------

This is called useless use of cat

Code:
 
for f in `cat /opt/emc/cxarray/${host}`

use

Code:
 
while read f
do 
...
...
done < /opt/emc/cxarray/${host}

# 4  
Old 07-22-2011
thanks works great
Quote:
echo -n LUN ${f}
naviseccli -h ${array} getlun $f -uid |awk '{printf(" %s ",$2)}'
naviseccli -h ${array} getlun $f |grep "LUN Capacity(Megabytes)"|awk '{print $3}'
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Echo's strange output

Hi, Kindly help me to understand the behavior or logic of the below shell command $ echo $!# echo $echo $ $ $ echo !$# echo $# 0 I am using GNU bash, version 3.2.25(1)-release (2 Replies)
Discussion started by: royalibrahim
2 Replies

2. Shell Programming and Scripting

Echo output from command

Hello i am trying to do some calculation from output command for example ls -l if then echo "error" else echo "$" fi its something like this which get strings from output command and try to sum total lines of this string if exceed certain number it display error if not it... (3 Replies)
Discussion started by: mogabr
3 Replies

3. Shell Programming and Scripting

sorting output of echo

can someone please tell me who to sort the numerical output of echo? UIO="8180 0 0 0 0 0 0 0 0 0 0 48240 48240 48240 48240 48240 48240 0 0 0 0 0 0 0 48300 0 0 0 48300" echo $UIO | sort -n This doesn't workk. it does not sort the numbers from smallest to highest. any ideas? (2 Replies)
Discussion started by: SkySmart
2 Replies

4. Shell Programming and Scripting

formatting output using echo

i have the following script: while ;do b=${ARRAY2} i=0 while ;do a=${ARRAY1} fin=`echo $a - $b | bc` echo -e "${fin}," >> try ((i++)) ((k++)) done echo -n >> try #add statement to format output here #printf "\t" >> try #echo -e '\t' >> nik ((j++)) echo $j (3 Replies)
Discussion started by: npatwardhan
3 Replies

5. Shell Programming and Scripting

Output of both the echo statement in one line

I have script like echo -n FINISHED FEXP: ${TABLE2EXP} echo $STATUS I want the output of both the echo statement in one line How can i do this (3 Replies)
Discussion started by: scorp_rahul23
3 Replies

6. Shell Programming and Scripting

weird echo output?

#!/bin/bash INPUT=$1 if then INPUT=0$1 TRACKNUMBER=$INPUT fi TRACKNUMBER=$INPUT echo "Track Number:" $TRACKNUMBER if then echo "File Does Not Exist!: split-track"${TRACKNUMBER}".wav" exit 0 fi CUEFILE="$2" (6 Replies)
Discussion started by: TinCanFury
6 Replies

7. UNIX for Dummies Questions & Answers

What is the output of echo *

Hi all, Kindly let me know the output of echo * command. (4 Replies)
Discussion started by: shailja
4 Replies

8. Shell Programming and Scripting

piping output to echo

Hi, I was wondering why ls * | echo does not print the contents of the directory to the screen? The way I see it, ls * returns a whole lot of information, and then we pipe all this info to echo, so surely it should all come to our screen! Is there a serious flaw in my understanding? ... (3 Replies)
Discussion started by: A1977
3 Replies

9. UNIX for Dummies Questions & Answers

How do I output or echo NONE if grep does not find anything?

I am performing a grep command and I need to know how to echo "NONE" or "0" to my file if grep does not find what i am looking for. echo What i found >> My_File grep "SOMETHING" >> My_File I am sure this is easy, I am sort of new at this! Thanks (2 Replies)
Discussion started by: jojojmac5
2 Replies

10. Shell Programming and Scripting

Store output and Echo

I will admit I am a newbie but I am trying to write some simple scripts Situation: I have a list of IP Addresses that I want to once or 2 times a day store the average ping response time in a database (mysql) I am part way there but not all the way there I have the following cat ./slow... (2 Replies)
Discussion started by: meyerder
2 Replies
Login or Register to Ask a Question