Search Results

Search: Posts Made By: MacMonster
1,824
Posted By MacMonster
Try this. #!/usr/bin/perl use...
Try this.


#!/usr/bin/perl

use List::Util qw(min max sum);

%d = ();

while (<STDIN>)
{
/\(Mid\) ([0-9]+),.*\(Val\) ([0-9.-]+)d/;
next if ($1 eq '' || $2 eq '');
$d{$1} =...
1,957
Posted By MacMonster
Please see the comments for explanation. ...
Please see the comments for explanation.


#!/usr/bin/perl

# This helps you to write better code and save time on debugging
use strict;
use warnings;

# Pass the command line argument(s) to...
22,259
Posted By MacMonster
The following code demonstrates a basic menu by...
The following code demonstrates a basic menu by using <STDIN> for reading input.


#!/usr/bin/perl

use strict;
use warnings;
use Switch;

my $input = '';

while ($input ne '6')
{
...
10,187
Posted By MacMonster
Still doesn't work? The later version should work...
Still doesn't work? The later version should work with aligned or non-aligned data as it uses continuous spaces as delimiter, so the spaces between the columns don't a matter.
1,566
Posted By MacMonster
Assume the input file is called "table2.sql". ...
Assume the input file is called "table2.sql".


sed -n 's/AUTO_INCREMENT[,]\?$//pI' < table2.sql > output.txt


It saves the output into a temp file called "output.txt". Then read it line by...
1,566
Posted By MacMonster
sed one liner. sed -n...
sed one liner.


sed -n 's/AUTO_INCREMENT[,]\?$//pI'
10,187
Posted By MacMonster
I used only one space to split the line. This...
I used only one space to split the line. This might caused the problem. Here is an improved version with formatted output.


#!/usr/bin/perl

use strict;
use warnings;

my $line = <STDIN>;...
2,780
Posted By MacMonster
The "-f" paramater only accepts a file with no...
The "-f" paramater only accepts a file with no extra arguments.

You may need to rewrite it as:


echo "/full_path_to/foo.sh bar abc " | at now


or create another wrapper script.
1,286
Posted By MacMonster
The triangle is 3D? Your coordinates have z-axis...
The triangle is 3D? Your coordinates have z-axis (x, y, z).
3,324
Posted By MacMonster
Print the date by incrementing UNIX timestamp. ...
Print the date by incrementing UNIX timestamp.


#!/bin/bash

function get_timestamp()
{
m=${1:0:2}
d=${1:2:2}
y=${1:4:4}
date -d "$m/$d/$y" +%s
}

inital_date="11012011"...
10,187
Posted By MacMonster
The following is a sample script. The output...
The following is a sample script. The output seems match what you want.


#!/usr/bin/perl

use strict;
use warnings;

my $line = <STDIN>;
chomp($line);
my @header_item = split(/ /, $line);...
2,677
Posted By MacMonster
Try with perl. perl -ne 'use POSIX;...
Try with perl.


perl -ne 'use POSIX; /^([0-9]+)-([0-9]+)-([0-9]+)-([0-9]{2})([0-9]{2})(.*)/; print mktime(0, $5, $4, $3, $2 - 1, $1 - 1900)."$6\n";' file
2,862
Posted By MacMonster
Try this: if (!defined($OPT{'p'})) {
Try this:


if (!defined($OPT{'p'})) {
10,530
Posted By MacMonster
getElementsByTagName() always return an array....
getElementsByTagName() always return an array. You need to determine the array size instead of checking the key exists or not.


my @node_list =...
Forum: Programming 11-04-2011
1,838
Posted By MacMonster
Array index starts from zero. You are trying to...
Array index starts from zero. You are trying to access thread[2].


for (i = 2; i > 0; i--)
Forum: Programming 11-03-2011
2,184
Posted By MacMonster
If you don't care about what language to use,...
If you don't care about what language to use, Perl would be much easier.


#!/usr/bin/perl

use POSIX;

$t = mktime(0, 0, 0, 1, 0, 96);
$i = 0x0076f676 * 60;
$s = strftime "%Y-%m-%d-%H-%M",...
2,447
Posted By MacMonster
You can set the sender address by "-f". That is: ...
You can set the sender address by "-f". That is:


eval $MTA -f "$4" "$3"
1,467
Posted By MacMonster
Not much simpler, just saves some duplicated...
Not much simpler, just saves some duplicated code.


$dateformat = 'yyyy_mm_dd';
$fmt = ($dateformat =~ m/yyyy/i) ? '%Y' : $dateformat =~ m/yy/i ? '%y' : '';

if ($fmt ne '')
{
print...
5,760
Posted By MacMonster
Escape the dollar sign. \$* ) echo...
Escape the dollar sign.


\$* ) echo success ;
2,059
Posted By MacMonster
The mailertable...
The mailertable (http://www.sendmail.org/m4/mailertables.html) feature may be your need. It routes a domain to a specified host or IP.

Your content will look like this:


catbiscuits.com ...
22,900
Posted By MacMonster
I think this option is not available in HP-UX. It...
I think this option is not available in HP-UX. It is OK in Linux.
22,900
Posted By MacMonster
Use "-iname" option for case-insensitive match. ...
Use "-iname" option for case-insensitive match.


find . -type f -iname "*.sql"
1,731
Posted By MacMonster
Notepad is be a better choice than Wordpad. I...
Notepad is be a better choice than Wordpad. I remember Wordpad saves the file as RTF by default. You need to manually change the file type to .txt when saving.

Shell script usually uses ".sh"...
10,904
Posted By MacMonster
You already put the content lines of the file...
You already put the content lines of the file into an array, so you can use the array index to display the line number. Using an extra counter is not necessary. Please see the comments in the code...
3,531
Posted By MacMonster
Why don't store the metadata in a file/db in the...
Why don't store the metadata in a file/db in the file system?
Showing results 1 to 25 of 73

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