File tree Expand file tree Collapse file tree 3 files changed +71
-25
lines changed Expand file tree Collapse file tree 3 files changed +71
-25
lines changed Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+
3
+ # Check if a directory is provided as an argument
4
+ if [ -z " $1 " ]; then
5
+ echo " Usage: $0 <directory>"
6
+ exit 1
7
+ fi
8
+
9
+ # Directory to search
10
+ directory=$1
11
+
12
+ # Find ELF files in the specified directory
13
+ files=$( find " $directory " -type f -exec sh -c ' file -b "$1" | grep -q "ELF" && echo "$1"' _ {} \; )
14
+
15
+ # Initialize an empty string for the output
16
+ output=" "
17
+
18
+ # Loop through each file and format it
19
+ for file in $files ; do
20
+ if [ -z " $output " ]; then
21
+ output=" \" $file \" "
22
+ else
23
+ output=" $output ,\" $file \" "
24
+ fi
25
+ done
26
+
27
+ # Print the formatted output
28
+ echo $output
Original file line number Diff line number Diff line change 1
1
#! /bin/bash
2
2
3
- # Check if a directory is provided as an argument
4
- if [ -z " $1 " ]; then
5
- echo " Usage: $0 <directory>"
6
- exit 1
7
- fi
3
+ # Detect the operating system
4
+ os_type=$( uname)
8
5
9
- # Directory to search
10
- directory=$1
11
-
12
- # Find ELF, Mach-O and Universal Binary files in the specified directory
13
- files=$( find " $directory " -type f -exec sh -c ' file -b "$1" | grep -q "ELF|Mach-O|universal binary" && echo "$1"' _ {} \; )
14
-
15
- # Initialize an empty string for the output
16
- output=" "
17
-
18
- # Loop through each file and format it
19
- for file in $files ; do
20
- if [ -z " $output " ]; then
21
- output=" \" $file \" "
22
- else
23
- output=" $output ,\" $file \" "
24
- fi
25
- done
26
-
27
- # Print the formatted output
28
- echo $output
6
+ # Execute the corresponding script based on the operating system
7
+ case " $os_type " in
8
+ Linux)
9
+ echo $( ./find-elf.sh " $1 " )
10
+ ;;
11
+ Darwin)
12
+ echo $( ./find-macho.sh " $1 " )
13
+ ;;
14
+ * )
15
+ echo " Unsupported OS: $os_type "
16
+ exit 1
17
+ ;;
18
+ esac
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+
3
+ # Check if a directory is provided as an argument
4
+ if [ -z " $1 " ]; then
5
+ echo " Usage: $0 <directory>"
6
+ exit 1
7
+ fi
8
+
9
+ # Directory to search
10
+ directory=$1
11
+
12
+ # Find Mach-O and Universal Binary files in the specified directory
13
+ files=$( find " $directory " -type f -exec sh -c ' file -b "$1" | grep -q "Mach-O|universal binary" && echo "$1"' _ {} \; )
14
+
15
+ # Initialize an empty string for the output
16
+ output=" "
17
+
18
+ # Loop through each file and format it
19
+ for file in $files ; do
20
+ if [ -z " $output " ]; then
21
+ output=" \" $file \" "
22
+ else
23
+ output=" $output ,\" $file \" "
24
+ fi
25
+ done
26
+
27
+ # Print the formatted output
28
+ echo $output
You can’t perform that action at this time.
0 commit comments