Search notes:

Scripts: paths.pl and paths

paths

paths shows each path in $PATH on a separate line in a Unix shell.
#   vi: ft=sh
#
#   Pretty print value of $PATH:
#
#   Each componenent of PATH on its own line
#
tr : '\n' <<<$PATH
Github repository scripts-and-utilities, path: /paths

paths.pl

Since Windows does not come with tr, this Perl script does the same in cmd.exe (although it also works in Linux).
Additionally, the script can be passed the name of a file to be searched in %PATH%.
#!/usr/bin/perl
use warnings; use strict;

print "\n\n";

my $sep=':';
   $sep=';' if $^O eq 'MSWin32';

my @pathes = split /$sep/, $ENV{PATH};

my $executable_name = shift;

if (defined $executable_name) {
#
#   Search for executable name in pathes if it
#   was defined.
#

  for my $path(@pathes) {

    if (-e "$path/$executable_name") {

      print "file found: $path\\$executable_name\n";

    }

  }

  exit;
}

#  
#     Just print spaces if executable name is
#     not defined:
# 
print join "\n", @pathes;
print "\n";
Github repository scripts-and-utilities, path: /paths.pl

TODO

The file name for this page should not be pathes.
The page should possibly be merged with paths.ps1

See also

paths.ps1 is a similar script for PowerShell.
Other scripts

Index