Skip to content

Instantly share code, notes, and snippets.

View ovntatar's full-sized avatar

Ovidiu N. Tatar ovntatar

View GitHub Profile
@ovntatar
ovntatar / getModulePath.pl
Created January 9, 2014 13:53
Where is my Perl module installed?
perl -MGitHub::Jobs -e 'print $INC{"GitHub/Jobs.pm"}' or perldoc -l GitHub::Jobs
@ovntatar
ovntatar / Snippets.awk
Created December 17, 2013 14:54
AWK Snippets
#SED If a line begins with an [A-Z], append it to the previous line
$cat File
\z No
True at end of string only.
\Z No
True at end of string or before optional newline.
$sed -e :a -e '$!N;s/\n[A-Z]//;ta' -e 'P;D' File
@ovntatar
ovntatar / ShellSnippets.sh
Last active March 24, 2023 07:38
Shell Snippets
#!/bin/bash
#run task sequential
time for i in `seq 1 5`;do sleep 1; done
#run task in parallel
time for i in `seq 1 5`;do sleep 1 & done ; wait
@ovntatar
ovntatar / cmp.sh
Created December 17, 2013 14:47
Compare lines in the same file
#!/bin/bash
#Compare lines in the same file
while read A
do
read B
((i+=2))
[ "$A" != "$B" ] && echo "$A == $B Lines $((i-1)) and $i are different"
done < file1.txt
@ovntatar
ovntatar / telnet.sh
Last active December 31, 2015 15:19
# simple cisco equipment - telnet client
#!/bin/bash
# simple cisco equipment - telnet client - required IpList and commands files
echo "==============================="
echo " Please enter you pass! "
echo "==============================="
read -s -p "password: " pw
printf "%b" "\n"
cmd=`cat commands`
@ovntatar
ovntatar / ping.sh
Created December 17, 2013 14:42
simple icmp loop
#!/bin/bash
# simple icmp loop
while true
do
ping -w2 -s 1550 $1 > /dev/null
if [ $? -ne 0 ]:then
echo "--- icmp request failed -- $(date) ---" >> /var/log/icmp.log
fi
done < IPLIST
@ovntatar
ovntatar / DataStructure,pl
Created December 17, 2013 14:40
Tree data structure
#!perl
# Tree (PERL)
# ordering option -- Preorder - Inorder - Postorder
$tree=["Root", ["Grandma",["Mam",["Me"],["Brother"]],["Dad",["test"]],],];
sub FamRec {
my $Person=$_[0];
print "-".$$Person[0]."\n";
@ovntatar
ovntatar / Progressbar.sh
Created December 16, 2013 15:45
Shell progressbar ..
#!/bin/bash
searchfor="Hallo" # something to search for
tempfile="search.log" # temporary logfile
echo -n "Searching for $searchfor. "
grep -rl $searchfor / 2>/dev/null 1>>$tempfile &
@ovntatar
ovntatar / Counting_words.pl
Created December 16, 2013 15:14
Counting words in a file
#!perl
# perl script.pl < file.txt
use warnings;
use strict;
my %seen=();
while(<>) {
@ovntatar
ovntatar / lwp_callback.pl
Created December 16, 2013 11:31
LWP Callback
#!perl
use warnings;
use strict;
$|++;
use DDP;
use LWP;