Hi
That is CMD problem, not Awk problem. You need to fix your quoting :
[ ] ╭─pair─╮ ╭───────pair────────╮
▼ ▼ ▼ ▼
awk -F, [highlight palegoldenrod]"{nvar="[/highlight]test[highlight palegoldenrod]"; print $1 nvar $2}"[/highlight] tt.txt
In...
Hi
Pretty sure it never worked exactly like that, as there is syntax error due to too many slashes ( / ).
Do not let yourself confused by the fact that both the s command and the regular expression address are using slashes as delimiters. They are completely separate things :
As they...
Hi
I would use an address to split the regular expression in 2 less complex ones :
address command
( in lines matching this ) ( do this )
╭────────────┴───────────╮ ╭──────────┴────────╮
sed '/^prod:admin:batch:daily:/ s/:server1$/:server2/'...
Hi
$1 needs no escaping as it has no special meaning. ( The placeholder for the 1st captured group is \1. )
& can be escaped by prefixing it with a backslash : \&.
So should be :
sed -i 's/# UserParameter=/UserParameter=systemd.unit.is-active,systemctl is-active --quiet $1 \&\& echo 1 ||...
Hi
There you concatenated the 3 field. print then out as separate fields. I mean, put comma ( , ) between them, so they get output with output field separator between them.
If you not want to change the separators, set the OFS ( output field separator ) to the same as FS ( field separator )...
Hi
Thinking again, would be simpler and faster with a for loop and substr() :
function comma(n , i)
{
for (i = index(n, ".") ? index(n, ".") - 3 : length(n) - 2; i > 1; i -= 2) {
n = substr(n, 0, i - 1) "," substr(n, i)
}
return n
}
Feherke.
feherke.github.io
Hi
There is nothing special. Let us rewrite it abit :
function comma(n , new_n)
{
new_n = gensub(/([[:digit:]])([[:digit:]]{3}$|[[:digit:]]{2},)/, "\\1,\\2", 1, n)
while (n != new_n) {
n = new_n
new_n = gensub(/([[:digit:]])([[:digit:]]{3}$|[[:digit:]]{2},)/...
Hi
For integers this should do it for any size :
function comma(n , nn)
{
while (n != nn = gensub(/([[:digit:]])([[:digit:]]{3}$|[[:digit:]]{2},)/, "\\1,\\2", 1, n)) {
n = nn
}
return n
}
For fractional part I did not got the rule.
Feherke.
feherke.github.io
Hi
Maybe my memories are failing, as I can not reproduce it right now, but I have a feeling that also met it with print when writing to file. But I would say on file/pipe input/output operations.
Feherke.
feherke.github.io
Hi
Dumb thing as according to operator precedence should be fine, but in reality you have to add parentheses :
awk 'BEGIN{
month=202303
print getline < ("file"month) <0 ? "Not Available" : "Available"
}'
Feherke.
feherke.github.io
Hi
Those are 2 different metacharacters :
. means any character
* means the previous entity 0 or more times
You can find them documented in the perlre manual's Metacharacters section.
Some examples :
'abc' =~ m/<.*>/ # not matches, presence of < and > is mandatory
'a><bc' =~ m/<.*>/ # not...
Hi
First of all, never user input data directly interpolated in SQL statement. That way you make your code vulnerable to SQL injection attacks. The Bobby Tables site explains the problem and the solution in simple terms.
Apparently there are user 2 completely different data access solutions...
Hi
Hard to understand what are you doing there.
In the 1st code how does the $message variable get its value ?
In the 2nd code how do the $date, $c_user, $to, etc variables get their values ?
Probably would be better to show us the code that is not working so we can tell what the problem is...
Hi
Yes, Perl is good for text processing, however it has a relatively steep learning curve.
A standup comedian's words about a girl applies to Perl too : "It's that kind of beauty which needs some accommodation".
Tried to write a script for your log file but after awhile I realized the format...
Hi
My relation with Mac was never good, so I may ask the dumbest thing now : is the GNU coreutils package available there ? Because if yes, then it has a right tool for you : csplit
csplit --digits=3 PoliceLog.txt '%^[0-9]%' '/^[0-9]/' '{*}'
For the first part of the file you attached, the...
Hi
There would be one thing to mention : in Perl there is a function like nowhere else(*), the wantarray. It tells to the function in which it is called whether the one which called it intends to assign its return value to an array or not.
In your original code, the value read from file was...
Hi
Because there you split() the filehandle itself, not the file content read from the filehandle.
my @configdata = <$configfile>;
( No idea what you tried with the split() there, so I skipped it. Reading from filehandle into array does the line splitting automatically. )
Feherke...
Hi
My previous post was too short and too confusing. Let me try again.
When the upload size exceeds post_max_size, a startup error is raised. It can not be stopped by ini_set('display_errors', false) and is too late for your script to stop it with ini_set('display_startup_errors', false). So...
Hi
To avoid abusively consuming the resources by uploading unacceptably huge files, that check is performed before preparing the files for processing by your script. So the error is generated automatically without a chance for the script to interfere.
Feherke.
feherke.github.io
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.