Search Results

Search: Posts Made By: drewk
4,895
Posted By drewk
It is not a given that Perl will be any faster...
It is not a given that Perl will be any faster than Awk. In most cases it won't be.

Here is a code snippet that will get you started with multi-line records from a file:


#!/usr/bin/env perl
...
4,994
Posted By drewk
I guess that is why I am having a heck of a time...
I guess that is why I am having a heck of a time creating it huh? :o
4,994
Posted By drewk
How would I create a NULL terminated file in Unix under Bash?
I am testing some file routines against potential "nasty name" Unix files, such as those with a CR, LF, in the middle or NULL terminated, utf multi-byte character. So, under Bash, I want some way of:...
1,323
Posted By drewk
With 50,000 files and a minimum of 66 fields, you...
With 50,000 files and a minimum of 66 fields, you might want to think about optimization. Perl running the same algorithm as awk will not be faster, and may be slower. However, with Perl, you would...
9,684
Posted By drewk
Here are some examples: You keep data in...
Here are some examples:


You keep data in files that are written each day and named that day. You want to access a file that is -1 day or some other number of days from today...
Your script is...
1,601
Posted By drewk
That works! :b:
That works! :b:
1,601
Posted By drewk
One liner that does not change the input order ...
One liner that does not change the input order

perl -nle 'if (/^\d+/) { push @nums, $_; } else { push @oth, $_; } END { for $i (0..($#nums<=$#oth ? $#nums : $#oth)) { print "$nums[$i].$oth[$i]";...
16,746
Posted By drewk
So why do all 19 files need to be open if you are...
So why do all 19 files need to be open if you are processing 1 file at a time?

Do you have simple logic and maybe the Perl experts here can help? ie, present pseudo code of what you want to do,...
16,746
Posted By drewk
What is it you want to do with the 19 files?
What is it you want to do with the 19 files?
16,746
Posted By drewk
Do all 19 need to be open simultaneously? Can you...
Do all 19 need to be open simultaneously? Can you revisit your algorithm or what you are trying to do? Since ultimately the results of your 19 file handles are ending up in memory (with your...
5,276
Posted By drewk
Ahh solaris -- It is not your Bash at all; it is...
Ahh solaris -- It is not your Bash at all; it is your version of awk.

On Sun, try `nawk` vs `awk`

So try:
eval $(nawk -F'[()]' '/Total:/{split($2,a,",| ");print a[2]"="a[1]";"a[5]"="a[4]}'...
5,276
Posted By drewk
Alister usually gets it right, and glad that...
Alister usually gets it right, and glad that works. :cool:

Curious why you get a Bash error tho for the other awk / eval solution -- what platform and Bash version?
5,276
Posted By drewk
This works beautifully... :) Here is a test...
This works beautifully... :)

Here is a test and example:

$ cat test_text.txt
Nr of active alarms are: 16...
3,212
Posted By drewk
Be aware that Comma Separated Value "CSV" is far...
Be aware that Comma Separated Value "CSV" is far more complex in practice than simple test cases often suggest. This applies to Perl, Awk, whatever regex or parsing tool you are using.

If you are...
3,212
Posted By drewk
The Perl operator split will split fields on...
The Perl operator split will split fields on whitespace or any other regular expression in one go.

Here (http://perldoc.perl.org/functions/split.html) is the documentation for that. (Or $ perldoc...
9,582
Posted By drewk
Alister you are the sh glob god. :)
Alister you are the sh glob god. :)
3,212
Posted By drewk
Change the single quotes ' ' in option 2 to...
Change the single quotes ' ' in option 2 to double quotes " "

In Perl, no variable interpolation takes place inside single quotes but does in double quotes. In single quotes, open is trying to...
9,582
Posted By drewk
First create the fixed header and tail files...
First create the fixed header and tail files (text in my case, HTML in your case...)

$ echo "I am the header" > header.txt
$ echo "I am the tail" > tail.txt
$ cat header.txt
I am the header
$...
9,582
Posted By drewk
If I am understanding you correctly, you have: ...
If I am understanding you correctly, you have:

1) A header file that contains HTML code that you wish to prepend to:

2) A series of 1,000 files that have text in them followed by:

...
Forum: Ubuntu 04-28-2010
4,402
Posted By drewk
:b:
:b:
Forum: Ubuntu 04-27-2010
4,402
Posted By drewk
I have to agree with you. The desktop wars are...
I have to agree with you. The desktop wars are long over. News from the front: Windows won.

Unless there is a spectacular advantage, most users will not switch. The Gnome folks seem to be bent on...
Forum: Ubuntu 04-26-2010
4,402
Posted By drewk
Thanks. Not the answer I wanted, but at least I...
Thanks. Not the answer I wanted, but at least I was not crazy for not finding that!

Note to Nautilus developers: that function is needed...
2,644
Posted By drewk
Perl will do that. There is a '06' vs '0' and '6'...
Perl will do that. There is a '06' vs '0' and '6' in your data. The code below sorts the '06' with the '0' and not the '6' but this is easily changed.

#!/usr/bin/perl

while(<DATA>) {
...
Forum: Ubuntu 04-26-2010
4,402
Posted By drewk
Ubuntu / Ubuntu File Manager / Config
I am using Ubuntu 9.10 with Gnome 2.28.

I use the default Nautilus File Manager to view / manage files.

Is there a way to add icons or customize the icons that are above the location bar and...
35,492
Posted By drewk
Well kinda, but no, this is incorrect in some...
Well kinda, but no, this is incorrect in some ways.

A struct adds labels to a group of related data in C. The group of data usually corresponds to a single record of structured data of some type,...
Showing results 1 to 25 of 100

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