Trying to get rid of a duplicate output line...


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Trying to get rid of a duplicate output line...
# 8  
Old 04-22-2013
I had made some edits to my approach in the meantime, perhaps you could try if that works better.
# 9  
Old 04-22-2013
Hi,

I tried your updated method and it got the machine name correctly but still is not capturing any of the data on the TENGETHERNET interfaces, and it is miss reporting the other numbers

Can you explain the logic so i can see what's happening and what's not?

Quote:
Originally Posted by Scrutinizer
I had made some edits to my approach in the meantime, perhaps you could try if that works better.
# 10  
Old 04-22-2013
I annotated my post. Strange that it does not work. Did you test with your own sample. Did you try cutting and pasting your own sample into a file to see if that makes a difference? What is your shell, OS and version?
# 11  
Old 04-23-2013
Hi all,
Tried to post this twice and it bounced.
My boss wanted the printed data variablized as well...for future use.
So I re-wrote the prog..in a less elegant form..but got it working.

thanks for all your help!
the final code is below

Marc
Code:
#!/bin/ksh

###########################################
# Parser.sh version 0.1
# Author: Marc G
#
###########################################

# read file - Hard coded.  File to be read can be determined via logic later
file="capturesummary.txt"

while read line
do
  # parse device name
  name=$(echo $line | grep ^RP | awk -F: '{print $2}'| awk -F# '{print $1}')
  if [[ $name != "" ]]
   then
    devName=$name
  fi

  # Parse Data
#     total is parsed as "Capacity", Up and Down are added into "Ports in Use" and administratively Down is "Ports Not In use"
  data=$(echo $line | egrep -i "IFT_ETHERBUNDLE|IFT_GETHERNET|IFT_TENGETHERNET")
  type=$(echo $line | awk '{print $1}')

  case $type in
  "IFT_ETHERBUNDLE")
   bunCap=$(echo $data | awk '{print $2}')
   bunUsed=$(echo $data | awk '{print $3 + $4}')
   bunNot=$(echo $data | awk '{print $5}')
  ;;
  "IFT_GETHERNET")
   geCap=$(echo $data | awk '{print $2}')
   geUsed=$(echo $data | awk '{print $3 + $4}')
   geNot=$(echo $data | awk '{print $5}')
  ;;
  "IFT_TENGETHERNET")
   lOCap=$(echo $data | awk '{print $2}')
   lOUsed=$(echo $data | awk '{print $3 + $4}')
   lONot=$(echo $data | awk '{print $5}')
  ;;
  esac

done <"$file"

echo "Device Name: $devName:\n"
printf "IFT_ETHERBUNDLE:\n  Capacity:\t%d\n  In Use:\t%d\n  Unused:\t%d\n" "$bunCap" "$bunUsed" "$bunNot"
printf "IFT_GETHERNET:\n  Capacity:\t%d\n  In Use:\t%d\n  Unused:\t%d\n" "$geCap" "$geUsed" "$geNot"
printf "IFT_TENGETHERNET:\n  Capacity:\t%d\n  In Use:\t%d\n  Unused:\t%d\n" "$lOCap" "$lOUsed" "$lONot"

# end

This User Gave Thanks to Marc G For This Post:
# 12  
Old 04-23-2013
@ Marc G: Thanks for reporting back..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Get an output of lines in pattern 1st line then 10th line then 11th line then 20th line and so on.

Input file: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 (6 Replies)
Discussion started by: Sagar Singh
6 Replies

2. Shell Programming and Scripting

Honey, I broke awk! (duplicate line removal in 30M line 3.7GB csv file)

I have a script that builds a database ~30 million lines, ~3.7 GB .cvs file. After multiple optimzations It takes about 62 min to bring in and parse all the files and used to take 10 min to remove duplicates until I was requested to add another column. I am using the highly optimized awk code: awk... (34 Replies)
Discussion started by: Michael Stora
34 Replies

3. Shell Programming and Scripting

how to duplicate an output in shell script

how to duplicate an output from a shell command? for example: `date` will give the current date to the console. I want this to be displayed in console and also parallely store it in file or variable. user1@solaris4:~> date Tue Feb 28 17:48:31 EST 2012 user1@solaris4:~> date > file ... (3 Replies)
Discussion started by: Arun_Linux
3 Replies

4. Shell Programming and Scripting

How get rid of kill output message?

Hi, My problem is the following, I have a little shell script that has a couple of functions... in one function I start an app like this... runmqtrm -m $ourManager -q $ourMQSYS.EVTINITQ 1>/dev/null 2>&1 & In another function I kill that app using kill -s SIGKILL $triggerMonitorPID... (15 Replies)
Discussion started by: valiadi
15 Replies

5. Shell Programming and Scripting

Get rid of the 7th character of each line if this is a space

I have a text file like this ... B 16 1.340E+05 A 18 3.083E+02 Wu123 1.365E+02 ... I would like to get rid of the 7th character of each line if this is a space character. Thank you, Sarah (5 Replies)
Discussion started by: f_o_555
5 Replies

6. Shell Programming and Scripting

Duplicate output without tee

Hi, Is there anyway to duplicate output without using tee? Let me explain the problem. We are use ssh to login to remote server and save output to a file using tee commands for auditing purposes. When we use vi editor in ssh session, letters get garbled and cant really use vi. Without tee it... (7 Replies)
Discussion started by: eagles1
7 Replies

7. Shell Programming and Scripting

How to get rid of last line

I have to process a data file in Ab Initio. This data file is pipe delimited. BUt the file may have a Disclaimer line at the end. So before picking it for processing, I need to check if this line is there I need to remove it. ANy suggestions. Thanks Shalu (1 Reply)
Discussion started by: shalua
1 Replies

8. Shell Programming and Scripting

getting rid of duplicate files

i have a bad problem with multiple occurances of the same file in different directories.. how this happened i am not sure! but I know that i can use awk to scan multiple directory trees to find an occurance of the same file... some of these files differ somwhat but that does not matter! the... (4 Replies)
Discussion started by: moxxx68
4 Replies

9. Shell Programming and Scripting

how to get rid of blank line in a flat text file

Hi, I have a flat text file which contains blank line between each text line. Is there any command to get rid of it? Thanks for your help (11 Replies)
Discussion started by: xfang
11 Replies

10. Shell Programming and Scripting

getting rid of $ when entered at the command line

Hi everyone, Can someone possibly help me with this problem I am having please. I wrote a Korn shell script to manipulate currency amounts in a way that a person could use this script to determine the minimum number of coins required to make a certain amount. for example when entered on the... (2 Replies)
Discussion started by: bashirpopal
2 Replies
Login or Register to Ask a Question