printf is your solution.
netstat -an | grep tcp |awk '{x[$6]++;} END {
for(i in x){printf "%s ",i};print "";
for(i in x){printf "%s ",x[i];print ""}
}' |awk '{printf "%15s%15s%15s%15s%15s%15s\n",$1,$2,$3,$4,$5,$6}'
15 is the size you want to apply to each field.
Good luck.
I would put my awk script in a file named mytool.awk (with adding #!/usr/bin/awk -f and giving execution permission)
Then, in a directory containing my csv files, i would just write:
for i in *;do mytool.awk $i>$i'.html';done
I doubt that the recommended output has anything to do with a csv file to import.
I also doubt about 'idle' put after the destination. Is it a bad copy/paste?
As PHV has said, precise your question.
1) "hour" is extracted from a string. So it is a string. To consider it as a number (in order to format it), I would have use a command such as int()
[edit] reading again your code, I mentionned you have 2 n. One for the loop and one to store the result of sprintf. This is not good.[edit]...
First I was very surprised. Then I realised that your file has hidden spaces at the end of line. So you have to clean it, either directly, or by command (but it becomes long compared too the awk solution)
The following command over the log file you gave works fine for me:
sed '/^$/N;s/\n//;s/^input/\ninput/;s/\.\.\([^\.]\(\.\{0,1\}[^\.]\{1,\}\)\{1,\}\).*/ \1/;/^U/{s/U \([^\.]*\)[^ ]* \([^ ]*\) -> \([^ ]*\) [^ ]* /\1 \2 \3 /}' pcap.txt
Result:
input: /media/KINGSTON/test.pcap
match...
First, your log is dirty. The result can be in the fifth column (SUCCESS) or the sixth column (FAILURE).
Change it and you'll be able to use:
awk -F";" '{num=0;cmd="grep -c "$6" file.log";cmd|getline num;close(cmd);printf "%-20s %s\n",$6,num}' |sort -u
"-F" to change the separator
"6" is the...
If the pain comes from the point-slash, you have two more solutions:
o alias. Example:
alias goForIt="./goforit.bin"
You place it in your ~/.bashrc not to retype it each time you restart.
o place a symbolic link into your /home/user/bin directory. Example:
ln -s /your/path/to/app/goforit.bin...
First, the suggested solutions won't work with:
release 10.1
Or
release release 4 (Nahant Update 9 extended)
What about
sed 's/.*release \([^ ]*\) .*/\1/' /etc/*release
?
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.