Skip to content

Instantly share code, notes, and snippets.

@AndrewRussellHayes
AndrewRussellHayes / getOracleSolarisInfo.sh
Created May 29, 2014 14:55
Get SolarisSystem information
printf "System Info for CBM Servers\n\n" >> ~/SystemInformation.txt
printf "\nProduction\n\n" >> ~/SystemInformation.txt
printf "\nOS Release:\n" >> ~/SystemInformation.txt
cat /etc/release >> SystemInformation.txt
printf "\nHostname:\n" >> ~/SystemInformation.txt
hostname >> SystemInformation.txt
printf "\nIP Address:\n" >> ~/SystemInformation.txt
/usr/sbin/ifconfig -a | awk 'BEGIN { count=0; } { if ( $1 ~ /inet/ ) { count++; if( count==2 ) { print $2; } } }' >> SystemInformation.txt
printf "\n\nRAM Info\n" >> ~/SystemInformation.txt
@AndrewRussellHayes
AndrewRussellHayes / rmAdded.linux.sh
Last active August 29, 2015 14:00
remove .added extension from all files in directory
rename 's/\.added$//' *.added
git tag new old
git tag -d old
git push origin :refs/tags/old
git push --tags
@AndrewRussellHayes
AndrewRussellHayes / replacesSpaces.pl
Created November 20, 2013 20:45
replace spaces with underscores
my $variable =~ s/ /_/ig;
@AndrewRussellHayes
AndrewRussellHayes / removeLetter.pl
Created November 20, 2013 20:45
remove letter from entire string
my $variable =~ s/z//ig;
@AndrewRussellHayes
AndrewRussellHayes / perlRegexNotes.txt
Created November 20, 2013 20:43
perl regex notes
modes
/i makes the regex match case insensitive.
/s enables "single-line mode". In this mode, the dot matches newlines.
/m enables "multi-line mode". In this mode, the caret and dollar match before and after newlines in the subject string.
/x enables "free-spacing mode". In this mode, whitespace between regex tokens is ignored, and an unescaped # starts a comment.
Regular expressions
@AndrewRussellHayes
AndrewRussellHayes / searchString.pl
Created November 20, 2013 20:29
very basic string match
$sentence = "the boy is 20";
if($sentence =~ /the/)
{
print "true";
}
if($sentence =~ /Trhe/)
{
print "true"; #will return false
@AndrewRussellHayes
AndrewRussellHayes / matchEnd.pl
Created November 20, 2013 20:28
perl string matching with tail anchor
#!/usr/bin/perl
use strict;
use warnings;
# if the string ends in z regardless of case the below returns true
my $string = '"abcdefz"';
my $string2 = "abcefj";
my $last;
@AndrewRussellHayes
AndrewRussellHayes / PerlTemplate.pl
Last active December 28, 2015 22:19
General Perl template.
#!/usr/bin/perl -w
use strict;
use warnings;
#To view This Program's Documentation execute `perldoc programname.pl`
=head2 utilityName.pl
AUTHOR: Joe Developer
CREATION DATE:
@AndrewRussellHayes
AndrewRussellHayes / ModuleTemplate.pl
Last active December 28, 2015 22:19
Genera Perl module template.
#!/usr/bin/perl -w
package moduleName;
use strict;
use warnings;
#To view This Module's Documentation execute `perldoc modulename.pl`
=head2 module.pm
AUTHOR: Joe Developer