Search Results

Search: Posts Made By: getmmg
4,104
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
937
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)
{
...
3,411
Posted By getmmg
perl -0pe 's/\n;/;/g' input
perl -0pe 's/\n;/;/g' input
4,701
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,701
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.
5,892
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
2,199
Posted By getmmg
Try this perl -pe 's/(.+HD)\/.*/\1/'
Try this

perl -pe 's/(.+HD)\/.*/\1/'
16,563
Posted By getmmg
Remove the chomp part. $input = <STDIN>; ...
Remove the chomp part.
$input = <STDIN>;
then if ($input =~ /\n/) should work.
19,127
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
...
1,836
Posted By getmmg
Try this perl -lane...
Try this

perl -lane '$hash{$F[0]}+=$F[1];END{print "$_\t$hash{$_}" for keys %hash}' input
3,812
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.
...
2,483
Posted By getmmg
perl -lne 'print /\/(\w+\.html)/g' temp.txt
perl -lne 'print /\/(\w+\.html)/g' temp.txt
3,812
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,812
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,661
Posted By getmmg
How about this df -h | perl -ne 'print...
How about this


df -h | perl -ne 'print if (/(\d+)%/ && $1>70)'
2,731
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,496
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,496
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]);...
20,864
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
2,564
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.
4,184
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,864
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,209
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,484
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...
12,450
Posted By getmmg
Oops!!.. This should work. perl -le...
Oops!!..
This should work.


perl -le 'foreach(@ARGV){if($_ =~/\$/){$a =$_; $a=~s/\$/\\\$/g;$_=~s/\$//g; print `mv $a $_`}}' *
Showing results 1 to 25 of 29

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