File size: 40,162 Bytes
e547783
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
Prompt,Ground Truth Command,Functionally Equivalent Command
"Calculate a list of duplicate md5 sum hashes for all the "".java"" files in the /testbed directory",md5sum /testbed/*.java | awk '{print $1}' | sort | uniq -d,"find /testbed -type f -name ""*.java"" -exec md5sum {} + | sort | uniq -w32 -d -c | sort -nr"
Calculate the md5 sum of the md5 sum of all the files under /testbed/dir2/subdir2 sorted by filename,find /testbed/dir2/subdir2 -type f -print0 | sort -z | xargs -0 md5sum | awk '{print $1}' | md5sum,ls -1 /testbed/dir2/subdir2/* | sort | xargs md5sum | awk '{print $1}' | md5sum
"Calculate the md5 sum of the contents of the sorted list of files ""$FILES""",cat $(echo $FILES | tr ' ' '\n' | sort) | md5sum,"echo ""$FILES"" | tr ' ' '\n' | sort | xargs cat | md5sum"
"Calculate the md5 sum of the sorted list of md5 sums of all "".py"" files under /testbed/dir1/subdir1",find /testbed/dir1/subdir1 -type f -name *.py -exec md5sum {} + | awk '{print $1}' | sort | md5sum,find /testbed/dir1/subdir1 -type f -name '*.py' -print0 | xargs -0 md5sum | awk '{print $1}' | sort | md5sum
"Calculate the total disk usage for each "".txt"" file on the /testbed directory and prepend the system host name to the output","find /testbed -name ""*.txt"" -exec du {} + | awk -v hostname=""$(hostname)"" '{print hostname, $0}'","find /testbed -name ""*.txt"" -exec du -h {} + | awk -v hostname=""$(hostname)"" '{print hostname, $0}'"
Change permissions for all PHP files under the /testbed directory tree to 755 and print the number of files changed,"find /testbed -name ""*.php"" -exec chmod 755 {} \; -exec /bin/echo {} \; | wc -l","find /testbed -type f -name ""*.php"" -exec chmod 755 {} \; -print | wc -l"
"Check if the current shell is running within a 'screen' process and print ""True"" or ""False""","pstree -s $$ | grep -q ""screen"" && echo ""True"" || echo ""False""","ps -o comm= $(pstree -sp $$ | awk -F '[^0-9]*' '{print $2}') | grep -q 'screen' && echo ""True"" || echo ""False"""
"Print ""True"" if the contents of file /testbed/dir3/subdir1/subsubdir1/textfile3.txt is a subset of file /testbed/dir2/subdir1/textfile2.txt, otherwise print ""False""","comm -23 <(sort /testbed/dir3/subdir1/subsubdir1/textfile3.txt | uniq) <(sort /testbed/dir2/subdir1/textfile2.txt | uniq) | head -1 | grep -q '.' && echo ""False"" || echo ""True""","comm -23 <(sort /testbed/dir3/subdir1/subsubdir1/textfile3.txt | uniq) <(sort /testbed/dir2/subdir1/textfile2.txt | uniq) | grep -q '.' && echo ""False"" || echo ""True"""
Compute the mean average of the word count of *.txt files in the /testbed directory,find /testbed -name '*.txt' -print0 | xargs -0 wc -w | awk 'END { print $1/(NR-1) }',"find /testbed -type f -name ""*.txt"" -exec wc -w {} + | awk '{total = $1} END {print total/(NR-1)}'"
Compute the mean average of the word count of *.txt files smaller than 6 words in the /testbed directory,find /testbed -name '*.txt' -print0 | xargs -0 wc -w | awk '$1 < 6 {v += $1; c++} END {print v/c}',"find /testbed -name '*.txt' -print0 | xargs -0 wc -w | awk '$1 < 6 {v += $1; c++} END {print v/c, ""words""}'"
"Copy all files with ""FooBar"" in the path under the '/testbed' directory to the '/testbed/dir3/subdir1/subsubdir1/tmp' directory.",find /testbed -path '*FooBar*' -print0 | xargs -0 -I{} cp -r {} /testbed/dir3/subdir1/subsubdir1/tmp,find /testbed -path '*FooBar*' -print0 | xargs -0 -I{} cp -R {} /testbed/dir3/subdir1/subsubdir1/tmp
"search for all .txt files in the /testbed directory, prints their paths, and then search within each file for the word ""another""","find /testbed -name ""*.txt"" \( -exec echo {} \; -o -exec true \; \) -exec grep another {} \;","find /testbed -type f -name ""*.txt"" -print -exec grep -H ""another"" {} \;"
"Convert the first 16 characters in ""/testbed/textfile7.txt"" to a single hexadecimal value",head /testbed/textfile7.txt -c16 | od -tx1 -w16 | head -n1 | cut -d' ' -f2- | tr -d ' ',head -c 16 /testbed/textfile7.txt | od -An -tx1 | tr -d ' \n'
"Copies all files under the /testbed folder like ""file.txt"" with ""FooBar"" in the path to the root of the current folder, preserving mode, ownership and timestamp attributes.","find /testbed -type f -path '*FooBar*' | xargs -i cp -p ""{}"" .","find /testbed -type f -path '*FooBar*' -exec cp --preserve=mode,ownership,timestamps {} ./ \;"
"Copy all files and folders below the /testbed directory whose names contain ""FooBar"" to directory '/testbed/dir3/subdir1/subsubdir1/tmp'",find /testbed -name '*FooBar*' -print0 | xargs -0 -I{} cp -R {} /testbed/dir3/subdir1/subsubdir1/tmp,"find /testbed -name ""*FooBar*"" -exec cp -r {} /testbed/dir3/subdir1/subsubdir1/tmp \;"
Count all the lines of all '*.c' files in /testbed directory recursively,"find /testbed -name ""*.c"" -print0 | xargs -0 cat | wc -l","find /testbed -name ""*.c"" -exec wc -l {} + | awk '{s+=$1} END {print s}'"
Count all the lines of all files with names ending with 'php' in current directory and subdirectories recursively,find . -type f -name '*php' | xargs cat | wc -l,find . -type f -name '*.php' -exec wc -l {} + | awk '{s=$1} END {print s}'
Count all the lines of all php files in the /testbed directory recursively,find /testbed/ -name '*.php' | xargs cat | wc -l,find /testbed/ -type f -name '*.php' | xargs cat | wc -l
Calculate the md5sum of all '*.py' files in /testbed folder and sub folders.,"find /testbed -type f -name ""*.py"" -exec md5sum {} +","find /testbed -type f -name ""*.py"" -print0 | xargs -0 md5sum"
"Count the *.html files residing in the /testbed directory tree and containing string ""foo""","find /testbed -name ""*.html"" | xargs grep -l foo | wc -l","find /testbed -name ""*.html"" -exec grep -l foo {} + | wc -l"
Count the number of files/directories with '.php' extension under /testbed directory tree and change the permissions to 755,"find /testbed -name ""*.php"" -exec chmod 755 {} \; -exec /bin/echo {} \; | wc -l",find /testbed -type f -name '*.php' -exec chmod 755 {} \; -print | wc -l
Count the number of lines in all files in the /testbed directory tree that match pattern '*file*',find /testbed/ -name '*file*' | sort | xargs wc -l,find /testbed -type f -name '*file*' -exec wc -l {} +
Count the number of regular files in directory tree ${DIRECTORY} that contain a vowel in their names,find ${DIRECTORY} -type f -print | sed -e 's@^.*/@@' | grep '[aeiouyAEIOUY]' | wc -l,"find ""${DIRECTORY}"" -type f -print | awk -F/ '{print $NF}' | grep -i '[aeiouy]' | wc -l"
Count the number of files for each unique file extensions in the /testbed directory tree.,find /testbed -type f | sed -e 's/.*\.//' | sed -e 's/.*\///' | sort | uniq -c | sort -rn,find /testbed -type f | awk -F. '{if (NF>1) print $NF}' | sort | uniq -c | sort -nr
"Count the total number of lines in all ""*.gz"" files in the /testbed directory tree after decompression",find /testbed -type f -name '*.gz' | xargs zcat | wc -l,"find /testbed -type f -name ""*.gz"" -exec sh -c 'gunzip -c ""$0"" | wc -l' {} \; | awk '{s+=$1} END {print s}'"
Counts all files in the /testbed folder and subfolders.,find /testbed -type f -exec ls -l {} \; | wc -l,find /testbed -type f | wc -l
Count lines in each *.php file sorted by file in /testbed directory.,find /testbed -name '*.php' -type f | sort | xargs wc -l,"find /testbed -type f -name ""*.php"" -exec wc -l {} + | sort"
"Counts lines in each *.php file in /testbed directory, sorted by number of lines, descending.",find /testbed -name '*.php' -type f | xargs wc -l | sort -nr,"find /testbed -type f -name ""*.php"" -exec wc -l {} + | sort -rn"
"Counts number of occurences of all ip addresses in '/etc/networks' file, and prints all addresses with number of occurences in a descending order.","grep -oE '([0-9]{1,3}\.){3}[0-9]{1,3}' /etc/networks | sort | uniq -c | sort -nr","awk '{for (i=1; i<=NF; i++) if ($i ~ /([0-9]{1,3}\.){3}[0-9]{1,3}/) print $i}' /etc/networks | sort | uniq -c | sort -nr"
Counts total number of only lines with alphanumeric symbols in all *.php files in the /testbed folder and subfolders.,find /testbed -name '*.php' | xargs cat | awk '/[a-zA-Z0-9]/ {i++} END{print i}',find /testbed -type f -name '*.php' -exec grep -H '.*[[:alnum:]].*' {} + | wc -l
Counts total lines in PHP and JS files in /testbed.,find /testbed -name '*.js' -or -name '*.php' | xargs wc -l | grep 'total'  | awk '{print $1}',find /testbed -type f \( -name '*.php' -o -name '*.js' \) -exec wc -l {} + | awk '{s=$1} END {print s}'
"Create an empty file ""abc.txt"" in each directory named ""dir1"" under testbed directory.","find /testbed -type d -name ""dir1"" -print |  sed 's/$/\/abc.txt/g' | xargs touch","find testbed -type d -name ""dir1"" -exec touch {}/abc.txt \;"
Create logs.tar.gz of all older than one day logs of Ubuntu,find /var/log/ -mtime +1 | xargs  tar -czvPf  /testbed/logs.tar.gz,find /var/log -type f -mtime +1 -exec tar -czvPf /testbed/logs.tar.gz {} +
"Delete files in ""/testbed/dir3/subdir1/subsubdir1/tmp"" that are older than 2 days",find /testbed/dir3/subdir1/subsubdir1/tmp -type f -mtime +2 -print0 | xargs -0 rm -f,find /testbed/dir3/subdir1/subsubdir1/tmp -type f -mtime +2 -delete
Display the 5 largest files in the /testbed directory and its sub-directories.,find /testbed -type f -exec du -b {} + | sort -rh | head -n 5,find /testbed -type f -print0 | xargs -0 du -b | sort -rn | head -n 5
Display the 5 smallest files in the /testbed directory and its sub-directories ignoring any empty files.,find /testbed -type f -size +0c -exec du -b {} + | sort -n | head -n 5,find /testbed -type f -size +0c -exec du -b {} + | sort -rh | tail -n 5
Display the 5 smallest files in the /testbed directory and its sub-directories.,find /testbed -type f -exec ls -s {} \; | sort -n  | head -5,find /testbed -type f -exec du -b {} + | sort -n | head -n 5
Display the five biggest file sizes only in the /testbed directory,find /testbed -type f -maxdepth 1 -exec du -b {} + | sort -rh | head -n 5,ls -lS /testbed | grep '^-' | head -n 5
"Find .java files in the testbed directory tree that contain 'Hello', and print their names","find /testbed -name ""*.java"" -exec grep -Hin Hello {} + | cut -d "":"" -f 1 | xargs -I{} basename {}","find testbed -type f -name ""*.java"" -exec grep -l 'Hello' {} +"
Print a list of all duplicate case insensitive filenames in the /testbed directory tree,find /testbed -type f | awk -F/ '{print $NF}' | sort -f | uniq -i -d,find /testbed -type f | awk -F/ '{print tolower($NF)}' | sort | uniq -d
"Print all unique file paths under ""testbed/dir1"" compared to ""testbed/dir2""",comm -23 <(find /testbed/dir1 | sed 's#/testbed/dir1/##' | sort) <(find /testbed/dir2 | sed 's#/testbed/dir2/##' | sort) | sed 's#^#/testbed/dir1/#',comm -23 <(find testbed/dir1 -type f | sed 's|testbed/dir1/||' | sort) <(find testbed/dir2 -type f | sed 's|testbed/dir2/||' | sort) | sed 's|^|testbed/dir1/|'
Recursively finds all files containing text 'Hello' in /testbed and prints folder where they are placed.,grep -rl 'Hello' /testbed | xargs -I {} dirname {} | sort | uniq,find /testbed -type f -exec grep -l 'Hello' {} + | xargs -I {} dirname {} | sort | uniq
Prints total number of lines of all *.java files in /testbed folder and subfolders.,find /testbed -name '*.java' -print0 |xargs -0 wc -l|grep 'total' |awk '{ print $1 }',"find /testbed -name ""*.java"" -exec wc -l {} + | awk '{s=$1} END {print s}'"
Create a symbolc link in the /testbed/dir3/subdir1/subsubdir1/FooBar to root folder,ln /testbed/dir3/subdir1/subsubdir1/FooBar -s /,ln -s /testbed/dir3/subdir1/subsubdir1/FooBar /
search for all the files in the folder /testbed/dir1 which have sticky bit set and have the permissions 553,find /testbed/dir1 -perm 1553,find /testbed/dir1 -type f -perm 1553
"search for php files in /testbed directory and search for ""world"" in all these files","find /testbed -name '*.php' -exec grep -iq ""world"" {} \; -print","find /testbed -name ""*.php"" -exec grep -H ""world"" {} \;"
"Recursively finds all files with any cased text ""Hello"" in the '/system/folder1' folder, and precedes found string with its number in file.","grep -inr ""Hello"" /system/folder1",find /system/folder1 -type f -exec grep -inH 'hello' {} \;
"Recursively finds all files with whole word ""foo"" in the '/system', and precedes found string with its number in file.","grep -rnw /system -e ""foo""",grep -ronw '/system' -e 'foo'
Recursively list contents of the '/system' directory in a tree-like format,tree /system,find /system -print | sed -e 's;[^/]*/;|___;g;s;___|; |;g'
Recursively print all files and directories in the '/system/folder2' directory tree including hidden files,tree -a /system/folder2,find /system/folder2 -print | sed -e 's;[^/]*/;|___;g;s;___|; |;g'
"Recursively prints all folders in the '/system' folder that contain files like ""*.out"".","find /system -type f -name ""*.out"" -print0 | xargs -0 -n1 dirname | sort -u","find /system -type f -name ""*.out"" -printf '%h\n' | sort -u"
"Remove all ""*.txt"" files in the '/system' folder and answer ""y"" to any prompt",yes y | rm -r /system/*.txt,"find /system -maxdepth 1 -type f -name ""*.txt"" -exec rm -f {} \;"
Recursively removes all empty folders from the /system/folder3/temp folder.,find /system/folder3/temp -depth -type d -exec rmdir {} \;,find /system/folder3/temp -type d -empty -delete
"Recursively removes all empty folders under /system/folder3/temp, printing info message on each operation, and suppressing error messages if folder is not empty.",find /system/folder3/temp -type d -empty -exec rmdir -vp --ignore-fail-on-non-empty {} +,find /system/folder3/temp -type d -empty -print -delete 2>/dev/null
Recursively removes all files in the /system/folder1 folder but '*txt' files.,find /system/folder1 -type f -not -name '*txt' | xargs rm,find /system/folder1 -type f ! -name '*.txt' -print -delete
Recursively rename all files under /system/folder2 replacing special with regular.,"find /system/folder2 -type f -name '*special*' ! -path '*/special/*' -execdir bash -c 'mv ""$0"" ""${0/special/regular}""' {} \;","find /system/folder1 -type f -name '*special*' -exec bash -c 'for f; do mv -- ""$f"" ""${f%/*}/${f##*/special/regular}""; done' _ {} +"
"Recursively search for ""foo"" in the '/system' folder and write the output to the console followed by the number of matched lines","grep -r ""foo"" /system | tee >(wc -l)","grep -r ""foo"" /system | awk '{print} END {print NR}'"
"Recursively search for all regular files below directory ""/system/folder3/"", and output the name of each, without any containing directories.",find /system/folder3/ -type f -exec basename {} \;,find /system/folder3/ -type f | xargs -n 1 basename
"Recursively unzip files to stdout in ""/system/folder2.tar.gz"" and search for ""special""","zcat -r /system/folder2.tar.gz | grep ""special""","tar -xzvf /system/folder2.tar.gz -O | grep ""special"""
"Remove ""\r"" at the end of each line in ""system/folder3/temp/temp1/text1.txt"" and display the result as printable characters or backslash escapes",cat /system/folder3/temp/temp1/text1.txt | sed 's/\r$//' | od -c,cat system/folder3/temp/temp1/text1.txt | sed 's/\r$//' | od -c -An
Remove all *.doc files from the /system/folder1 tree,"find /system/folder1 -name '*.doc' -exec rm ""{}"" \;",find /system/folder1 -type f -name '*.doc' -delete
Remove all *.log files from the /system/folder1 tree,find /system/folder1 -name '*.log' -print0 | xargs -0 rm,find /system/folder1 -type f -name '*.log' -delete
Remove all *.txt files in '/system' directory but not in it's subdirectories,find /system -name '*.txt' -maxdepth 1 | xargs rm,find /system -name '*.txt' -maxdepth 1 -delete
Remove all *.sql files in the '/system/folder3/backup_dbg' directory that were last modified more than 25 days ago,find /system/folder3/backup_dbg/*.sql -mtime +25 -exec rm -f {} \;,find /system/folder3/backup_dbg -name '*.sql' -print -mtime +25 -delete
Remove all *.txt files under the /system/folder1 directory modified more than 5 minutes ago,"find /system/folder1 -mmin +5 -type f -name ""*.txt"" -delete","find /system/folder1 -mmin +5 -type f -name ""*.txt"" | xargs rm -f"
"Remove all *.txt files, except ""keep.txt"", under /system/folder1 directory modified more than 5 minutes ago. Do not include subdirectories.","find /system/folder1 -maxdepth 1 -mmin +5 -type f -name ""*.txt"" ! -name ""keep.txt"" -delete","find /system/folder1 -maxdepth 1 -mmin +5 -type f -name ""*.txt"" ! -name ""keep.txt"" | xargs rm -f"
"Remove all .sh files in the '/system/folder1' tree whose names begin with ""new""",find /system/folder1 -name 'new*.sh' -exec rm -f '{}' \;,find /system/folder1 -name 'new*.sh' -delete
"Remove all a.out, *.o, and core files under the '/system' directory",find /system \( -name a.out -o -name '*.o' -o -name 'core' \) -exec rm {} \;,"find /system -type f \( -name ""a.out"" -o -name ""*.o"" -o -name ""core"" \) -delete"
Print the last five lines of /system/folder1/data.csv,"cat /system/folder1/data.csv | rev | cut -d, -f-5 | rev","tail -n 1 /system/folder1/data.csv | rev | cut -d',' -f1-5 | rev"
"Remove all directories called ""temp"" from the /system directory tree","find /system -name ""temp"" -type d -delete","find /system -type d -name ""temp"" -exec rm -rf {} +"
Remove all empty files in /system/folder3/temp and below,find /system/folder3/temp -type f -empty -print | xargs rm -f,find /system/folder3/temp -type f -empty -print -delete
Remove all files a.out and *.o in the /system directory tree that were modified less than 7 days ago,find /system \( -name a.out -o -name '*.o' \) -mtime -7 -exec rm {} \;,"find /system -type f \( -name ""a.out"" -o -name ""*.o"" \) -mtime -7 -delete"
"Remove all files and directories under '/system/folder3/temp' directory tree that match with one of the name patterns '.DS_Store', '._.DS_Store' , '._*', '.TemporaryItems' or '.apdisk'",find /system/folder3/temp \( -name '.DS_Store' -or -name '._.DS_Store' -or -name '._*' -or -name '.TemporaryItems' -or -name '.apdisk' \) -exec rm -rf {} \;,find /system/folder3/temp \( -name '.DS_Store' -or -name '._.DS_Store' -or -name '._*' -or -name '.TemporaryItems' -or -name '.apdisk' \) -delete
"Remove everything within parentheses and substitute all non digit characters with a space from ""1/2 [3] (27/03/2012 19:32:54) word word word word 4/5"" and format the output as a table",echo '1/2 [3] (27/03/2012 19:32:54) word word word word 4/5' | sed -e 's/(.*)//' -e 's/[^0-9]/ /g' | column -t,echo '1/2 [3] (27/03/2012 19:32:54) word word word word 4/5' | sed 's/([^)]*)//g' | tr -c '0-9' ' ' | column -t
"Remove files text2, text3, text4 in directory /system/folder1",find /system/folder1 -name 'text[2-4]*' -exec rm {} \;,find /system/folder1 -name 'text[2-4]*' -delete
Remove files that are less than 1KB in size under /system directory,find /system -type f -size -1k -exec rm {} +,find /system -type f -size -1k -delete
"Remove files modified more than 31 days ago recursively from ""/system""",find /system -type f -mtime +31 -exec rm -f {} \;,find /system -type f -mtime +31 -delete
"Print ""/system/folder3/temp/temp1/text1.txt"" without newline characters.","paste -sd """" /system/folder3/temp/temp1/text1.txt",tr -d '\n' < /system/folder3/temp/temp1/text1.txt
Remove regular files in the /system directory tree,find /system -type f -exec rm {} +,find /system -type f -delete
Print which files differ between /system/folder1 and /system/folder2.,diff -qr /system/folder1 /system/folder2 | sort,diff -qr /system/folder1 /system/folder2
Print amount of space available on the file system containing path to the /system directory in megabytes.,df -m /system,df -m /system | grep / | tr -s ' ' | cut -d ' ' -f 4
Display the number of sub-directories under /system,find /system -type d | wc -l,tree -d /system | tail -n 1
"Archive all files in /system/folder1 directory modified in the last 60 days to ""/mytarfile.tgz"" with a time of 2023-01-01, owner of 0, and group of 0.",tar --mtime='2023-01-01' --owner=0 --group=0 -czf mytarfile.tgz `find /system/folder1 -mtime -60`,tar --mtime='2023-01-01' --owner=0 --group=0 -czvf mytarfile.tgz `find /system/folder1 -mtime -60`
Create a symbolc link in the /system/folder1 to root folder,ln /system/folder1 -s /,ln -s /system/folder1 /
"Write the current date and time followed by "" 1"" to the console and append to ""/system/folder3/temp/empty.txt""","echo $(date) ""1"" | tee -a /system/folder3/temp/empty.txt","echo $(date +""%Y-%m-%d~%H:%M:%S"") ""1"" | tee -a /system/folder3/temp/empty.txt"
"Concatenate all .txt files residing in the /system tree into a single file ""/system/folder3/temp/concat.txt""","find /system -name ""*.txt"" -not -name ""concat.txt"" -print -exec cat {} \; > /system/folder3/temp/concat.txt","find /system -type f -name ""*.txt"" -not -name ""concat.txt"" -print -exec cat {} \; > /system/folder3/temp/concat.txt"
Compresses all the files in the /system folder with default depth to /backup using cpio.,find /system -depth -print | cpio -dump /backup,find /system -print | cpio -dump /backup
Copy all files in the /system directory except those containing 'text' to '/system/folder3/backup_dbg/backup'. Do not include subdirectories.,find /system -maxdepth 1 -type f ! -name '*text*' -exec cp {} /system/folder3/backup_dbg/backup \;,find /system -maxdepth 1 -print -type f ! -name '*text*' -exec cp {} /system/folder3/backup_dbg/backup \;
"Rename ""/system/folder3/temp/temp1"" to ""/system/folder3/temp/temp1_old""",mv /system/folder3/temp/temp1 /system/folder3/temp/temp1_old,cp -r /system/folder3/temp/temp1 /system/folder3/temp/temp1_old && rm -r /system/folder3/temp/temp1
"Dump ""/system/text1.txt"" as ASCII characters",od -t c /system/text1.txt,hexdump -C /system/text1.txt
"Create a compressed archive of /system/folder1 ""compress_folder1.tar.gz"" with a time of 2023-01-01, owner of 0, and group of 0.",tar --mtime='2023-01-01' --owner=0 --group=0 -zcf compress_folder1.tar.gz /system/folder1,tar --mtime='2023-01-01' --owner=0 --group=0 -zcvf compress_folder1.tar.gz /system/folder1
"download content from ""http://example.com/textfile.txt"" and output to 'textfile.txt' in /system",curl http://example.com/textfile.txt -o /system/textfile.txt,curl -vo /system/textfile.txt http://example.com/textfile.txt
Search in /system downwards all files whose size is greater than 10 bytes.,find /system -size +10c -print,find /system -type f -size +10c
"Calculate the md5sum of each "".txt"" file under ""/system"" and sort the output.",find /system -type f -name '*.txt' -exec md5sum {} + | awk '{print $1}' | sort,"find /system -type f -name ""*.txt"" -exec md5sum {} + | sort"
"Search for the system host name in ""/etc/hosts"" and print the IP address in the first awk field",more /etc/hosts | grep `hostname` | awk '{print $1}',"grep ""$(hostname)"" /etc/hosts | awk '{print $1}'"
Find files in /workspace directory modified within 30 days.,find /workspace -daystart -type f -mtime -30,find /workspace -type f -mtime -30
find files in the /workspace directory with pattern` *.c  that larger than 1 Kilobytes,find /workspace -name '*.c' -size +1k -print,find /workspace -name '*.c' -size +1k
"Find files in the /workspace directory and sub-directories, that changed over an hour ago.",find /workspace -type f -cmin +60,find /workspace -type f -cmin +60 -print
"Find files in the /workspace directory and sub-directories, that were accessed over an hour ago.",find /workspace -type f -amin +60,find /workspace -type f -amin +60 -print
list all the drectories present in the /workspace directory and do not search in the sub directories.,find /workspace -maxdepth 1 -type d,find /workspace -maxdepth 1 -type d
list all the files in the /workspace directory which are of size 0 bytes.,find /workspace -empty,find /workspace -empty -print
list all zero-length files under the /workspace directory,find /workspace -empty -exec ls {} \;,find /workspace -type f -size 0
locate and remove large files (> 1 KB) in /workspace,find /workspace -type f -size +1k -delete,find /workspace -type f -size +1k -exec rm {} \;
List all the files in the /workspace directory which have only read permission to the group.,find /workspace -perm 400 -type f -exec ls -l {} \;,find /workspace -perm 400 -ls
List all the files in the /workspace directory which have permissions 777.,find /workspace -perm 777 -type f -exec ls -l {} \;,find /workspace -perm 777 -ls
List the details of all the text files in /workspace directory.,"find /workspace -name ""*.txt"" -exec ls -ld {} \;","find /workspace -name ""*.txt"" | xargs ls -ld"
move all files in the /workspace folder to / and do not move the files in the sub folder,find /workspace -maxdepth 1 -type f -exec mv -t / {} +,find /workspace -maxdepth 1 -type f -exec mv {} / \;
Move files in /workspace accessed less than one day ago to directory /.,find /workspace -atime -1 -type f -exec mv {} / \;,find /workspace -type f -atime -1 -print0 | xargs -0 -I {} mv {} /
"print all filenames of files under /workspace/dir1 dir containing 'hello', case-insensitive",find /workspace/dir1 -type f -exec grep -il 'hello' {} \;,grep -ril 'hello' /workspace/dir1
print disk usage of files or folders in /workspace,du -sh /workspace,du -h /workspace
print the last word in /workspace/dir1/long.txt,tac /workspace/dir1/long.txt | awk 'NF{print $NF; exit}',awk '{ for (i=1; i<=NF; i++) last=$i } END { print last }' /workspace/dir1/long.txt
Print the 3 largest directories in /workspace.,du -a /workspace | sort -nr | head -n 3,find /workspace -exec du -h {} + | sort -rh | head -n 3
"prints first line of ""/workspace/dir1/long.txt""",head -n1 /workspace/dir1/long.txt,sed -n '1p' /workspace/dir1/long.txt
"prints the last non-empty line of ""/workspace/dir1/a.txt""",tac /workspace/dir1/a.txt | grep -m 1 '.',awk 'NF' /workspace/dir1/a.txt | tail -n 1
prune all the files in the /workspace directory,find /workspace -type f -delete,find /workspace -type f -exec rm -f {} +
search for all the files in the  /workspace directory which have size greater than 1KB (approx) and less than 32KB(approx).,find /workspace -type f -size +1k -size -32k,find /workspace -type f -size +1k -size -32k -print
search for all the files in the  /workspace folder and sort them in the order of their depth and display the file names,"find /workspace -type f | awk -F/ '{print NF, $0}' | sort -n","find /workspace -type f | awk -F/ '{print NF, $0}' | sort -n | cut -d' ' -f2-"
Search for all the files in the /workspace folder which are bigger than 1KB and display the biggest file.,find /workspace -type f -size +1k -exec ls -ls {} + | sort -n | tail -1,find /workspace -type f -size +1k -exec ls -lh {} + | sort -k 5 -rh | head -n 1
search for text files in the  /workspace folder which do not have write access to others,"find  /workspace -type f \( -iname ""*.txt"" -not -perm -o=w \)","find /workspace -type f -name ""*.txt"" ! -perm -o=w"
"Search for the directory ""mysql"" in the workspace directory.",find  /workspace -name mysql -type d,"find workspace -type d -name ""mysql"""
Print a list of all duplicate case insensitive filenames in the /workspace directory tree,find /workspace -type f | awk -F/ '{print $NF}' | sort -f | uniq -i -d,find /workspace -type f | awk -F/ '{print tolower($NF)}' | sort | uniq -d
Search for the file old2.txt in the /workspace folder and list its permissions and creation time.,find /workspace -name old2.txt | xargs ls -tl,find /workspace -name old2.txt -print0 | xargs -0 ls -tl
"search for the word ""hello"" in all the regular/normal files in the  /workspace folder and display the matched file name","find  /workspace -type f | xargs grep -l ""hello""",grep -rnw '/workspace' -e 'hello'
Calculate the md5 sum of all files in the /workspace directory with the filename printed first,"find /workspace -type f -exec md5sum {} + | awk '{print $2 "" "" $1}'","find /workspace -type f -print0 | xargs -0 md5sum | awk '{print $2 "" "" $1}'"
"Calculate the md5 sum of all files in directory tree ""/workspace""",find /workspace -type f -exec md5sum {} + | sort,find /workspace -type f -exec md5sum {} +
Count the number of unique 3 to 6 character file extensions are in the /workspace directory tree,find /workspace -type f -name '*.*' | awk -F. 'NF>1 {ext=tolower($NF); if (length(ext) >= 3 && length(ext) <= 6) print ext}' | sort | uniq -c | wc -l,"find /workspace -type f -name '*.*' | sed -n 's/.*\.//p' | awk '{print tolower($0)}' | grep -E '^[a-z]{3,6}$' | sort -u | wc -l"
"Create a copy of the /workspace directory structure in the /usr directory,",find /workspace -type d -print|sed 's@^@/usr/@'|xargs mkdir -p,find /workspace -type d | cpio -pdm /usr
Display a long listing of the oldest file under '/workspace' directory tree,find /workspace -type f -printf '%T+ %p\n' | sort | head -n 1 | awk '{print $2}' | xargs ls -l,find /workspace -type f -exec stat --format '%Y %n' {} \; | sort -n | head -n 1 | cut -d' ' -f2- | xargs ls -l
Find the largest 2 directories under /workspace directory,find /workspace -type d -print0 | xargs -0 du | sort -n | tail -2 | cut -f2 | xargs -I{} du -sh {},find /workspace -type d -print0 | xargs -0 du | sort -n | tail -2
List all files with their paths that have identical content in /workspace directory,find /workspace -type f | xargs md5sum | sort | uniq -Dw32,find /workspace -type f -print0 | xargs -0 md5sum | sort | uniq -w32 -D
"Make directories for each unique file path in ""/workspace/files.txt""","cat /workspace/files.txt |xargs -I {} dirname ""{}""| sort -u | xargs -I{} mkdir -p ""{}""","cat /workspace/files.txt | xargs -I {} dirname {}| sort -u | xargs -I{} mkdir -p ""{}"""
"Print the total disk usage in bytes of all files listed in ""/workspace/files.txt""",cat /workspace/files.txt | xargs du -b | tail -1 | awk '{print $1}',awk '{print $0}' /workspace/files.txt | xargs du -b | awk '{sum += $1} END {print sum}'
Unhide all hidden files in the /workspace directory. Do not include subdirectories.,"find /workspace -maxdepth 1 -type f -name '.*' -exec sh -c 'mv ""$0"" ""${0%/\.*}/${0##*/.}""' {} \;","find /workspace -maxdepth 1 -type f -name '.*' -exec sh -c 'mv ""$1"" ""${1%/\.*}/${1##*/.}""' _ {} \;"
"Count the number of differing lines in ""/workspace/dir1/long.txt"" and ""/workspace/dir1/terminate.txt""",diff /workspace/dir1/long.txt /workspace/dir1/terminate.txt | grep ^[\>\<] | wc -l,diff /workspace/dir1/long.txt /workspace/dir1/terminate.txt | grep '^>' | wc -l
"Count the number of differing lines in ""/workspace/dir1/terminate.txt"" and ""/workspace/dir1/long.txt"" with 0 lines of unified context",diff -U 0 /workspace/dir1/terminate.txt /workspace/dir1/long.txt | grep -v ^@ | wc -l,diff -U 0 /workspace/dir1/terminate.txt /workspace/dir1/long.txt | grep -v '^@' | wc -l
Counts lines in file /workspace/dir1/a.txt ignoring empty lines and lines with spaces only.,awk '!/^[[:space:]]*$/{++x} END{print x}' /workspace/dir1/a.txt,grep -v '^[[:space:]]*$' /workspace/dir1/a.txt | wc -l
"Create a symbolic link in directory ""~/newlinks"" for each file listed in ""/workspace/results.txt""",cat /workspace/results.txt | xargs -I{} ln -s {} ~/newlinks,cat /workspace/results.txt | xargs -I {} ln -s {} ~/newlinks
Delete all hidden files under /workspace,find /workspace -type f -name '.*' -delete,find /workspace -type f -name '.*' -exec rm -f {} \;
"Display a dump of ""/workspace/dir1/long.txt"" as floating point values of double size",od -t fD /workspace/dir1/long.txt,od -An -t fD /workspace/dir1/long.txt
Display differences between list of files in /workspace/dir1 and /workspace/dir2.,diff <(ls /workspace/dir1) <(ls /workspace/dir2),diff -qr /workspace/dir1 /workspace/dir2
Display the file size of file '/workspace/dir1/sum.c' in bytes,du -sb /workspace/dir1/sum.c | cut -f1,stat -c %s /workspace/dir1/sum.c
Display the last slash-separated part of each filename path in /workspace/dir1/file.txt,rev /workspace/dir1/file.txt | cut -d/ -f1 | rev,awk -F/ '{print $NF}' /workspace/dir1/file.txt
Display the sizes and filepaths of all files/directories in /workspace directory sorted in descending order of size,du /workspace -a -h | sort -hr,du -ah /workspace | sort -rh
Print percentage of the space used on the /workspace directory.,df -k /workspace | tail -1 | awk '{print $5}',df -h /workspace | awk 'NR==2 {print $5}'
"Print the contents of ""/workspace/dir1/long.txt"" in reverse order",nl /workspace/dir1/long.txt | sort -nr | cut -b8-,tac /workspace/dir1/long.txt
"Create an empty file ""Icon"" in workspace/ with a carriage return character in the end of its name.",echo $'workspace/Icon\r' | xargs touch,"touch ""workspace/Icon""$'\r'"
Create a symbolc link in the /workspace/dir1 to root folder,ln /workspace/dir1 -s /,ln -s /workspace/dir1 /
"Display permissions, user, group, and full path for each file in the /workspace directory tree",tree /workspace -p -u -g -f,find /workspace -type f -exec stat --format '%A %U %G %N' {} \;
Search for 'hello' case insensitively in all files under /workspace directory tree and show the matched lines with their filenames,"find /workspace -type f -print0  | xargs -0 grep -iH ""hello""",grep -ri 'hello' /workspace
Unpack all *.gz archives in the /workspace directory tree,find /workspace -name '*.gz' -print0 | xargs -0 gunzip,find /workspace -type f -name '*.gz' -exec gunzip {} +
"Uncompress ""/workspace/archive.tar.gz"" and extract the archive to ""/backup""",gzip -dc /workspace/archive.tar.gz | tar -xf - -C /backup,tar -xzvf /workspace/archive.tar.gz -C /backup
"Create a symbolic link to ""/workspace/dir1/terminate.txt"" named ""/workspace/test""",ln /workspace/dir1/terminate.txt /workspace/test,ln -s /workspace/dir1/terminate.txt /workspace/test
"Retrieve only build number of current kernel, ie. #104",uname -v | grep -o '#[0-9]\+',uname -r | awk -F'-' '{print $2}'
Print reverse lookup for adress 127.0.0.1,dig -x 127.0.0.1,nslookup 127.0.0.1
"List file information of the full path of command ""grep""",ls -ald `which grep`,stat $(which grep)
"Extract host name part from ""http://www.google.com""","echo ""http://www.google.com"" | cut -d'/' -f3","echo ""http://www.google.com"" | sed -E 's|https?://([^/]+).*|\1|'"
"List environment variables and their values, escaping all semicolons with a backslash.",env | sed 's/;/\\;/g',"while IFS= read -r line; do echo ""${line//;/\\;}""; done < <(env)"
Displays a tree of all process alongside their command line arguments.,pstree -a,"ps -eo pid,ppid,cmd --forest"
"Create intermediate directories ""dir"" and ""subdir"" as required and create ""subsubdir""",mkdir -p dir/subdir/subsubdir,mkdir -p dir/subdir/subsubdir
"Print numbers 1 through 10 separated by "":""",yes | head -n10 | grep -n . | cut -d: -f1 | paste -sd:,"echo $(seq -s "":"" 1 10)"
print all readline bindings,bind -P,bind -P
"list names of bind functions containing ""p""",bind -l | grep p,bind -l | egrep 'p'
Save first IP address of domain 'google.com' in 'address' variable and display it,address=$(dig +short google.com | grep -E '^[0-9.]+$' | head -n 1) && echo $address,address=$(dig +short google.com | grep -m 1 '^[0-9]' | head -n 1) && echo $address
"Remove all characters except "";"" and digits from the string ""  Hello world;876	  """,echo '  Hello world;876	  ' | tr -cd ';0-9',"echo ""  Hello world;876     "" | sed 's/[^0-9;]//g'"
"Remove leading and trailing spaces or tabs from ""  Hello world!	  """,echo '  Hello world!	  ' | sed -e 's/^[ \t]*//' | sed -e 's/[ \t]*$//',"echo -n ""  Hello world!    "" | sed 's/^[ \t]*//;s/[ \t]*$//'"
"Remove the last 3 characters from ""987654321""",echo 987654321 | rev | cut -c 4- | rev,"echo ""987654321"" | sed 's/...$//'"
Print source of the file system containing current working directory.,df . | tail -1 | awk '{print $1}',df -P . | awk 'NR==2 {print $1}'
"List all variables (names only) with names containing ""H"".",env | awk -F= '{if($1 ~ /H/) print $1}',env | grep '^[^=]*H[^=]*=' | awk -F= '{print $1}'
Print a list of unique users who are logged in,who | cut -d' ' -f1 | sort | uniq,who | awk '{print $1}' | sort | uniq
ping 192.168.1.1,ping -w 1 192.168.1.1,ping -w 1 192.168.1.1
Print a line of 99 '=' characters,seq -s= 100|tr -d '[:digit:]',printf '=%.0s' {1..99}
Count number of users logged in,who | awk -F' ' '{print $1}' | sort -u | wc -l,who | wc -l
"Displays calendar of a previous, current and next month for December of 2120 year.",cal -3 12 2120,cal -3 12 2120
"Extract, sort and print only group names from /etc/group.",cut -d: -f1 /etc/group | sort,cut -d: -f1 /etc/group | sort | uniq
Calculate the sum of all the numbers from 1 to 10,seq 10 | jq -s 'add',echo $(( (10 * (10 + 1)) / 2 ))
Count the number of files and directories in the entire testbed directory,find /testbed | wc -l,find /testbed -print | wc -l
Print the number of python files in the testbed directory.,"find testbed -type f -name ""*.py"" | wc -l","find testbed -type f -name ""*.py"" -print | wc -l"
Sort the lines of textfile1.txt in reverse alphabetical order and save the result to a new file,sort -r /testbed/dir1/textfile1.txt > /testbed/dir1/textfile1_reverse_sorted.txt,sort -r /testbed/dir1/textfile1.txt > /testbed/dir1/textfile1_reverse_sorted.txt
Search for all files containing the word 'Shell' in testbed.,find /testbed -type f -exec grep -l 'Shell' {} +,grep -r 'Shell' /testbed
Find all symbolic links in the testbed directory.,find /testbed -type l,find /testbed -type l -print
Get the total size of all files in testbed/ and save it to total_size.txt,du -sh testbed/ | awk '{print $1}' > total_size.txt,du -s testbed/ | awk '{print $1}' > total_size.txt
List all files in the directory /testbed/dir1 and sort them by size in human-readable format,ls -lhS /testbed/dir1,ls -lhS /testbed/dir1
Count the number of lines in files under the directory /testbed/dir2.,grep -rl . /testbed/dir2 | xargs wc -l,find /testbed/dir2 -type f -exec wc -l {} +
Print the name and size of the 3 largest files in the directory /testbed/dir3,find /testbed/dir3 -type f -exec ls -lhS {} + | sort -rh -k5 | head -n 3,find /testbed/dir3 -type f -exec ls -lhS {} + 2>/dev/null | sort -rh -k5 | head -n 3
Find all files modified in the last 2 hours and compress them into a tarball named archive.tar.gz in the directory /testbed,find /testbed -type f -mmin -120 -print0 | xargs -0 tar -czf /testbed/archive.tar.gz,find /testbed -type f -mmin -120 -print0 | xargs -0 tar -czf /testbed/archive.tar.gz
List all subdirectories of /testbed that are not named subdir1,ls -d /testbed/*/ | grep -v /subdir1/,"find /testbed -mindepth 1 -maxdepth 1 -type d ! -name ""subdir1"""
Search for all files that contain the string 'text file' under the directory /testbed,grep -r 'text file' /testbed,grep -rl 'text file' /testbed
Compute the MD5 hash of all files under the directory /testbed and store them in a file named hashes.txt in the same directory,find /testbed -type f -exec md5sum {} + > /testbed/hashes.txt,find /testbed -type f -exec md5sum {} + > /testbed/hashes.txt
Print the last 10 lines of the file /testbed/dir3/subdir1/subsubdir1/textfile3.txt,tail -n 10 /testbed/dir3/subdir1/subsubdir1/textfile3.txt,tail -n 10 /testbed/dir3/subdir1/subsubdir1/textfile3.txt
Print the line number and contents of all lines containing the string 'value3' in the file /testbed/dir1/subdir1/jsonfile1.json,grep -n 'value3' /testbed/dir1/subdir1/jsonfile1.json,grep -n 'value3' /testbed/dir1/subdir1/jsonfile1.json
Find all files in the directory /testbed that have been modified in the last 24 hours and print their path,find /testbed -type f -mtime -1 -print,find /testbed -type f -mtime -1
Search for all the files in /testbed directory and its subdirectories that contain the word 'Hello' and replace it with 'Hi' in-place.,"grep -rl ""Hello"" /testbed | xargs sed -i 's/Hello/Hi/g'",grep -rl 'Hello' /testbed | xargs sed -i 's/Hello/Hi/g'
"Display the contents of textfile3.txt and textfile4.txt side by side, with line numbers and a separator between them.",paste <(nl /testbed/dir3/subdir1/subsubdir1/textfile3.txt) <(nl /testbed/dir1/subdir1/textfile4.txt),paste <(nl /testbed/dir3/subdir1/subsubdir1/textfile3.txt) <(nl /testbed/dir1/subdir1/textfile4.txt)