Search Results

Search: Posts Made By: MacMonster
1,997
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} =...
22,630
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')
{
...
1,736
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...
2,940
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,459
Posted By MacMonster
The triangle is 3D? Your coordinates have z-axis...
The triangle is 3D? Your coordinates have z-axis (x, y, z).
4,400
Posted By MacMonster
Replace the slashes with spaces. ...
Replace the slashes with spaces.


mydate="22/Oct/2011"
mydate_converted=`echo "$mydate" | sed 's/\// /g'`
mydate=`date -d "$mydate_converted" +%s`
5,996
Posted By MacMonster
Escape the dollar sign. \$* ) echo...
Escape the dollar sign.


\$* ) echo success ;
13,250
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...
2,549
Posted By MacMonster
You can directly use the variables from...
You can directly use the variables from ftp.properties. Parsing the file is not necessary. The code will look like this:


#!/bin/sh

. ftp.properties

ftp -vin >> ftp.log <<-!
open...
3,196
Posted By MacMonster
I use for loop in my script. It reads the data...
I use for loop in my script. It reads the data from the "users" command. Usernames are separated by a space, so "for" will treat it as a list of items. Then I compare each item in the list with the...
1,434
Posted By MacMonster
Without "-" or "+" in the "-mtime" option, it...
Without "-" or "+" in the "-mtime" option, it means EXTACT value. The "!" means NOT. Thus, the meaning of your original statement is to find any files which the last modified time are NOT EXACTLY two...
1,434
Posted By MacMonster
Your find command should rewrite to: find...
Your find command should rewrite to:


find $INDIR -type f -mtime -$DAYS -exec mv {} $OUTDIR \;
Forum: Programming 10-22-2011
3,853
Posted By MacMonster
It can be shorter. z += (z < 0 ? 2 : -2 )...
It can be shorter.


z += (z < 0 ? 2 : -2 ) * r * cos(theta);
3,196
Posted By MacMonster
"users" command would be the best choice as it...
"users" command would be the best choice as it only outputs the usernames without extra useless text.

Username may contain a dot that requires extra handling in regular expression, so I think use...
Forum: Programming 10-14-2011
17,020
Posted By MacMonster
You tried to copy the data to the address of the...
You tried to copy the data to the address of the pointer (&) which is not correct.

The code should be:


memcpy(finalptr + finaloffset, out, have);
15,125
Posted By MacMonster
Use "pre" tag in html to show your content. It...
Use "pre" tag in html to show your content. It will process the line breaks. Otherwise, you need to convert the "\n" to "<br>".

The code will look like this:


outputFile="sample.log"
( ...
Forum: Programming 10-06-2011
2,555
Posted By MacMonster
Thanks Mac! I seem understanding more of your...
Thanks Mac!
I seem understanding more of your code now, but not quite sure the exact algorithm. As a learner, I'd like to confirm your logic flow with my comment for the tricky part. If this is too...
Forum: Programming 09-28-2011
7,949
Posted By MacMonster
You can't pass an array to execute(). A normal...
You can't pass an array to execute(). A normal way to execute a statement is:


my $sth = $dbh->prepare($sql);
$sth->execute();
27,394
Posted By MacMonster
Just a reminder: Your command may fail with...
Just a reminder:

Your command may fail with "argument list too long" error if there is a lot of files in the directory.

A more fail safe way is:


find "/path" -maxdepth 1 -type f -name...
4,367
Posted By MacMonster
Simply pipe the output of "ls" to "sed". That is:...
Simply pipe the output of "ls" to "sed". That is:


ls -l BU/AD_*/ANTS*/SERVER/REJECT | sed '/^.*:$/{N;N;/\ntotal 0\n$/d;}'
4,367
Posted By MacMonster
sed is easier to perform multi-line matching. ...
sed is easier to perform multi-line matching.


sed '/^.*:$/{N;N;/\ntotal 0\n$/d;}'
Showing results 1 to 21 of 21

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