📄 makecsv
字号:
#! /bin/bash## makeCSV## Copyright 2006 Mark Lisee, Boleslaw K. Szymanski and Rensselaer Polytechnic# Institute. All worldwide rights reserved. A license to use, copy, modify# and distribute this software for non-commercial research purposes only is# hereby granted, provided that this copyright notice and accompanying# disclaimer is not modified or removed from the software.## DISCLAIMER: The software is distributed "AS IS" without any express or# implied warranty, including but not limited to, any implied warranties of# merchantability or fitness for a particular purpose or any warranty of# non-infringement of any current or pending patent rights. The authors of# the software make no representations about the suitability of this software# for any particular purpose. The entire risk as to the quality and# performance of the software is with the user. Should the software prove# defective, the user assumes the cost of all necessary servicing, repair or# correction. In particular, neither Rensselaer Polytechnic Institute, nor# the authors of the software are liable for any indirect, special,# consequential, or incidental damages related to the software, to the maximum# extent the law permits.## Usage: makeCSV <directory>## The directory is expected to contain only the files generated by many runs# of the simulation.# - Search all of the files in the directory looking for oversized packets.# - For each of the important summary lines at the end of the files:# - Use grep to extract these lines to a temporary file# - Use awk on the temporary file to convert each line to a CSV format that# retains only the desired information.# - Clean up by removing the temporary files.dir=$1appFile=app.csvnetFile=net.csvmacFile=mac.csvbatFile=bat.csvcd $direcho "Searching for oversized packets..."grep -l Oversize *-*if [ $? -eq 0 ]; then echo "Oversized packet in at least one run"else echo "Everything OK"fi# Grep for desired string & save results in temp file# break lines in temp file at ':', keep some fields & write to 2nd temp file# write header to final file# break lines in 2nd temp file at ' ', keep some fields & write to final filegrep APP * > aawk -F: '{printf( "%s %s %s %s\n", $1, $3, $4, $6)}' a > becho "name, sent, received, delay" > $appFileawk '{printf( "%s, %s %s %s\n", $1, $2, $4, $7)}' b >> $appFilegrep "NET -- pkt" * > aawk -F: '{printf( "%s %s %s %s %s %s %s %s\n", $1, $3, $4, $5, $6, $7, $8, $9)}' a > becho "name, sent, received, hop count, suboptimal, can pkt, can subopt" > $netFileawk '{printf( "%s, %s %s %s %s %s %s\n", $1, $2, $4, $7, $12, $15, $18)}' b >> $netFilegrep "MAC" * > aawk -F: '{printf( "%s %s %s\n", $1, $3, $4)}' a > becho "name, sent, received, collision" > $macFileawk '{printf( "%s, %s %s %s\n", $1, $2, $4, $7)}' b >> $macFilegrep "BAT" * > aawk -F: '{printf( "%s %s %s\n", $1, $3, $4)}' a > becho "name, initial, remaining" > $batFileawk '{printf( "%s, %s %s %s\n", $1, $2, $4, $7)}' b >> $batFilerm a b
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -