Search Results

Search: Posts Made By: summer_cherry
4,179
Posted By summer_cherry
try below sed
sed -n '/150318 23:19:04/,/150318 23:55:04/{p}'
5,723
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=" +| +"}...
2,081
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
...
1,775
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...
6,211
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
3,532
Posted By summer_cherry
awk
awk 'BEGIN{
FS="[ \t]+"
}
{
if(NR%4==1){
user=$1
users[user]=$0
sort[NR]=$2" "user
}
else{
...
1,518
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...
1,485
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:...
9,195
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:...
4,999
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:...
2,885
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...
2,062
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]=[]
...
1,533
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...
1,559
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...
1,560
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...
2,590
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...
1,402
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:
...
1,149
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
15,355
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...
2,205
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 =...
9,347
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...
2,062
Posted By summer_cherry
awk + uniq
awk '$2==100' a | sort | uniq
1,236
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};...
1,414
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,688
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

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