Search Results

Search: Posts Made By: ctrld
2,743
Posted By RudiC
Fine if that suits you. I was thinking you might...
Fine if that suits you. I was thinking you might want to perform further shell commands in the ifbranch...









Well, try if ! awk..., then. Or use the else branch...
2,743
Posted By RudiC
If "I am sure that pattern occurs only once" (per...
If "I am sure that pattern occurs only once" (per file, I presume), how about
if awk '/pattern/ {T[$2]++}; END {for (t in T) if (T[t] > 1) exit 1}' file[12]
then echo "Second column is not...
3,412
Posted By gandolf989
You can setup the following privileges. do a...
You can setup the following privileges. do a chmod on the first three directories as 755.
Then do a chmod on /var/spool/cron/root as 644 and you will have what you want.


$ ls -ld /var...
955
Posted By Don Cragun
The following produces the output you said you...
The following produces the output you said you want. (I don't understand why you want two digits after the decimal in the sum of field 2 since all of the input lines only have one digit after the...
955
Posted By Akshay Hegde
This may help you Input [akshay@localhost...
This may help you

Input
[akshay@localhost tmp]$ cat file
First Column Header |Second Column Header| Third Column Header| Fourth Column Header| Fifth Column Header
DATA1| 1.4|22.80| 6.6|6.55...
955
Posted By RavinderSingh13
Hello ctrld, Could you please try following...
Hello ctrld,

Could you please try following and let me know if this helps.

awk -F"|" 'NR==1{print;next} {print;Q=Q?Q FS ($2+$3+$4+$5):($2+$3+$4+$5)} END{print Q}' Input_file

Output will be...
1,163
Posted By Don Cragun
Here is a slightly different way to do it (which...
Here is a slightly different way to do it (which copies the results back into the 2nd input file if awk successfully processes the files). It should run slightly faster for files that contain...
1,163
Posted By RavinderSingh13
Hello ctrld, Could you please try following...
Hello ctrld,

Could you please try following and let me know if this helps you.

awk -vs1="<p><span style=\"color: #ff0000;\">" -vs2="</span></p>" -F"|" 'FNR==NR{A[$0]=$0;next} ($0 in...
5,155
Posted By RavinderSingh13
Hello ctrld, No, awk considers the...
Hello ctrld,

No, awk considers the difference between +5 and -5, offcourse if you will not put and +ve or -ve sign with any digit as per basic mathematics it will considered as a positive number,...
5,155
Posted By RavinderSingh13
Hello ctrld, As you had mentioned to take 5%...
Hello ctrld,

As you had mentioned to take 5% in positve and negative both ways so I had kept it, could you please try following and let me know then if this helps you.

awk '{if((Q=100-(($2 *...
5,155
Posted By RavinderSingh13
Hello ctrld, Could you please try following...
Hello ctrld,

Could you please try following and let me know if this helps you.

awk '{if((Q=100-(($2 * 100)/$3)) > 5 || Q <= -5){print Q, $0}}' Input_file


Thanks,
R. Singh
1,689
Posted By Aia
Functions should do one and preferable one thing...
Functions should do one and preferable one thing only. An indication that a function is doing too much is the amount of passed arguments that it has. Thus said, going along with your design choice of...
1,689
Posted By RudiC
Why don't you - create a function for the split...
Why don't you
- create a function for the split to be called from within any of the other functions
- split into an array and call the functions with that array
?
1,689
Posted By Aia
Would you be willing to post a few lines from the...
Would you be willing to post a few lines from the input text? Also, if you do not mind, could you show what any of those subfuncx functions do. What you have posted is not enough to provide a...
2,062
Posted By wisecracker
If you want a return code here you go... def...
If you want a return code here you go...
def EXIT(QUIT = "", RETCODE = 0):
if (QUIT == "q" or QUIT == "Q" or QUIT == ""):
exit(RETCODE)

print("Enter 'Q', 'q' or RETURN to QUIT at any...
2,062
Posted By wisecracker
I haven't done python since 2013 but here goes......
I haven't done python since 2013 but here goes...
def EXIT(QUIT = ""):
if (QUIT == "q" or QUIT == "Q" or QUIT == ""): exit()

print("Enter 'Q', 'q' or RETURN to QUIT at any time...")
name =...
2,062
Posted By wisecracker
I am not sure how you are going to shorten any...
I am not sure how you are going to shorten any prompts and also if this is what you are after:-
It looks like you are using pyhton2.6.x or higher...
OSX 10.7.5, default bash terminal using default...
1,994
Posted By Aia
>>> uris ...
>>> uris
'abc.de.fghijk.com:zyz.ab.fgfijk.com:abc.ef.fghijk.com'
>>> domains = uris.split(':')
>>> hostnames = [ x.split('.')[0] for x in domains ]
>>> hostnames
['abc', 'zyz', 'abc']
>>>

Of...
763
Posted By Aia
>>> a_dict['mydict'][1]['DATA1'] 'UK' >>>...
>>> a_dict['mydict'][1]['DATA1']
'UK'
>>> a_dict['mydict'][1]['DATA3']
'zscj27r87878r7jhdkjasdjksa'
>>>
31,732
Posted By Aia
subprocess is the module intended to be used...
subprocess is the module intended to be used instead of os.system

Maybe this might help:

import subprocess
import sys

host = 'myclient'
cmd = ['ping', '-c2', '-W 5', host ]
done = False...
31,732
Posted By cjcox
consider: import os, sys, time hostname...
consider:


import os, sys, time
hostname = "myclient"
response = os.system("ping -c 1 " + hostname + " >/dev/null 2>&1")

if response == 0:
print hostname, 'Reboot successful!'
...
2,189
Posted By Don Cragun
Actually, if you look at the 2nd, 3rd, and 4th...
Actually, if you look at the 2nd, 3rd, and 4th lines in your sample input:
NAME1 93MB 93KB
NAME2 25G 62K
NAME3 14G 873M
you'll see that you use both...
2,189
Posted By Don Cragun
Hi Ravinder, Nice script. Note, however,...
Hi Ravinder,
Nice script.

Note, however, that the line shown in red (which occurs a few times in your script isn't needed and can't be executed. Commands in a code block following a return...
2,189
Posted By RudiC
Try also (no error checking included): awk ' ...
Try also (no error checking included): awk '
BEGIN {ENG = "BKMGT"
for (i=split (ENG, UN, ""); i>0; i--) EXP[UN[i]]=i-1
}

function NBR(NUMSTR) ...
2,189
Posted By RavinderSingh13
Hello ctrld, If you need only row number and...
Hello ctrld,

If you need only row number and the percentage then following may help you in same.

awk 'function...
Showing results 1 to 25 of 55

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