Search Results

Search: Posts Made By: rveri
1,810
Posted By Don Cragun
Maybe something like: awk ' { h[substr($1, 7,...
Maybe something like:
awk '
{ h[substr($1, 7, 1)]++
}
END { for(i in h)
printf("%s_hosts = %d\n", i, h[i])
}' file
producing the output:
d_hosts = 1
m_hosts = 8
o_hosts = 1
p_hosts = 17...
1,810
Posted By Don Cragun
Please note that rveri only supplied a partial...
Please note that rveri only supplied a partial answer to the question about what code had been attempted by the submitter. Until that question is answered in full, please refrain from posting...
1,810
Posted By RudiC
I'm pretty sure that's only a snippet from your...
I'm pretty sure that's only a snippet from your attempt. Post it in its entirety.

What if that char is NOT p , d , o , or m ?
1,223
Posted By MadeInGermany
Please get rid of the old style call of the expr...
Please get rid of the old style call of the expr program
i=`expr $i + 1`
k=`expr $i + 1`
And use the shell-builtins instead
i=$((i+1))
k=$((k+1))
or
((i+=1))
((k+=1))
And please avoid...
1,223
Posted By Scrutinizer
Try: sort -k1,1 -k2 datafile.txt | awk...
Try:
sort -k1,1 -k2 datafile.txt | awk '$1!=s{s=$1; close(f); f=s ".out"} {print>f}'
1,223
Posted By MadeInGermany
My second sample works the same as...
My second sample
works the same as Scrutinizer's sample:
sort the file on the 1st field and pipe the result to awk or a while loop. The awk automatically loops over each input line, so the code...
1,066
Posted By vgersh99
if ( F ) s = s ? s OFS $i : $iif expression F...
if ( F )
s = s ? s OFS $i : $iif expression F is true, then concatenate string 's' with value of field 'i' preceded with the output field separator OFS (if s is not empty). If 's' is empty assign...
2,382
Posted By RudiC
All of the proposals so far fail if there are...
All of the proposals so far fail if there are other dots in the line, e.g. file name extensions or like. You need to isolate the row of timing dots like e.g.
awk '{sub(/^[^:]*::/, ""); print...
2,382
Posted By Subbeh
Just trying out different methods in case anyone...
Just trying out different methods in case anyone is interested:

Perl:
perl -lne 'print $_ =~ tr/\.//' file
Python:
python -c 'print open("file").read().count(".")'
2,382
Posted By CarloM
tr -Cd '.' < file | wc -c
tr -Cd '.' < file | wc -c
2,382
Posted By rdcwayx
It is not solved by above code. if you have...
It is not solved by above code. if you have several lines, you calculate wrong.

try this:
grep -o "\." infile|wc -l
awk '{sum+=gsub(/\./,"")}END{print sum}' infile
1,605
Posted By Scrutinizer
Another way with sed : sed 's/\.\([^.]*\)$/...
Another way with sed :
sed 's/\.\([^.]*\)$/ \1/' file
or
sed 's/\./ /7' file
1,605
Posted By Akshay Hegde
you may try $ cat test tcp 0 0...
you may try

$ cat test
tcp 0 0 10.80.110.100 2900 1 10.40.104.6.42769 ESTABLISHED
tcp 0 0 10.80.110.100 2900 1 10.40.103.7.38620 ESTABLISHED
tcp ...
1,614
Posted By CarloM
It's -p for proc list (which I assume was the...
It's -p for proc list (which I assume was the aim).
1,614
Posted By Scrutinizer
Try: UNIX95=1 ps -p "$PID" -o...
Try:
UNIX95=1 ps -p "$PID" -o pcpu,pid,ppid,stime,etime,args
-edit- OK, I see CarloM already answered this one..
1,614
Posted By RudiC
Try ($2==pid1) EDIT: Or, maybe, ($2 ~...
Try ($2==pid1)

EDIT: Or, maybe, ($2 ~ "^"pid1"$") ?
6,742
Posted By in2nix4life
I wrote a shells script that takes the output...
I wrote a shells script that takes the output from stdin and surrounds it with #s.

Hope this helps.


#!/bin/bash
#
#

# read from stdin and dump to a temporary file...
2,401
Posted By jim mcnamara
awk is messy with [ ] characters. I'm on Solaris...
awk is messy with [ ] characters. I'm on Solaris so awk/nawk is even messier

Try: tr piped into awk as a general approach. If this works with the ancient BSD /usr/bin/awk of Solaris it will ...
2,401
Posted By Scrutinizer
Or awk -F'[]] |[]]$' '{print $1 "]"}'...
Or
awk -F'[]] |[]]$' '{print $1 "]"}' file
2,401
Posted By radoulov
GNU awk 4+: awk '{ print $1 }'...
GNU awk 4+:
awk '{ print $1 }' FPAT='[[][^]]+[]]' infileStandard awk:
awk 'match($0, /[[][^]]+[]]/) {
print substr($0, RSTART, RLENGTH)
}' infile
If you need all the occurrences:...
2,401
Posted By RudiC
What about awk '{gsub ("\] \[", "];["); print...
What about
awk '{gsub ("\] \[", "];["); print $1}' FS=";" file
[ Aug 19 21:02 apptime_flagECQAPP ]
[ Aug 24 01:43 apptime_flagECTAPP ]
[ Aug 28 01:47 apptime_flagMOWSQ101 ]
[ Aug 28 01:49...
2,401
Posted By vbe
but then you loose the brakets in the output...
but then you loose the brakets in the output hehe... yep messy...
2,401
Posted By shamrock
Try the awk below... awk -F" ]" '{print $1 FS...
Try the awk below...
awk -F" ]" '{print $1 FS $2 FS $3}' file
2,401
Posted By vgersh99
depending on how picky your awk is: awk...
depending on how picky your awk is:

awk -F'(\\[)|(\\])' '{print "[" $2 "]" }' myFile
1,382
Posted By Aia
See if that fits you. awk '/PV Name/ {if...
See if that fits you.

awk '/PV Name/ {if (!a[$NF]++)print $NF}'
Showing results 1 to 25 of 146

 

Featured Tech Videos

All times are GMT -4. The time now is 12:31 AM.
Unix & Linux Forums Content Copyright 1993-2021. All Rights Reserved.
Privacy Policy