package dropdash.sh;

import java.util.List;

import com.google.common.collect.Lists;

public class Netstat extends FilteredCommand {

	public Netstat() {
		super("/bin/netstat -tunp|/usr/bin/awk '{print $1\";\"$2\";\"$3\";\"$4\";\"$5\";\"$6\";\"$7}'");
	}

	@Override
	public String apply(String input) {
		List<List<String>> output = Lists.newArrayList();
		List<String> lines = lineSplit(input);
		for (int i = 0; i < lines.size(); i++) {
			if (i > 0) {
				String line = lines.get(i);
				output.add(semicolSplit(line));
			}
		}
		return json(output);
	}

}

@@ -175,13 +175,23 @@
 at -
+n
 tu
-np%7C
+ %22%0A%09%09%09%09+ %22%7C 
 /usr
@@ -204,59 +204,132 @@
 wk '
-%7Bprint $1%5C%22;%5C%22$2%5C%22;%5C%22$3%5C%22;%5C%22$4%5C%22;%5C%22$5%5C%22;%5C%22$6%5C%22;%5C%22$7
+NR%3E2 %7Bsub(/:%5B%5E:%5D+$/, %5C%22%5C%22); print $5%7D' %22%0A%09%09%09%09+ %22%7C /usr/bin/sort %7C /usr/bin/uniq -c %22%0A%09%09%09%09+ %22%7C /usr/bin/awk '%7Bprint $1%5C%22;%5C%22$2
 %7D'%22)

Update netstat script