Created
October 21, 2021 15:10
-
-
Save avli/981702aee5a399c6e4a1c38d047c2a86 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/use/bin/env perl | |
use strict; | |
# Usage: | |
# ls -l <path> | perl lsbasename.pl | |
while (<STDIN>) { | |
chomp; | |
my $original = $_; | |
my @chunks = split / /; | |
my $fullpath = $chunks[-1]; | |
my $basename = (split /\//, $fullpath)[-1]; | |
$original =~ s/$chunks[-1]/$basename/; | |
print $original . "\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment