linux - 使用 grep 进行模式匹配

标签 linux shell unix scripting

<分区>

我有一个文件的完整路径 hai/hello/home/something/file.txt 。我怎样才能得到 file.txt 作为输出消除完整路径?

如何使用 grep 做到这一点?

最佳答案

#!/usr/bin/perl
use File::Spec;
use File::Basename;
$n="hai/hello/home/something/file.txt";
my $m = basename $n;
print "$m";

关于linux - 使用 grep 进行模式匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19152606/

相关文章:

linux - 如何打印索引为 24 的文件描述符总数

shell - 为什么从子进程通过 system() 或 execvp() 调用 cd shell 命令不起作用?

linux - Jenkins 执行 bash shell 命令

linux - Sh 脚本帮助 - 试卷评分

c - 为什么我们在 struct sockaddr_un 中仍然有 sun_family ?

c - AIX 中的 memmove_overlay 命令是什么?

linux - 循环内的 SED 命令

linux - 以访客用户身份登录时,如何以编程方式重启 Ubuntu?

c - POSIX 线程如何在 Linux 中工作?

shell - 是否可以在远程 ssh 命令中使用变量?