Visit The New, Modern Unix Linux Community

Search Results

Search: Posts Made By: Klashxx
1,429
Posted By Klashxx
Using GNU date: $ date --date="Dec 11"...
Using GNU date:
$ date --date="Dec 11" +"%Y-%m-%d"
2014-12-11
2,551
Posted By Klashxx
Try this: #!/bin/bash typeset -i interval=5 ...
Try this:
#!/bin/bash
typeset -i interval=5
run=true
trunk=vonage
reboot=0
while [[ "$run" == "true" ]]; do
checktrunk=$(asterisk -rx "sip show peer $trunk" | grep -c "Status.*OK")
if...
1,826
Posted By Klashxx
Nice & clean @Yoda , just one point i .. i would...
Nice & clean @Yoda , just one point i .. i would use next to avoid the second matching this way:
awk '
/>/ {
$0 = ( NR == 1 ? $0 : RS $0 RS )
print
...
1,575
Posted By Klashxx
Add tou your ssh: -o ConnectTimeout=n Where n...
Add tou your ssh:
-o ConnectTimeout=n
Where n is compute as seconds.
9,198
Posted By Klashxx
Hi @wisecracker, i just wanted tho show a...
Hi @wisecracker, i just wanted tho show a practical usage of look-ahead/behid assertion, for me the important thing here is not the print statement and of course i can't guarantee python in all *nix...
861
Posted By Klashxx
I would choose another python approach by using...
I would choose another python approach by using datetime calculation facilities:
#cat filter.py
#!/usr/bin/python

import sys
import datetime

first_offline = {}
with open(sys.argv[1],'r')...
4,664
Posted By Klashxx
Try this logic: #!/usr/bin/python import...
Try this logic:
#!/usr/bin/python

import re
import ping, socket
import subprocess
from subprocess import Popen, PIPE

pattern = re.compile(r'inet.\S+(\S+\d+\.\d+\.\d+\.)')

p1 =...
1,055
Posted By Klashxx
Quick dirty awk: awk...
Quick dirty awk:
awk 'NR==1{L=$NF<$(NF-1)?$NF:$(NF-1)}$(NF-1)<= L{L=$(NF-1);t=$0};$NF<=L{L=$NF;t=$0}END{print t}' infile
5,886
Posted By Klashxx
You should pick one tool and keep stick to it. ...
You should pick one tool and keep stick to it.
A starting point to give python a try:
#!/usr/bin/env python
import re
import sys

pattern = re.compile(r'''
...
5,886
Posted By Klashxx
Interesting regex (python shell again): >>>...
Interesting regex (python shell again):
>>> text = '''
... @LIB ADVAPI32.dll @CAL RtlInitAnsiString @PA1 0x0012f740 @PA2 "CriticalSectionTimeout" @RET0
... @LIB ADVAPI32.dll @CAL...
1,394
Posted By Klashxx
python shell: >>> import re >>> text = ''' ...
python shell:
>>> import re
>>> text = '''
... Server Stopped
... ABC
... DEF
... GHI
... JKL
... Server Started
... MNO
... PQR
... STU
... Server Stopped
... VWX
... YZ
... ABC
......
5,886
Posted By Klashxx
From python shell: >>> import re >>> text =...
From python shell:
>>> import re
>>> text = '''
... @LIB ADVAPI32.dll @CAL RtlInitAnsiString @PA1 0x0012f740 @PA2 "CriticalSectionTimeout" @RET0
... @LIB ADVAPI32.dll @CAL memmove @PA1...
973
Posted By Klashxx
Try: sort -un inputfile
Try:
sort -un inputfile
767
Posted By Klashxx
Not sure if i understood correctly, but this may...
Not sure if i understood correctly, but this may helps:
# awk '{a[$NF]=sprintf("%s%s ",a[$NF],$1)}END{for (i in a){print i,a[i]}}' infile
1.1.1.1 app1 app3
1.1.1.2 app2
1.1.1.3 app4
4,584
Posted By Klashxx
Give this a try: awk '/<\/RECORD/{ ...
Give this a try:
awk '/<\/RECORD/{
print raw""$0 > name".xml"
name=""
raw=""
next}
...
690
Posted By Klashxx
Another way: ls *_2010*| sed -e...
Another way:
ls *_2010*| sed -e "p;s/_2010/_2014/"|xargs -n2 mv
1,176
Posted By Klashxx
In a oneliner: perl -ne 's/(\s*|\n)//g;print...
In a oneliner:
perl -ne 's/(\s*|\n)//g;print $_' inputfile
Inside a multiline script:
perl -e 's/(\s*|\n)//g && print $_ foreach (<>);' < inputfile
2,200
Posted By Klashxx
ok , use: file_avail=`ssh username@host 'if [[...
ok , use:
file_avail=`ssh username@host 'if [[ -f "directory/structure/Daily Report.xls" ]]; then echo 1; else echo 0; fi'`
Personally , i prefer:
ssh username@host 'if [[ -f "Daily Report.xls"...
1,725
Posted By Klashxx
Python re module maybe handy for that task: ...
Python re module maybe handy for that task:
echo "abcd fkaj&dsdsd;"|python -c 'import re;import sys;print re.escape(sys.stdin.read().strip()),'
2,715
Posted By Klashxx
As simply as: s= int(line[1])-1 In your...
As simply as:
s= int(line[1])-1
In your original script.
1,735
Posted By Klashxx
Try with this less verbose example: ...
Try with this less verbose example:
#!/usr/bin/env python
import sys
from decimal import Decimal
with open(sys.argv[1],'rb') as f:
for number in f:print str(Decimal(number))
About Python...
4,694
Posted By Klashxx
Try: scp -B -p...
Try:
scp -B -p ${Auser}@${aSrcHOST}:${aSrcDIR}/*.[Oo][Kk] $aTgtDIR
660
Posted By Klashxx
If perl is ok: perl -lane 'if...
If perl is ok:
perl -lane 'if (/Name:\s+(\S+)/){$group=$1};if(/^\s*(\d+)\s+(\S+)\s+(\S+)/i && $group){print $2.",".$3.",".$1.",".$group}' infile
1,907
Posted By Klashxx
Or: if [ "$ServerName" = "usei01" -o...
Or:
if [ "$ServerName" = "usei01" -o "$ServerName" = "usei02" -o "$ServerName" = "usei03" ]
1,056
Posted By Klashxx
The perl equivalent: perl -lane 'print $1 if...
The perl equivalent:
perl -lane 'print $1 if /(<a href[^>]*>)/' infile
Showing results 1 to 25 of 106

 

Featured Tech Videos

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