#!/usr/bin/perl # # mls This script will undo a lot of the percent-quoted mess from ls output. # # Author - Wayne Morrison tewok@tewok.com # # Revision History # 1.0 Initial version. 110418 # 1.1 Added licensing info. 180531 # # Written by Wayne Morrison, 4/18/11 # # Copyright 2011 Wayne Morrison # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # use strict; # # Version information. # my $NAME = "mls"; my $VERS = "$NAME version: 1.1"; my $outstr; my $ret; $ret = main(); exit($ret); #-------------------------------------------------------------------------- # Routine: main() # sub main { $outstr = `/bin/ls @ARGV`; $ret = $? >> 8; $outstr =~ s/%20/ /g; $outstr =~ s/%21/\!/g; $outstr =~ s/%23/\#/g; $outstr =~ s/%24/\$/g; $outstr =~ s/%26/\&/g; $outstr =~ s/%27/\'/g; $outstr =~ s/%28/\(/g; $outstr =~ s/%29/\)/g; $outstr =~ s/%2A/\*/g; $outstr =~ s/%2B/\+/g; $outstr =~ s/%2C/\,/g; $outstr =~ s/%2D/\-/g; $outstr =~ s/%2E/\./g; $outstr =~ s/%2F/\//g; $outstr =~ s/%3A/\:/g; $outstr =~ s/%3B/\;/g; $outstr =~ s/%3D/\=/g; $outstr =~ s/%3F/\?/g; $outstr =~ s/%40/\@/g; $outstr =~ s/%5B/\[/g; $outstr =~ s/%5D/\]/g; print "$outstr"; return($ret); } ############################################################################## =head1 NAME mls - list directory contents and translate percent codes in filenames =head1 SYNOPSIS mls <-ls options> <-ls arguments> =head1 DESCRIPTION B translates percent codes in filenames into their actual characters. This translation is for display only; the filenames are not changed in any way. B is a wrapper for the B command that translates percent codes in filenames into their actual characters. Percent codes are used to encode characters not allowed in such things as URLs. If a filename contains percent-coded characters, it can be difficult to make sense of the filename. B makes the following translations: Percent Code Character ------------ --------- %20 space " " %21 exclamation point "!" %23 pound, octothorpe "#" %24 dollar sign "$" %26 ampersand "&" %27 single quote "'" %28 left parenthesis "(" %29 right parenthesis ")" %2A asterisk "*" %2B plus sign "+" %2C comma "," %2D minus sign "-" %2E period "." %2F slash "/" %3A colon ":" %3B semicolon ":" %3D equals sign "=" %3F question mark "?" %40 at-sign "@" %5B left square bracket "[" %5D right square bracket "]" Percent codes are most often given in hexadecimal, which is the form used in the table above. There are additional percent codes that may be given, but this table lists the ones have been encountered by the author. Others will be added as needed. =head1 OPTIONS B takes no options of its own. However, any options or arguments given to B will be passed directly to B. =head1 AUTHOR Wayne Morrison, tewok@tewok.com =head1 LICENSE Copyright 2011 Wayne Morrison Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. =head1 SEE ALSO B