首页 > 系统相关 >shell: list_executable_file - 列出可执行文件的名称(linux)

shell: list_executable_file - 列出可执行文件的名称(linux)

时间:2022-09-03 01:33:06浏览次数:64  
标签:executable shell -- list rw file root

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]# 

 

标签:executable,shell,--,list,rw,file,root
From: https://www.cnblogs.com/lnlidawei/p/16651821.html

相关文章

  • Java集合---ArrayList
    集合和数组的区别共同点:都是存储数据的容器 不同点:数组的容量是固定的,集合的容量是可变的ArrayList的构造方法和添加方法publicArrayList()创建一个空......
  • but GITEE.COM does not provide shell access
    butGITEE.COMdoesnotprovideshellaccess当使用ssh加公钥认证时在终端输入[email protected]首次使用需要确认并添加主机到本机SSH可信列表。若返回HiXXX!You......
  • 10_Linux基础-SHELL入门1
    @目录10_Linux基础-SHELL入门1一.输入输出重定向二.2个特殊文件三.heredocument四.tee命令五.清空文件内容六.SHELL入门SHELL的变量SHELL接收参数数据类型引号区别......
  • php exec 函数执行shell命令,中文参数异常的问题
    exec("/usr/local/bin/wkhtmltopdf--page-sizeA4--footer-font-nameFangSong--footer-line--header-font-size13--footer-font-size9--footer-center[page]--......
  • list底层实现
    list底层实现list和vector都是容器,只不过他们的存储结构不同,vector实际底层结构是顺序表,支持随机访问。list的底层结构带头双向链表,不支持随机访问。 但list的底层实现......
  • Shell 传递参数
    可执行文件loan_repay_check.sh其中有三个参数s_date,e_date,project_key如下:传入参数执行:shloan_repay_check.sh2022-03-022022-03-02lx8......
  • 04_Linux基础-.&..-cat-tac-重定向-EOF-Shell-more-ps-less-head-tail-sed-grep-which
    04_Linux基础-.&..-cat-tac->&>>-EOF-Shell-more-ps-less-head-tail-sed-grep-which-whereis-PATH-bash-/usr-locate-find一.回顾回顾// 将/home/目录下的所有文件和......
  • Delphi 经典游戏程序设计40例 的学习 例26 Image List 的实力与用法
     unitR26;interfaceusesWindows,Messages,SysUtils,Variants,Classes,Graphics,Controls,Forms,Dialogs,ExtCtrls,ImgList;typeTPatDt=rec......
  • java中List的详细用法
    目录:list中添加,获取,删除元素;list中是否包含某个元素;list中根据索引将元素数值改变(替换);list中查看(判断)元素的索引;根据元素索引位置进行的判断;利用list中索引位置重新生成......
  • 220902_leetcode 21. Merge Two Sorted Lists 合并两个有序链表(简单).md
    一、题目大意将两个升序链表合并为一个新的升序链表并返回。新链表是通过拼接给定的两个链表的所有节点组成的。示例1:输入:l1=[1,2,4],l2=[1,3,4]输出:[1,1,2,......