sed -ne '/<!--/ { :c; /-->/! { N; b c; }; /-->/s/<!--.*-->//g }; /^ *$/!p;'
You might consider stripping blanklines and/or filtering through xmllint
--format to make the xml pretty printed.
Sun, 14 Jan 2007Strip XML comments with sed
sed -ne '/<!--/ { :c; /-->/! { N; b c; }; /-->/s/<!--.*-->//g }; /^ *$/!p;'
You might consider stripping blanklines and/or filtering through xmllint
--format to make the xml pretty printed.
Comments: 2 (view comments)
Thu, 23 Mar 2006Site move soon, perhaps.
I'll be moving this site to my new domain as soon as I get things setup there. I won't bother disclosing the name at this point, seeing as how there's nothing there.
As a hint, however, I will say I came up with the name using this perl one-liner:
perl -Mre=eval -ne 'print if m/^s(.)(??{"[^$1]+$1"}){2}$/' words
(are your eyes bleeding, yet?)
That regex will find all valid sed substitution expressions in the file 'words' (freebsd's dictionary file). So, anything printed by that perl code will be valid as a sed command. ie: "streetlet" is valid as % echo "ree" | sed -e "streetlet" leI learned a new word in the process of running this script. syzygy Nothing quite like using perl to choose a domain name for you. Yeah, I'm a dork.
Comments: 1 (view comments)
Wed, 22 Feb 2006precedence sorting with perl's sort()
This isn't terribly complicated, but it may be useful to you. Mostly I'm putting it here for my own future reference.
sort { $users{$b} <=> $users{$a} || $a cmp $b } keys(%users)
This will sort first numerically by the values stored in %users and then by the keys of %users. This means that the return value of sort is the keys sorted by data values first, and then alphabetically when both data values are equal.
Comments: 0 (view comments)
Fri, 15 Oct 2004grep -R
Boredom + lacking grep with -R...
find ./ -type f | xapply -f 'grep "SOMESTRING" "%1" | sed -e "s!^!%1: !"' -
Comments: 0 (view comments)
Fri, 01 Oct 2004perl makes addition fun!
I like calculators...
perl -lne 'print $a+=$_'
Comments: 0 (view comments)
Thu, 05 Aug 2004happy perl obfuscation #425234569807
perl -e '$foo = "hello there"; $foo =~ /(?{chop}){4}/; print "$foo\n"'
Nuff said.
You may have to look up what (?{...}) does in
Comments: 0 (view comments)
Sun, 11 Jul 2004boredom + apache
Here's a silly oneliner that'll attempt to calculate per-file usage from an apache log.
awk '{print $7}' - | perl -e 'while (<>) { chomp; s!^/([^/]+)!/.html_pages!;
$u = $1; next if ($u !~ s/^~//); @a = getpwuid(getpwnam($u)); $_ = $a[7] . $_;
$f{$_} += (stat($_))[7] }; map { print $f{$_} . " $_\n" if ($f{$_}) } keys(%f)'
Reads the log data from stdin. Output is unsorted. I'd make it smaller but I'm lazy and tired.
Comments: 0 (view comments)
Wed, 23 Jun 2004Yet another random number generator
I was bored...
dd if=/dev/urandom bs=1 count=30 2> /dev/null | \
perl -e 'read(STDIN,$foo,5); print unpack("J",$foo) % 6 . "\n";'
Comments: 0 (view comments)
Sun, 20 Jun 2004Removing duplicates from arrays in Perl
After needing to do this in a project of mine, I went googling and found, as expected, a wide variety of solutions.
Solutions ranged from using map, foreach, grep, etc.. All using things like a temporary hash to count instances and ensure uniqueness - but I remembered that hashes have unique keys and that hashes are often treated the same way as arrays in perl, so my solution is as follows:
my %foo; #Temp var my @a = qw (hello there hello how are you today there what now hello hello hello); %foo = @a; @a = keys(%foo); I also have a one-liner version:
# Assumedly, @a is already defined and has stuff in it, perhaps...
@a = do { my %foo = @a; keys(%foo) };
Comments: 3 (view comments)
Mon, 29 Sep 2003<3 xapply.xapply 'ping -t 1 -c 1 %1 > /dev/null 2>&1; A=$?; echo -n "%1 - "; [ $A -eq 0 ] && echo "ONLINE" || echo "***DOWN***"' `cat hostlist`
Outputs: project1 - ONLINE mokey - ***DOWN*** boober - ONLINE wimbley - ONLINE doozer - ONLINE felix - ONLINE red - ***DOWN*** sprocket - ONLINE henchy - ONLINE falcon - ONLINE talon - ONLINE junior - ONLINE doc - ONLINE eagle - ***DOWN***
Comments: 0 (view comments)
|
Search this siteNavigation Page 1 of 2 [next]
MetadataHome About Resume My Code (SVN Web)ArticlesARP Security Dynamic DNS with DHCP OpenLDAP+Kerberos+SASL PPP over SSH SSH Security: /bin/false Week of Unix Tools Work EfficiencyProjectsfex firefox tabsearch firefox urledit grok keynav liboverride newpsm (FreeBSD) nis2ldap pam_captcha poor man's backup Solaris audio utility xboxproxy xdotool xmlpresenter xpathtool misc scriptsPresentationsYahoo! Hack Day '06 Unix Essentials Vi/Vim EssentialsTag CloudCalendar
FriendsBarCamp Kent Brewster Tantek Çelik John Resig Wesley Shields Tyler ShieldsTechnorati |
|||||||||||||||||||||||||||||||||||||||||||||||||