shell: list_executable_file - 列出可执行文件的名称(linux)
2022/9/3 5:22:44
本文主要是介绍shell: list_executable_file - 列出可执行文件的名称(linux),对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
shell: list_executable_file - 列出可执行文件的名称(linux)
一、shell: list_executable_file
1 #!/usr/bin/bash 2 3 4 # file_name=list_executable_file 5 # function: list executable files in the current directory. 6 7 8 function list_executable_file() 9 { 10 count=0 11 echo 12 for file in $(ls) 13 do 14 if [ -x $file ] 15 then 16 echo "EXECUTABLE_FILE_$count: " $file 17 count=$(($count+1)) 18 fi 19 done 20 echo 21 } 22 23 24 list_executable_file
二、应用示例
1 [root@rockylinux tmp]# cat list_executable_file 2 #!/usr/bin/bash 3 4 5 # file_name=list_executable_file 6 # function: list executable files in the current directory. 7 8 9 function list_executable_file() 10 { 11 count=0 12 echo 13 for file in $(ls) 14 do 15 if [ -x $file ] 16 then 17 echo "EXECUTABLE_FILE_$count: " $file 18 count=$(($count+1)) 19 fi 20 done 21 echo 22 } 23 24 25 list_executable_file 26 [root@rockylinux tmp]# 27 [root@rockylinux tmp]# 28 [root@rockylinux tmp]# ls -l 29 total 268 30 -rwxr-xr-x 1 root root 23336 Sep 3 01:12 class_test 31 -rw-r--r-- 1 root root 635 Jul 10 14:25 class_test.cpp 32 -rw-r--r-- 1 root root 1859 Aug 30 14:36 data_pointer.cpp 33 -rw-r--r-- 1 root root 1169 Aug 25 01:17 data_structures_stack.cpp 34 -rw-r--r-- 1 root root 254 Jul 27 17:03 define_user.c 35 -rwx--x--x 1 root root 349 Sep 3 00:59 delete_exe 36 -rw-r--r-- 1 root root 349 Sep 3 00:59 delete_exe_backup 37 -rw-r--r-- 1 root root 1366 Sep 2 16:28 embed_structure.cpp 38 -rwxr-xr-x 1 root root 24016 Sep 3 01:12 enumeration_structure 39 -rw-r--r-- 1 root root 672 Sep 1 16:39 enumeration_structure.cpp 40 -rwx--x--x 1 root root 388 Sep 3 01:12 gpp 41 -rw-rw-rw- 1 root root 388 Sep 3 00:58 gpp_backup 42 -rw-r--r-- 1 root root 446 Jun 29 09:43 io_test.c 43 -rwx--x--x 1 root root 316 Sep 3 01:18 list_executable_file 44 -rw-r--r-- 1 root root 1129 Jul 3 12:47 macro_define.c 45 -rw-r--r-- 1 root root 20 Jul 11 15:34 minimal-test.c 46 -rw-r--r-- 1 root root 2932 Aug 30 17:42 mix_data_structure.cpp 47 -rw-r--r-- 1 root root 814 Sep 2 19:26 multiple_pointer.c 48 -rw-r--r-- 1 root root 825 Sep 2 18:45 multiple_pointer.cpp 49 -rwxr-xr-x 1 root root 28608 Sep 3 01:12 multiple_time_pointer 50 -rw-r--r-- 1 root root 1399 Sep 2 22:25 multiple_time_pointer.cpp 51 -rw-r--r-- 1 root root 41230 Jun 29 08:23 mysql_h.txt 52 -rw-r--r-- 1 root root 1592 Aug 31 02:14 object_overload_operator.cpp 53 -rwxr-xr-x 1 root root 23112 Sep 3 01:12 parameter_function 54 -rw-r--r-- 1 root root 1131 Aug 30 14:46 parameter_function.cpp 55 -rw-r--r-- 1 root root 605 Jul 11 13:20 pid_test.c 56 -rw-r--r-- 1 root root 2605 Jul 1 14:47 pointer_array.c 57 -rw-r--r-- 1 root root 539 Jun 29 08:54 pointer_charactor_array_test.c 58 -rw-r--r-- 1 root root 553 Sep 1 17:32 pointer_double.c 59 -rw-r--r-- 1 root root 592 Sep 1 17:42 pointer_double.cpp 60 -rw-r--r-- 1 root root 446 Jul 11 13:41 print_test.c 61 -rw-r--r-- 1 root root 606 Jun 29 09:44 read_file.c 62 -rw-r--r-- 1 root root 731 Aug 30 18:58 reference.cpp 63 -rw-r--r-- 1 root root 337 Jul 1 14:36 setjmp.c 64 -rw-r--r-- 1 root root 868 Jun 29 09:22 string_test.cpp 65 -rw-r--r-- 1 root root 156 Jul 11 13:23 template.c 66 [root@rockylinux tmp]# 67 [root@rockylinux tmp]# 68 [root@rockylinux tmp]# ./list_executable_file 69 70 EXECUTABLE_FILE_0: class_test 71 EXECUTABLE_FILE_1: delete_exe 72 EXECUTABLE_FILE_2: enumeration_structure 73 EXECUTABLE_FILE_3: gpp 74 EXECUTABLE_FILE_4: list_executable_file 75 EXECUTABLE_FILE_5: multiple_time_pointer 76 EXECUTABLE_FILE_6: parameter_function 77 78 [root@rockylinux tmp]# 79 [root@rockylinux tmp]#
这篇关于shell: list_executable_file - 列出可执行文件的名称(linux)的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-12-18git仓库有更新,jenkins 自动触发拉代码怎么配置的?-icode9专业技术文章分享
- 2024-12-18Jenkins webhook 方式怎么配置指定的分支?-icode9专业技术文章分享
- 2024-12-13Linux C++项目实战入门教程
- 2024-12-13Linux C++编程项目实战入门教程
- 2024-12-11Linux部署Scrapy教程:新手入门指南
- 2024-12-11怎么将在本地创建的 Maven 仓库迁移到 Linux 服务器上?-icode9专业技术文章分享
- 2024-12-10Linux常用命令
- 2024-12-06谁看谁服! Linux 创始人对于进程和线程的理解是…
- 2024-12-04操作系统教程:新手入门及初级技巧详解
- 2024-12-04操作系统入门:新手必学指南