
Terminal - Commands using perl - 346 results
perl -MYAML -MJSON -0777 -wnl -e 'print YAML::Dump(decode_json($_))' package.json
This is sample output - yours may be different.
perl -MYAML -MJSON -0777 -wnl -e 'print YAML::Dump(decode_json($_))' package.json
This is sample output - yours may be different.
echo -n 023135 | perl -pe 's/([0-9a-f]{2})/chr hex $1/gie' | nc -4u -q1 -p5001 192.168.0.100 2000
This is sample output - yours may be different.
Use it to send raw data to a networked device. Used to interact with relay controller board whose documentation is lost, so use wireshark to sniff the sent data and replayed using the command.
perl -p -e 's/\$(\w+)/$ENV{$1}/g;' <files...>
This is sample output - yours may be different.
alarm() { perl -e 'alarm shift; exec @ARGV' "
[email protected]"; }; alarm 20 foo arg1
This is sample output - yours may be different.
$ time alarm 5 telnet 10.10.10.10
Trying 10.10.10.10...
Alarm clock
real 0m5.004s
user 0m0.002s
sys 0m0.003s
$
perl -Mojo -E 'say g("http://www.census.gov/popclock/data/population/world")->json->{'world'}{'population'};'
This is sample output - yours may be different.
logger -tdnsupdate $(curl -s 'https://dynamicdns.park-your-domain.com/
[email protected]&domain=xxx&password=xxx'|tee -a /root/dnsupdate|perl -pe'/Count>(\d+)<\/Err/;$_=$1eq"0"?"Update Sucessful":"Update failed"'&&date>>/root/dnsupdate)
This is sample output - yours may be different.
Aug 11 12:05:22 sync dnsupdate: Update Sucessful
convert_path2uri () { echo -n 'file://'; echo -n "$1" | perl -pe 's/([^a-zA-Z0-9_\/.])/sprintf("%%%.2x", ord($1))/eg' ;} #convert2uri '/tmp/a b' ### convert file path to URI
This is sample output - yours may be different.
$ convert_path2uri '/tmp/a/b c+d'
file:///tmp/a/b%20c%2bd
Really helpfull when play with files having spaces an other bad name. Easy to store and access names and path in just a field while saving it in a file.
This format (URL) is directly supported by nautilus and firefox (and other browsers)
perl -lne 'print unless $seen{$_}++'
This is sample output - yours may be different.
perl -le '$l=80;$l2="!" x $l;substr+($l2^=$l2),$l/2,1,"\xFF";{local $_=$l2;y/\0\xFF/ ^/;print;($lf,$rt)=map{substr $l2 x 2,$_%$l,$l;}1,-1;$l2=$lf^$rt;select undef,undef,undef,.1;redo}'
This is sample output - yours may be different.
^
^ ^
^ ^
^ ^ ^ ^
^ ^
^ ^ ^ ^
^ ^ ^ ^
^ ^ ^ ^ ^ ^ ^ ^
^ ^
^ ^ ^ ^
^ ^ ^ ^
^ ^ ^ ^ ^ ^ ^ ^
xmas lights for your terminal - switching the $l value to something like 1200 and zooming out on your terminal gives a great view ...
perl -e 'printf "%o\n", (stat shift)[2]&07777' file
This is sample output - yours may be different.
nohup tail /var/log/murmur.log | perl -ne '/^<.>[0-9:. -]{24}(\d+ => )?(.*)/; $pid=`pgrep -u murmur murmurd | head`; chomp $pid; `logger -p info -t "murmurd[$pid]" \\"$2\\"`;' &
This is sample output - yours may be different.
Sends log lines from murmur's (the mumble server's) logfile to syslog.
tail -F some.log | perl -ne 'print time(), "\n";' | uniq -c
This is sample output - yours may be different.
ps -e -m -o user,pid,args,%mem,rss | grep Chrome | perl -ne 'print "$1\n" if / (\d+)$/' | ( x=0;while read line; do (( x += $line )); done; echo $((x/1024)) );
This is sample output - yours may be different.
How much memory is chrome sucking?
pwd|grep -o '/'|perl -ne '$x.="./.";print`readlink -f $x`'|xargs -tn1 chmod 755
This is sample output - yours may be different.
chmod 755 /tmp/1/2/3
chmod 755 /tmp/1/2
chmod 755 /tmp/1
chmod 755 /tmp
`pwd` returns the current path
`grep -o` prints each slash on new line
perl generates the paths sequence: './.', './../.', ...
`readlink` canonicalizes paths (it makes the things more transparent)
`xargs -tn1` applies chmod for each of them. Each command applied is getting printed to STDERR.
for i in `gpg --list-sigs | perl -ne 'if(/User ID not found/){s/^.+([a-fA-F0-9]{8}).*/\1/; print}' | sort | uniq`; do gpg --keyserver-options no-auto-key-retrieve --recv-keys $i; done
This is sample output - yours may be different.
gpg: requesting key E8D80906 from hkp server keys.gnupg.net
gpg: key E8D80906: public key "Ayush Sharma <[email protected]>" imported
gpg: no ultimately trusted keys found
gpg: Total number processed: 1
gpg: imported: 1
gpg: requesting key EFFF0243 from hkp server keys.gnupg.net
gpg: key EFFF0243: public key "GSWoT:US10 (www.gswot.org)" imported
gpg: no ultimately trusted keys found
gpg: Total number processed: 1
gpg: imported: 1 (RSA: 1)
The original command doesn't work for me - does something weird with sed (-r) and xargs (-i) with underscores all over...
This one works in OSX Lion. I haven't tested it anywhere else, but if you have bash, gpg and perl, it should work.
curl http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html 2>/dev/null | grep '^<h3' | grep -v '^\d' | perl -pe 's/^.*(?<=(\d\d\d)) (.*)<\/h3>$/$1 : $2/' | grep -v h3
This is sample output - yours may be different.
100 : Continue
101 : Switching Protocols
200 : OK
201 : Created
202 : Accepted
203 : Non-Authoritative Information
204 : No Content
205 : Reset Content
206 : Partial Content
300 : Multiple Choices
301 : Moved Permanently
302 : Found
303 : See Other
304 : Not Modified
305 : Use Proxy
306 : (Unused)
307 : Temporary Redirect
400 : Bad Request
401 : Unauthorized
402 : Payment Required
403 : Forbidden
404 : Not Found
405 : Method Not Allowed
406 : Not Acceptable
407 : Proxy Authentication Required
408 : Request Timeout
409 : Conflict
410 : Gone
411 : Length Required
412 : Precondition Failed
413 : Request Entity Too Large
414 : Request-URI Too Long
415 : Unsupported Media Type
416 : Requested Range Not Satisfiable
417 : Expectation Failed
500 : Internal Server Error
501 : Not Implemented
502 : Bad Gateway
503 : Service Unavailable
504 : Gateway Timeout
505 : HTTP Version Not Supported
When you need a quick ref guide while troubleshooting Apache|NGINX error|access logs.
wget -q -O - http://listen.di.fm/public2 | sed 's/},{/\n/g' | perl -n -e '/"key":"([^"]*)".*"playlist":"([^"]*)"/; print "$1\n"; system("wget -q -O - $2 | grep -E '^File' | cut -d= -f2 > di_$1.m3u")'
This is sample output - yours may be different.
1.- Enter into the playlist path.
2.- Run the command.
3.- Playlists created!
FULLPATH=$(perl -e "use Cwd 'abs_path';print abs_path('$0');")
This is sample output - yours may be different.
]$ ls -l test.sh
-rwxr-xr-x 1 follier dev-user 78 Feb 01 14:05 test.sh
]$ ./test.sh
/home/follier/test.sh
]$ ls -l linktest.sh
lrwxrwxrwx 1 follier dev-user 12 Feb 01 14:07 linktest.sh -> /tmp/test.sh
]$ ./linktest.sh
/tmp/test.sh
Since none of the systems I work on have readlink, this works cross-platform (everywhere has perl, right?).
Note: This will resolve links.
perl -MModule::Name\ 9999 -e 1
This is sample output - yours may be different.
[email protected]:~$ perl -MMoose\ 9999 -e 1
Moose version 9999 required--this is only version 2.0604.
BEGIN failed--compilation aborted.
[email protected]:~$ perl -MModule::Name\ 9999 -e 1
Can't locate Module/Name.pm in @INC (@INC contains: /home/foo/perl5/lib/perl5/x86_64-linux-gnu-thread-multi /home/foo/perl5/lib/perl5/x86_64-linux-gnu-thread-multi /home/jon/perl5/lib/perl5 /etc/perl /usr/local/lib/perl/5.14.2 /usr/local/share/perl/5.14.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.14 /usr/share/perl/5.14 /usr/local/lib/site_perl .).
BEGIN failed--compilation aborted.
This attempts to load a Perl Module (-M flag) and use version 9999, since no module has a version this high, Perl exits either a) telling you the version of the module installed or b) tells you it can't find the module.
module_exists(){ perl -e 'use '$1 2>/dev/null; }
This is sample output - yours may be different.
$ module_exists diagnostics && echo yes || echo no
yes
$ module_exists beeblebrox && echo yes || echo no
no
This version uses a bash function and does not print the path to the module.
perl -MFile::Find=find -MFile::Spec::Functions -Tlwe '$found=1; find { wanted => sub { if (/$ARGV[0]\.pm\z/) { print canonpath $_; $found=0; } }, no_chdir => 1 }, @INC; exit $found;' Collectd/Plugins/Graphite
This is sample output - yours may be different.
/usr/local/share/perl5/Collectd/Plugins/Graphite.pm
find . | xargs perl -p -i.bak -e 's/oldString/newString/;'
This is sample output - yours may be different.
find . = will set up your recursive search. You can narrow your search to certain file by adding -name "*.ext" or limit buy using the same but add prune like -name "*.ext" -prune
xargs =sets it up like a command line for each file find finds and will invoke the next command which is perl.
perl = invoke perl
-p sets up a while loop
-i in place and the .bak will create a backup file like filename.ext.bak
-e execute the following....
's/ / /;' your basic substitute and replace.
perl -E 'say $_,`tput setb $_`," "x(`tput cols`-length("$_")),`tput sgr0` for 0..(`tput colors`-1)'
This is sample output - yours may be different.
Using perl and tput, show all the colors with numbers that your actual $TERM can handle.
If want to remove the numbers at beginning of new line, it should be something like this:
perl -E 'say `tput setb $_`," "x `tput cols`, `tput sgr0` for 0 .. (`tput colors` - 1)'
perl -E 'say$_%15?$_%3?$_%5?$_:Buzz:Fizz:Fizzbuzz for 1..100'
This is sample output - yours may be different.
1
2
Fizz
4
Buzz
Fizz
7
8
Fizz
Buzz
11
Fizz
13
14
Fizzbuzz
Just another FizzBuzz in Perl.