Search Results

Search: Posts Made By: summer_cherry
1,375
Posted By summer_cherry
try below sed
sed -n '/150318 23:19:04/,/150318 23:55:04/{p}'
2,427
Posted By summer_cherry
if you are sure that it is impossible for either...
if you are sure that it is impossible for either of REQUEST/RESPONSE/SUCCESS to appear more than once in terms of your key from column 1. Then below awk should work for you.

awk 'BEGIN{FS=" +| +"}...
924
Posted By summer_cherry
hope below prototype can help you some
num_of_files=`ls leo| wc -l`
loop_size=$((${num_of_files}/2))
i=1
while [ $i -le $loop_size ];do
let tmp=$i+$loop_size
echo "comparing file_${i} with file_${tmp}"
let i=$i+1
done
...
621
Posted By summer_cherry
awk 'BEGIN{ FS="[ ]+" } { arr[$1]+=$5 ...
awk 'BEGIN{
FS="[ ]+"
}
{
arr[$1]+=$5
brr[$1]+=1
}
END{
for(i in arr){
avg=arr[i]/brr[i]
print i,avg
}
}' a b
Your repeated refusal to use CODE tags as required by forum rules has...
992
Posted By summer_cherry
awk -F"," 'BEGIN{OFS=","} { if(NR==FNR) ...
awk -F"," 'BEGIN{OFS=","}
{
if(NR==FNR)
_[$1]=$0
else
print $0,_[$1]
}' file2 file1
1,598
Posted By summer_cherry
awk
awk 'BEGIN{
FS="[ \t]+"
}
{
if(NR%4==1){
user=$1
users[user]=$0
sort[NR]=$2" "user
}
else{
...
628
Posted By summer_cherry
Why my SETUID does not work as expected?
Hi All,

Thanks for your help in advanced.

Could you please kindly help on why my SETUID does not work?

create a file, only root can read write it
/tmp>ls -l a.log
-rw------- 1 root root 3...
781
Posted By summer_cherry
users={} mark=[] with open("a.txt") as file: ...
users={}
mark=[]
with open("a.txt") as file:
for line in file:
line=line.replace("\n","")
if len(line)==0:
continue
if 'user=' in line:
user=line
else:
if user in users:...
3,322
Posted By summer_cherry
import os from collections import deque ...
import os
from collections import deque

def parse_file(f,first=0):
header=""
line_3=""
cnt=0
q=deque([],maxlen=4)
with open(f) as file:
for line in file:...
2,087
Posted By summer_cherry
python
cache={}
with open("a.txt") as file:
for line in file:
line=line.replace("\n","")
key=" ".join([i.lower() for i in filter(lambda x: x!="",line.split(" "))])
if key not in cache:...
1,503
Posted By summer_cherry
python with open("b.txt") as file: ...
python

with open("b.txt") as file:
lines=file.readlines()
a=[
[
i[j]
for i in
[
j for j in [j.split(" ") for j in [line.replace("\n","") for line in lines ]]
]
]
for j in...
992
Posted By summer_cherry
python
import re
hash={}
with open("a.txt") as file:
for line in file:
arr=re.findall('"[^"]+"',line.replace("\n",""))
key=" ".join(arr[0:13])
if key not in hash:
hash[key]=[]
...
742
Posted By summer_cherry
python
arr=[]
with open("a.txt") as file:
for line in file:
line=line.replace("\n","")
if not arr:
arr.append(line)
elif int(arr[-1])+1==int(line):
arr.append(line)
else:
if...
834
Posted By summer_cherry
python
d={}
td={}
with open("a.txt") as file:
for line in file:
line=line.replace("\n","")
items=line.split(" ")
a=[int(i) for i in items[0].split(":")]
t=a[0]*3600+a[1]*60+a[2]
if...
741
Posted By summer_cherry
you may try below python
import os
import collections
d=collections.defaultdict(list)
cnt=0
for f in sorted(os.listdir('dir')):
with open('dir/'+f) as file:
for line in file:
t=line.split(" ")
if t[0] not...
1,400
Posted By summer_cherry
python
import itertools
import operator
a='''Linux 2014_01_24 CPU 10
Linux 2014_01_24 MEM 20
UNIX 2014_01_24 CPU 30
UNIX 2014_01_24 MEM 40'''.split("\n")
a=map(lambda x:x.split(" "),a)
for name,item...
751
Posted By summer_cherry
some kind of python code
import glob
for i in glob.glob('leo/*.txt'):
name=i[i.index('_')+1:i.rindex('.')]
with open(i) as file:
l=[name]
for line in file:
if line.startswith(' '):
pass
else:
...
587
Posted By summer_cherry
awk
awk 'BEING{lines=0}
{
if(NR%3==0){
print a
a=0
}
else{
a+=$3
print $0
}
lines=NR
}
END{
if(lines%3!=0)
print a
}' a
6,548
Posted By summer_cherry
sed python
If it is exactly a multiple of 7, below simple 'sed' should be ok for you.

sed -n '{N;N;N;N;N;N;s/\n/ /g;p}' a

If it is somehow not multiple of 7, use below awk.

awk '{
str=$0
pre_nr=NR...
1,009
Posted By summer_cherry
python OR perl
python

import re
counter=1
keys={}
values={}
with open("a.txt") as file:
for line in file:
line=line.replace("\n","")
if re.match('=',line):
counter+=1
continue
items =...
5,801
Posted By summer_cherry
python OR perl
python
def leo(x):
return(x[0],x[1],int(x[2]))
d=[]
with open("a.txt") as file:
for line in file:
line=line.replace("\n","")
items = line.split(" ")
d.append(items)
for i in...
955
Posted By summer_cherry
awk + uniq
awk '$2==100' a | sort | uniq
701
Posted By summer_cherry
hope below perl can help you some
my %overload;
my %idle;

sub handle{
OUTER:
foreach my $os (sort keys %overload){
foreach my $is (sort keys %idle){
my $ol = $overload{$os};
my $available = $idle{$is};...
721
Posted By summer_cherry
awk
awk -F"[|]" '{
if(FILENAME=="file1")
key[$1]=1
else if(FILENAME=="file3"){
tail[$0]=1
}
else{
if(key[$3]==1){...
1,023
Posted By summer_cherry
perl
my @arr;
my $hit2=0;
while(<DATA>){
chomp;
if(/website1/ && scalar @arr && $hit2){
print join(";",@arr);
print "\n";
$#arr=-1;
$hit2=0;
}
elsif(/website2/){
$hit2=1;
}
push...
Showing results 1 to 25 of 500

 

Featured Tech Videos

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