Search Results

Search: Posts Made By: getmmg
3,984
Posted By getmmg
$ perl -lane '$k1="$F[0] $F[1] $F[2]";$k2="$F[0]...
$ perl -lane '$k1="$F[0] $F[1] $F[2]";$k2="$F[0] $F[2] $F[1]";$h{$k1}+=0 if !(exists $h{$k1} || exists $h{$k2}) }{print foreach keys %h' inputfile
3,262
Posted By getmmg
perl -0pe 's/\n;/;/g' input
perl -0pe 's/\n;/;/g' input
899
Posted By getmmg
How about this use strict; print...
How about this


use strict;
print "Enter File Name: ";
my $fileName = <STDIN>;
chomp($fileName);
print "Enter Number: ";
my $no = <STDIN>;
chomp($no);
if(-e $fileName)
{
...
4,467
Posted By getmmg
-0lne reads the whole file. s/\n//g replaces...
-0lne reads the whole file.
s/\n//g replaces all new line charecters and makes it into a single line.

print "$1\n" while /(.*?{})/g' this will try to do a minimalistic pattern match for any...
4,467
Posted By getmmg
If {} marks the end of line, try this ...
If {} marks the end of line, try this


perl -0lne 's/\n//g;print "$1\n" while /(.*?{})/g' input file.
2,059
Posted By getmmg
Try this perl -pe 's/(.+HD)\/.*/\1/'
Try this

perl -pe 's/(.+HD)\/.*/\1/'
16,370
Posted By getmmg
Remove the chomp part. $input = <STDIN>; ...
Remove the chomp part.
$input = <STDIN>;
then if ($input =~ /\n/) should work.
18,870
Posted By getmmg
Is this what you are looking for Input: this...
Is this what you are looking for
Input:
this is test
one
two
three
four
two
one
end of file


"one" is the search string here.

Code:
perl -0ne 'print $1 if /one(.*)one/sg' test
...
5,751
Posted By getmmg
Try this Insert ^M by using ^v and ^M perl...
Try this Insert ^M by using ^v and ^M

perl -0ne 'print "Control Chars found in $ARGV" if /^M/g' txt.txt
1,735
Posted By getmmg
Try this perl -lane...
Try this

perl -lane '$hash{$F[0]}+=$F[1];END{print "$_\t$hash{$_}" for keys %hash}' input
2,367
Posted By getmmg
perl -lne 'print /\/(\w+\.html)/g' temp.txt
perl -lne 'print /\/(\w+\.html)/g' temp.txt
3,591
Posted By getmmg
Unilearn, Anyways i dont have work now, so...
Unilearn,

Anyways i dont have work now, so here it goes :)

-lane reads the file line by line, -a splits the line and store array @F.
Read perldoc to get more on this.
...
3,591
Posted By getmmg
Indeed. Nice way to do it. ---------- Post...
Indeed. Nice way to do it.

---------- Post updated at 01:13 PM ---------- Previous update was at 01:06 PM ----------




This should fix that.


perl -lane...
3,591
Posted By getmmg
Try this. Here the output also will tab...
Try this. Here the output also will tab separated. Change \t to any other delimiter if you dont want tab separated output.

perl -lane...
2,355
Posted By getmmg
How about this df -h | perl -ne 'print...
How about this


df -h | perl -ne 'print if (/(\d+)%/ && $1>70)'
2,623
Posted By getmmg
This will print only the numbers you are expected...
This will print only the numbers you are expected to see.
As per your input it should print 97 twice.
From there its fairly easy to do the calculation yourself.


perl -0lne...
3,330
Posted By getmmg
#=> GMT+11 is the comment part. If you want to...
#=> GMT+11 is the comment part. If you want to change the actual time zone change it like this


@time=gmtime(time +(11*3600)); #=> GMT +11


Also you dont the shell scripts.

Just run...
3,330
Posted By getmmg
This should do it, replace the perl part in your...
This should do it, replace the perl part in your code.


perl -e '
use POSIX qw(strftime);
use Time::Local;
@inp = split(/-/,$ARGV[0]);
$epochTime = timegm(0,0,0,$inp[2],$inp[1],$inp[0]);...
2,470
Posted By getmmg
Hi, Can you post the the code which gives...
Hi,

Can you post the the code which gives the output as shown above.
20,330
Posted By getmmg
perl -0ane...
perl -0ane 'BEGIN{$cols=3;$k=0}END{foreach(@F){$j=sprintf("%03d",++$k);$hash{$j}.= "$_\t";$k=0 if($k == (($#F+1)/$cols))}; for (sort keys %hash){chop($hash{$_});print "$hash{$_}\n"}}' inp
4,033
Posted By getmmg
This should print them line by line. perl...
This should print them line by line.

perl -F// -lane 'BEGIN{$"=":"} push(@arr,unpack("H*",$_)) for @F; print "@arr"; @arr=()' ascii

If you want the o/p in a file, Redirect it using >.
20,330
Posted By getmmg
Problem happened when it was getting sorted. It...
Problem happened when it was getting sorted. It sorts row 1,10...19,then 2,3 etc.,

I have added formatting for rows to fix that

Hope this code will your issue.

perl -0ane...
3,078
Posted By getmmg
perl -F'\\' -lane 'for (@F){print $_ .":". length...
perl -F'\\' -lane 'for (@F){print $_ .":". length $_ if($_)}' names

Output:

folder name :12
folder1 :9
folder2 :9
folder3 :9
folder4:8
folder name :12
very long folder name :23
...
3,325
Posted By getmmg
Columns will be in the order of how the file are...
Columns will be in the order of how the file are given.


perl -lane '$hash{$F[1]}.=" $F[8]";END{print "$_ $hash{$_}" for keys %hash}' file1 file2


And the output is

ab2 0.0007...
1,685
Posted By getmmg
This snippet below should do the job for you.. ...
This snippet below should do the job for you..


perl -ane 'BEGIN{@arr=("1234","5678","91011","1213");$i=0;$total=scalar(@arr)-1;$str} if($_=~/\/(\w+\-\w+\-\w+\-\w+\-\w+)/)
{if($curr ne...
Showing results 1 to 25 of 29

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