
Terminal - Commands using perl - 346 results
perl -e 'for (<*.mp3>) { $old = $_; s/ /-/g; rename $old, $_ }'
This is sample output - yours may be different.
#(see sample) $ cat x | perl -pe 'BEGIN{ print "TIME;...\n"; } s!(\S+) - (\S+) - \[(\d\d)/(\S\S\S)/(\S+):(\d\d):(\d\d:\d\d) \S+\] "(\S+) (.*/)(\S+)(?:\.([^?]*)(\?\S*)?) HTTP/\S+" (\d+) (\S+)!$3-$4-$5 $6:$7;$6;$2;$1;$8;$13;1;$14;$11;$10;$9;$12;!' > x.csv
This is sample output - yours may be different.
cat access.log | perl -pe 'BEGIN{ print "TIME;HOUR;USER;HOST;METHOD;STATUS;REQ;COST;TYPE;PAGE;PATH;QUERY\n"; } s!(\S+) - (\S+) - \[(\d\d)/(\S\S\S)/(\S+):(\d\d):(\d\d:\d\d) \S+\] "(\S+) (.*/)(\S+)(?:\.([^?]*)(\?\S*)?) HTTP/\S+" (\d+) (\S+)!$3-$4-$5 $6:$7;$6;$2;$1;$8;$13;1;$14;$11;$10;$9;$12;!' > access.csv
$ head access.log
93.57.16.194 - x2 - [07/Feb/2012:12:56:06 -0200] "GET /pmp/faces/jspx/MainWindow/Header.jspx HTTP/1.1" 200 0,010
93.57.16.194 - x2 - [07/Feb/2012:12:56:06 -0200] "GET /pmp/faces/jspx/MainWindow/Header/SearchDevice.jspx HTTP/1.1" 200 0,198
93.57.16.194 - x2 - [07/Feb/2012:12:56:06 -0200] "GET /pmp/faces/jspx/MainWindow/Panel.jspx HTTP/1.1" 200 0,012
$ head access.csv
TIME;HOUR;USER;HOST;METHOD;STATUS;REQ;COST;TYPE;PAGE;PATH;QUERY
07-Feb-2012 12:56:06;12;x2;93.57.16.194;GET;200;1;0,010;jspx;Header;/pmp/faces/jspx/MainWindow/;;
07-Feb-2012 12:56:06;12;x2;93.57.16.194;GET;200;1;0,198;jspx;SearchDevice;/pmp/faces/jspx/MainWindow/Header/;;
07-Feb-2012 12:56:06;12;x2;93.57.16.194;GET;200;1;0,012;jspx;Panel;/pmp/faces/jspx/MainWindow/;;
07-Feb-2012 12:56:06;12;x2;93.57.16.194;GET;200;1;0,024;jspx;WorkArea;/pmp/faces/jspx/MainWindow/Panel/;;
- excel date compatible with a separate hour field
- added a fixed 1 for easier request counter aggregation
- split URL in directory, filename, fileext, query
- used with tomcat valve with response bytes replaced by elapsed time
du -k | sort -n | perl -ne 'if ( /^(\d+)\s+(.*$)/){$l=log($1+.1);$m=int($l/log(1024)); printf ("%6.1f\t%s\t%25s %s\n",($1/(2**(10*$m))),(("K","M","G","T","P")[$m]),"*"x (1.5*$l),$2);}' | more
This is sample output - yours may be different.
4.0 K ** ./bin
4.0 K ** ./.config/gnome-main-menu
4.0 K ** ./.config/.mono/certs/Trust
4.0 K ** ./Desktop
4.0 K ** ./.fvwm
4.0 K ** ./.gconfd
4.0 K ** ./.gnome2/accels
4.0 K ** ./.gnome2/keyrings
4.0 K ** ./.gnome2/nautilus-scripts
4.0 K ** ./.gnome2_private
4.0 K ** ./.gnupg/private-keys-v1.d
4.0 K ** ./.kde/share/config
4.0 K ** ./.mozilla/firefox/9ikhdhm7.default/extensions
4.0 K ** ./netv/netvault/clientpackages
4.0 K ** ./netv/netvault/extrabkl
4.0 K ** ./netv/netvault/extrapackages
4.0 K ** ./.qt
4.0 K ** ./.skel
4.0 K ** ./.wapi
4.0 K ** ./.zenuser.gconf.defaults
4.0 K ** ./.zenuser.gconf.mandatory
8.0 K *** ./.config/.mono/certs
8.0 K *** ./Documents
8.0 K *** ./firefox/firefox/defaults/pref
8.0 K *** ./.gconf/apps/gnome-settings/gnome-panel
8.0 K *** ./.gconf/apps/nautilus/preferences
8.0 K *** ./.gconf/apps/panel/applets/clock_screen0/prefs
8.0 K *** ./.gconf/apps/panel/applets/main_menu_screen0
8.0 K *** ./.gconf/apps/panel/applets/mixer_screen0
8.0 K *** ./.gconf/apps/panel/applets/notification_area_screen0
8.0 K *** ./.gconf/apps/panel/applets/show_desktop_button_screen0
8.0 K *** ./.gconf/apps/panel/applets/tomboy_screen0
8.0 K *** ./.gconf/apps/panel/applets/window_list_screen0/prefs
8.0 K *** ./.gconf/apps/panel/general
8.0 K *** ./.gconf/apps/panel/global
8.0 K *** ./.gconf/apps/panel/toplevels/bottom_panel_screen0/background
8.0 K *** ./.gconf/desktop/gnome/accessibility/keyboard
8.0 K *** ./.gconf/desktop/gnome/background
8.0 K *** ./.gconf/desktop/gnome/peripherals/keyboard/host-posadm1/0
8.0 K *** ./.gconf/system/http_proxy
8.0 K *** ./.gconf/system/proxy
8.0 K *** ./.gnome2/share/cursor-fonts
8.0 K *** ./.gnome2/share/fonts
8.0 K *** ./.gnome/gnome-vfs
8.0 K *** ./.kde/share
8.0 K *** ./.nautilus/metafiles
8.0 K *** ./src/.tmp_versions
12.0 K *** ./.config/.mono
12.0 K *** ./firefox/firefox/defaults
12.0 K *** ./.gconf/apps/gnome-settings
12.0 K *** ./.gconf/apps/nautilus
12.0 K *** ./.gconf/desktop/gnome/accessibility
12.0 K *** ./.gconf/desktop/gnome/peripherals/keyboard/host-posadm1
12.0 K *** ./.kde
12.0 K *** ./.mozilla/firefox/9ikhdhm7.default/chrome
12.0 K *** ./.nautilus
12.0 K *** ./.thumbnails/fail/gnome-thumbnail-factory
16.0 K **** ./.gconf/apps/panel/applets/clock_screen0
16.0 K **** ./.gconf/apps/panel/applets/window_list_screen0
16.0 K **** ./.gconf/apps/panel/toplevels/bottom_panel_screen0
16.0 K **** ./.gconf/desktop/gnome/peripherals/keyboard
16.0 K **** ./netv/netvault/eula/Chinese/BIG5
16.0 K **** ./netv/netvault/eula/ChineseSimp/GB2312
16.0 K **** ./netv/netvault/eula/Korean/EUC-KR
16.0 K **** ./.thumbnails/fail
20.0 K **** ./firefox/firefox/chrome/icons/default
20.0 K **** ./.gconf/apps/panel/toplevels
20.0 K **** ./.gconf/desktop/gnome/peripherals
20.0 K **** ./.gconf/system
20.0 K **** ./.gnome2/share
20.0 K **** ./.kbd
20.0 K **** ./netv/netvault/eula/French/ISO-8859-1
20.0 K **** ./netv/netvault/eula/JapaneseEUC/EUC-JP
20.0 K **** ./.thumbnails
24.0 K **** ./firefox/firefox/chrome/icons
24.0 K **** ./firefox/firefox/extensions/{972ce4c6-7e08-4474-a285-3208198ce6fd}
24.0 K **** ./netv/netvault/eula/English
24.0 K **** ./netv/netvault/eula/German/ISO-8859-1
28.0 K ***** ./.config
28.0 K ***** ./firefox/firefox/chrome
28.0 K ***** ./firefox/firefox/extensions
28.0 K ***** ./firefox/firefox/searchplugins
28.0 K ***** ./.gnome
28.0 K ***** ./.gnupg
32.0 K ***** ./netv/netvault/eula/Chinese
32.0 K ***** ./netv/netvault/eula/ChineseSimp
36.0 K ***** ./.gnome2
40.0 K ***** ./firefox/firefox/icons
40.0 K ***** ./netv/netvault/eula/Korean
44.0 K ***** ./.gconf/desktop/gnome
44.0 K ***** ./netv/netvault/eula/French
44.0 K ***** ./zlmagent/data/locale/en_US/LC_MESSAGES
48.0 K ***** ./.gconf/desktop
48.0 K ***** ./.metacity/sessions
48.0 K ***** ./netv/netvault/eula/German
48.0 K ***** ./netv/netvault/eula/JapaneseEUC
48.0 K ***** ./.ssh
48.0 K ***** ./zlmagent/data/locale/en_US
52.0 K ***** ./.metacity
52.0 K ***** ./zlmagent/data/locale/pt_BR/LC_MESSAGES
56.0 K ****** ./zlmagent/data/locale/pt_BR
60.0 K ****** ./zlmagent/data/locale/de_DE/LC_MESSAGES
60.0 K ****** ./zlmagent/data/locale/es_ES/LC_MESSAGES
60.0 K ****** ./zlmagent/data/locale/fr_FR/LC_MESSAGES
64.0 K ****** ./.mozilla/firefox/9ikhdhm7.default/bookmarkbackups
64.0 K ****** ./zlmagent/data/locale/de_DE
64.0 K ****** ./zlmagent/data/locale/es_ES
64.0 K ****** ./zlmagent/data/locale/fr_FR
76.0 K ****** ./.gconf/apps/panel/applets
116.0 K ******* ./.gconf/apps/panel
124.0 K ******* ./zlmagent/readmes
144.0 K ******* ./.gconf/apps
148.0 K ******* ./squid-old
168.0 K ******* ./netv/netvault/serverpackages
168.0 K ******* ./zlmagent/data/configureScripts
184.0 K ******* ./.gstreamer-0.10
216.0 K ******** ./.gconf
232.0 K ******** ./firefox/firefox/components
260.0 K ******** ./zlmagent/data/eulas
272.0 K ******** ./netv/netvault/eula
300.0 K ******** ./zlmagent/data/locale
340.0 K ******** ./.vmware/VMware vCenter Converter Standalone/Logs
348.0 K ******** ./.vmware/VMware vCenter Converter Standalone
352.0 K ******** ./.vmware
624.0 K ********* ./firefox/firefox/dictionaries
1.4 M ********** ./zlmagent/data/packages/runtime-deps/sles-10-i586
1.4 M ********** ./zlmagent/data/packages/runtime-deps
1.6 M *********** ./zlmagent/data/packages/imaging/sles-10-i586
1.6 M *********** ./zlmagent/data/packages/imaging
1.9 M *********** ./src
1.9 M *********** ./.mozilla/firefox/9ikhdhm7.default/Cache
3.4 M ************ ./netv/netvault/packages
3.6 M ************ ./zlmagent/data/packages/sles-10-i586/sles-10-i586
3.6 M ************ ./zlmagent/data/packages/sles-10-i586
5.0 M ************ ./.mozilla/firefox/9ikhdhm7.default
5.0 M ************ ./.mozilla/firefox
5.0 M ************ ./.mozilla
5.9 M ************* ./scripts
14.0 M ************** ./zlmagent/data/packages/mono/sles-10-i586
14.0 M ************** ./zlmagent/data/packages/mono
24.9 M *************** ./netv/netvault
24.9 M *************** ./netv
25.9 M *************** ./zlmagent/data/packages/client/sles-10-i586
25.9 M *************** ./zlmagent/data/packages/client
28.4 M *************** ./firefox/firefox
46.5 M **************** ./zlmagent/data/packages
47.7 M **************** ./zlmagent/data
47.8 M **************** ./zlmagent
57.9 M **************** ./firefox
92.8 M ***************** ./acro
184.5 M ****************** ./servername-backup
437.2 M ******************* .
This one line Perl script will display the smallest to the largest files sizes in all directories on a server.
useradd -m -p $(perl -e'print crypt("passwordscelta", "stigghiola")') user
This is sample output - yours may be different.
The crypt function takes a password, key, as a string, and a salt character array which is described below, and returns a printable ASCII string which starts with another salt. It is believed that, given the output of the function, the best way to find a key that will produce that output is to guess values of key until the original value of key is found.
from http://en.wikipedia.org/wiki/Crypt_(Unix)
perl -i -ne 'print if $. == 3..5' <filename>
This is sample output - yours may be different.
> echo -e "1\n2\n3\n4\n5\n6\n" > aaa
> perl -i -ne 'print if $. == 3..5' aaa
> cat aaa
3
4
5
genRandomText() { perl -e '$n=shift; print chr(int(rand(26)) + 97) for 1..$n; print "\n"' $1;}
This is sample output - yours may be different.
If you don't have seq, you can use perl.
perl -p -i -e 's/.*\n//g if $.==2' ~/.ssh/known_hosts
This is sample output - yours may be different.
Easily removes line #2 in ~/.ssh/known_hosts.
perl -le 'print$_%3?$_%5?$_:"Buzz":$_%5?"Fizz":"FizzBuzz"for 1..100'
This is sample output - yours may be different.
comm -13 <(od -vw1 -tu1 dummy.txt|cut -c9-|sort -u) <(seq 0 127|sort)|perl -pe '$_=chr($_)'|od -c
This is sample output - yours may be different.
0000000 \0 001 \n j k \v \f z { | } ~ 177 \r 016 017
0000020 020 021 022 023 002 024 025 026 027 030 031 032 033 034 035 003
0000040 036 037 ! " # $ % & ' 004 ( ) * + ,
0000060 - . / 0 1 005 2 3 4 5 6 7 8 9 : ;
0000100 006 < = > ? @ A B C D E \a F G H I
0000120 J K L M N O \b P Q R S T U V W X
0000140 Y \t Z [ \ ] ^ _ ` a b c
0000154
Search in decimal rather than hex. od dumps the character list, cut to remove offsets, sort -u gives the used characters. seq gives the comparison list, but we need this sorted alphabetically for comm, which does the filtering. I drop to perl to convert back to characters (is there a better way?) and then use od to dump them in a print-safe format.
find . -type f|perl -lne '@x=sort {$b->[0]<=>$a->[0]}[(stat($_))[7],$_],@x;splice(@x,11);print "@{$x[0]}";END{for(@x){print "@$_"}'
This is sample output - yours may be different.
4833673216 ./Downloads/gnome-2.29.20091103-x86/gnome-2.29.20091103-x86.vmdk
A different approach to the problem - maintain a small sorted list, print the largest as we go, then the top 10 at the end. I often find that the find and sort take a long time, and the large file might appear near the start of the find. By printing as we go, I get better feedback. The sort used in this will be much slower on perls older than 5.8.
perl -e '$f = join("", <>); for (0..127) {$_ = chr($_); if (/[[:print:]]/) {print if index($f, $_) < 0}} print "\n"'
This is sample output - yours may be different.
Here's a perl version that only considers printable characters. Change the regex /[[:print:]]/ to look for different sets of delimiter characters.
This is sample output - yours may be different.
$ unidecode "\x{1D306}"
𝌆
$ unidecode "\x{00A9}\x{2122}\x{00AE}"
???
This is especially useful to get crazy stuff like space characters copied to your pasteboard correctly.
Source: https://github.com/mathiasbynens/dotfiles/blob/master/.functions
perl -ne 's/\^.{1,7}?m//g;print'
This is sample output - yours may be different.
Removes special characters (colors) in '^]]Xm' and '^]]X;Ym' format from file.
Use pipe ('input | perl [...]') or stream ('perl [...]
You can use 'cat -v infile' as 'input' to show special characters instead of interpreting (there is problem with non-ASCII chars, they are replaced by M-[char]).
cvs -Q status | perl -ne 'print if m/^File.+Status: (?!Up-to-date)/ .. m/^=/;'
This is sample output - yours may be different.
% cvs -Q status | perl -ne 'print if m/^File.+Status: (?!Up-to-date)/ .. m/^=/;'
File: Linux-rhel-5 Status: Needs Patch
Working revision: 1.68
Repository revision: 1.69 /home/myhome/project/software/scripts/steps/000-define-functions/Linux-rhel-5,v
===================================================================
File: Linux-rhel-6 Status: Needs Patch
Working revision: 1.20
Repository revision: 1.21 /home/myhome/project/software/scripts/steps/400-inittab/Linux-rhel-6,v
===================================================================
File: Linux-rhel-6 Status: Needs Patch
Working revision: 1.3
Repository revision: 1.4 /home/myhome/project/software/scripts/steps/451-snmp/Linux-rhel-6,v
===================================================================
This will also print the path to file which is not included in the other examples.
find . -iregex ".+\.\(c\|cpp\|h\)" | xargs -I{} perl -e "system(\"iconv -f SHIFT_JIS -t UTF-8 {} > temp; mv temp {} \");" ;
This is sample output - yours may be different.
lsmod | perl -e 'print "digraph \"lsmod\" {";<>;while(<>){@_=split/\s+/; print "\"$_[0]\" -> \"$_\"\n" for split/,/,$_[3]}print "}"' | dot -Tpng | display -
This is sample output - yours may be different.
parse `lsmod' output and pass to `dot' drawing utility then finally pass it to an image viewer
perl -MO=Deparse filename.pl | perltidy > new.pl
This is sample output - yours may be different.
This will create a new file with proper code formatting and all comments removed.
perl -le 'print scalar gmtime shift' 1234567890
This is sample output - yours may be different.
convert a unix timestamp to a human readable format.
perl -MExtUtils::Installed -E 'say for ExtUtils::Installed->new()->modules()'
This is sample output - yours may be different.
Algorithm::Diff
Algorithm::NaiveBayes
Alien::Judy
Alien::wxWidgets
Any::Moose
App::FatPacker
App::Nopaste
App::cpanminus
App::perlbrew
AppConfig
Archive::Any
Archive::Extract
Archive::Tar
Archive::Zip
Array::Diff
Array::Iterator
Array::RefElem
Async
Lists all the modules that were installed the "proper way". It also uses Perl 5.10(or higher)'s say command for less typing.
for f in $(ls -A ./dir); do echo -n $f && diff original.txt ./dir/$f | wc -l ; done | perl -ne 'my $h={}; while (<>) { chomp; if (/^(\S+?)\s*(\d+?)$/){$h->{$1}=$2;} }; for my $k (sort { $h->{$a} $h->{$b} } keys %$h ){ print "$k\t$h->{$k}\n"}'
This is sample output - yours may be different.
perl -ane 'END{printf(" %d %d %d\n", $x, $y, $z)} $x+=1;
[email protected]; $z+=length' file.txt
This is sample output - yours may be different.
perl -C -e 'print for sort { length $a <=> length $b or $a cmp $b } <>' < /usr/share/dict/words | tail
This is sample output - yours may be different.
making it "sound" more "natural" language like -- additionally sorting the longest words alphabetically:
this approach is using:
* to get at all lines of input
* post-"for" structure
* short-circuit-or in sort: if the lengths are the same, then sort alphabetically otherwise don't even evaluate the right hand side of the or
* -C sets all input and ouput channels to utf8
svn log | perl -pe 's/\n//g => s/^-.*/\n/g'
This is sample output - yours may be different.
dirrrty: use -p to chomp automatically, substitute all newlines away and then replace the "---" by a newline ? bingo!
s/// => s/// is just a cooler way to write s///, s/// which is just the small brother of s///; s/// (comma is an operator!)
have fun!
svn log | perl -l40pe 's/^-+/\n/'
This is sample output - yours may be different.
r14341 | bob | 2011-10-14 15:57:17 +0100 (Fri, 14 Oct 2011) | 1 line jack leave that alone
r14316 | jack | 2011-10-13 21:54:52 +0100 (Thu, 13 Oct 2011) | 1 line thing still broken
r14315 | jack | 2011-10-13 18:03:41 +0100 (Thu, 13 Oct 2011) | 1 line fixed the thing
r14307 | bob | 2011-10-13 15:49:29 +0100 (Thu, 13 Oct 2011) | 1 line made a thing
the output of svn log is annoying to grep, since it spreads the useful info over multiple lines. This compacts the output down to one line so eg you can grep for a comment and see the rev, date & committer straight away.
Updated: MUCH shorter, easier to remember. Now it just replaces newlines with spaces, except on '---' lines.
perl -MAcme::POE::Tree -e 'Acme::POE::Tree->new()->run()'
This is sample output - yours may be different.