Search Results

Search: Posts Made By: rveri
3,047
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...
3,047
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...
3,047
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 ?
2,141
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...
2,141
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}'
2,141
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,744
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...
3,915
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...
3,915
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(".")'
3,915
Posted By CarloM
tr -Cd '.' < file | wc -c
tr -Cd '.' < file | wc -c
3,915
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,975
Posted By Scrutinizer
Another way with sed : sed 's/\.\([^.]*\)$/...
Another way with sed :
sed 's/\.\([^.]*\)$/ \1/' file
or
sed 's/\./ /7' file
1,975
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,937
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,937
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,937
Posted By RudiC
Try ($2==pid1) EDIT: Or, maybe, ($2 ~...
Try ($2==pid1)

EDIT: Or, maybe, ($2 ~ "^"pid1"$") ?
9,376
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...
3,548
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 ...
3,548
Posted By Scrutinizer
Or awk -F'[]] |[]]$' '{print $1 "]"}'...
Or
awk -F'[]] |[]]$' '{print $1 "]"}' file
3,548
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:...
3,548
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...
3,548
Posted By vbe
but then you loose the brakets in the output...
but then you loose the brakets in the output hehe... yep messy...
3,548
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
3,548
Posted By vgersh99
depending on how picky your awk is: awk...
depending on how picky your awk is:

awk -F'(\\[)|(\\])' '{print "[" $2 "]" }' myFile
1,713
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

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