query
stringlengths 27
253
| gold
stringlengths 7
172
|
---|---|
Create a symbolc link in the /system/folder1 to root folder | ln /system/folder1 -s / |
Remove files in the /system directory tree modified more than 31 days ago recursively | find /system -type f -mtime +31 -print0 | xargs -0 -r rm -f |
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 |
Concatenate all .txt files residing in the /system tree into a single file "/system/folder3/temp/empty.txt" | find /system -name "*.txt" -exec cat {} \; > /system/folder3/temp/empty.txt |
compresses all the files in the /system folder with default depth to /backup | find /system -depth -print | cpio -dump /backup |
Copy all files in the /system directory except those containing 'text' to '/system/folder3/backup_dbg/backup'. | find /system -maxdepth 1 -type f -name '*text*' -exec cp {} /system/folder3/backup_dbg/backup \; |
Rename "/system/folder3/temp/temp1" to "/system/folder3/temp/temp1_old" and backup to "/system/folder3/temp/temp1_old.old" if "/system/folder3/temp/temp1_old" exists | mv /system/folder3/temp/temp1 /system/folder3/temp/temp1_old -b -S .old |
Dump "/system/text1.txt" as ASCII characters | od -t c /system/text1.txt |
create a compressed archive of /system/folder1 "compress_folder1.tar.gz" with verbose output | tar -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 |
Search in /system downwards all files whose size is 10 bytes ( Characters ) . | find /system -size 10c -print |
Calculate the md5sum of each ".txt" file under "/system", sort the output, and calculate the md5sum of that | find /system -type f -name '*.txt' -exec md5sum {} + | awk '{print $1}' | sort | md5sum |
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}' |
find files in /workspace directory which are modified 30 days ago | find /workspace -daystart -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 files in the /workspace directory and sub-directories, that changed within last hour | find /workspace -cmin -60 |
find files in the /workspace directory and sub-directories, that were accessed within last hour | find /workspace -amin -60 |
list all the drectories present in the /workspace directory and do not search in the sub directories. | find /workspace -maxdepth 1 -type d |
list all the files in the /workspace directory which are of size 0 bytes. | find /workspace -empty |
list all zero-length files under the /workspace directory | find /workspace -empty -exec ls {} \; |
locate and remove large files (> 1 KB) in /workspace | find /workspace -type f -size +1k -delete |
long list al the files in the /workspace directory which have only read permission to the group | find /workspace -perm 400 -type f -exec ls -l {} \; |
long list al the files in the /workspace directory which have all the permissions | find /workspace -perm 777 -type f -exec ls -l {} \; |
long list the details of all the shell scripts in /workspace directory | find /workspace -name "*.sh" -exec 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 / {} + |
move files in /workspace accessed more than one day ago to directory / | find /workspace -atime +1 -type f -exec mv {} / \; |
print all filenames of files under /workspace/dir1 dir containing 'hello', case-insensitive | find /workspace/dir1 -type f -exec grep -il 'hello' {} \; |
print disk usage of files or folders in /workspace | du -sh /workspace |
print the last word in /workspace/dir1/long.txt | tac /workspace/dir1/long.txt | awk 'NF{print $NF; exit}' |
print top 3 largest files and /workspace | du -a /workspace | sort -nr | head -3 |
prints first line of "/workspace/dir1/long.txt" | head -n1 /workspace/dir1/long.txt |
prints the last non-empty line of "/workspace/dir1/a.txt" | tac /workspace/dir1/a.txt | grep -m 1 '.' |
prune all the files in the /workspace directory | find /workspace -prune |
search for all the files in the /workspace directory which have size greater than 1KB (approx) and less than 32KB(approx). | find /workspace -size +1000c -size -32000c -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 d -printf '%d\t%P\n' | sort -r -nk1 | cut -f2- |
search for all the files in the /workspace folder which are bigger than 1KB and display them biggest file | find /workspace -size +1k -exec ls -ls {} \+ | sort -n | tail -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 \) |
search for the directory "mysql" in the entire file system | find /workspace -name mysql -type d |
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 |
search for the file foo in the /workspace folder and display a long listing of it in sorted order of modification date | find /workspace -name foo | xargs 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" |
Calculate the md5 sum of all files in the /workspace directory with the filename printed first | ls -p | grep -v /workspace | xargs md5sum | awk '{print $2,$1}' |
Calculate the md5 sum of the contents of all files sorted in directory tree "/workspace" | find /workspace -type f | sort -u | xargs cat | md5sum |
Change directory to the alphabetically last path under the /workspace directory | cd $(find /workspace -type d -print0 | sort -z | tr '\0' '\n' | tail -1) |
Count the number of unique 3 to 6 character file extensions are in the /workspace directory tree | find /workspace -type f -name "*.*" | grep -o -E "\.[^\.]+$" | grep -o -E "[[:alpha:]]{3,6}" | awk '{print tolower($0)}' | sort | uniq -c | sort -rn |
Create a copy of the /workspace directory structure in the /usr directory, | find /workspace -type d -print|sed 's@^@/usr/@'|xargs mkdir -p |
Display a long listing of the oldest file under '/workspace' directory tree | find /workspace -printf "%T@ %p\n" | sort -n | head -1 | cut -d" " -f2- | xargs ls -al |
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 {} |
List all files with their paths that have identical content in /workspace directory | find /workspace -type f | xargs md5sum | sort | uniq -Dw32 |
Make directories for each unique file path in "/workspace/files.txt" | 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 -c | tail -1 | awk '{print $1}' |
Unhide all hidden files in the /workspace directory | find /workspace -maxdepth 1 -type f -name '.*' -exec sh -c 'mv "$0" "${0%/\.*}/${0##*/.}"' {} \; |
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 |
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 |
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 |
Create a symbolic link in directory "~/newlinks" for each file listed in "/workspace/results.txt" | cat /workspace/results.txt | xargs -I{} ln -s {} ~/newlinks |
Delete all hidden files under /workspace | find /workspace -type f -name '.*' -delete |
Determine if /workspace/dir2/mysql/ exists on a mounted file system. | df /workspace/dir2/mysql/ |
Display a dump of "/workspace/dir1/long.txt" as floating point values of double size | od -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) |
Display the file size of file '/workspace/dir1/sum.c' in bytes | du -sb /workspace/dir1/sum.c | cut -f1 |
Display the last slash-separated part of each filename path in /workspace/dir1/file.txt | rev /workspace/dir1/file.txt | cut -d/ -f1 | rev |
Display the sizes and filepaths of all files/directories in /workspace directory sorted in descending order of size | du /workspace -a -h --max-depth=1 | sort -hr |
Print percentage of the space used on the /workspace directory. | df -k /workspace | tail -1 | awk '{print $5}' |
Print the contents of "/workspace/dir1/long.txt" in reverse order | nl /workspace/dir1/long.txt | sort -nr | cut -b8- |
Create an empty file "Icon" with a carriage return character in the end of its name. | echo $'Icon\r' | xargs touch |
Create a symbolc link in the /workspace/dir1 to root folder | ln /workspace/dir1 -s / |
Display permissions, user, group, and full path for each file in the /workspace directory tree | tree /workspace -p -u -g -f |
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" |
Split the output of "/workspace/archive.tar.gz" into files of at most 10 MiB in size and use prefix "output_prefix" | tar -xf /workspace/archive.tar.gz | split -b 10M -d - /output_prefix |
Unpack all *.gz archives in the /workspace directory tree | find /workspace -name '*.gz' -print0 | xargs -0 gunzip |
Uncompress "/workspace/archive.tar.gz" and extract the archive to "/backup" | gzip -dc /workspace/archive.tar.gz | tar -xf - -C /backup |
Create a symbolic link to "/workspace/dir1/terminate.txt" named "/workspace/test" | ln /workspace/dir1/terminate.txt /workspace/test |
Retrieve only build number of current kernel, ie. #104 | uname -v | grep -o '#[0-9]\+' |
Print reverse lookup for adress 127.0.0.1 | dig -x 127.0.0.1 |
List file information of the full path of command "c++" | ls -ald `which c++` |
Extract host name part from "http://www.google.com" | echo "http://www.google.com" | cut -d'/' -f3 |
List environment variables and their values, escaping all semicolons with a backslash. | env | sed 's/;/\\;/g' |
Displays a tree of all process alongside their command line arguments. | pstree -a |
Create intermediate directories "dir" and "subdir" as required and create "subsubdir" | mkdir -p dir/subdir/subsubdir |
Change to the directory of the executable "python" | cd `dirname $(which python)` |
Print numbers 1 through 10 separated by ":" | yes | head -n10 | grep -n . | cut -d: -f1 | paste -sd: |
print all readline bindings | bind -P |
list names of bind functions containing "p" | bind -l | grep p |
List all files on smbfs mounts | mount -v | grep smbfs | awk '{print $3}' | xargs ls -ls |
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 |
Remove all characters except ";" and digits from the string " Hello world;876 " | echo ' Hello world;876 ' | tr -cd ';0-9' |
Remove leading and trailing spaces or tabs from " Hello world! " | echo ' Hello world! ' | sed -e 's/^[ \t]*//' | sed -e 's/[ \t]*$//' |
Remove the last 3 characters from "987654321" | echo 987654321 | rev | cut -c 4- | rev |
Print source of the file system containing current working directory. | df . | tail -1 | awk '{print $1}' |
List all variables (names only) with names containing "H". | env | awk -F= '{if($1 ~ /H/) print $1}' |
Print a list of unique users who are logged in | who | cut -d' ' -f1 | sort | uniq |
Ping hostname, grep for 192.168.11 and print the IP from the output | ping -c 1 hostname | grep 192.168.11 | grep 'bytes from' | awk '{print $4}' | sed 's/://g' |
Print a line of 99 '=' characters | seq -s= 100|tr -d '[:digit:]' |
Counts all business days in a current month. | cal -h | cut -c 4-17 | tail -n +3 | wc -w |
Count number of users logged in | who | awk -F' ' '{print $1}' | sort -u | wc -l |
Displays calendar of a previous, current and next month for December of 2120 year. | cal -3 12 2120 |
Extract, sort and print only group names from /etc/group. | cut -d: -f1 /etc/group | sort |
Store system load average number in the 'proc_load_average' variable and print it. | proc_load_average=$(w | head -n 1 | awk '{print $NF}' | tr ',' '.') && echo $proc_load_average |
Calculate the sum of all the numbers from 1 to 10 | seq 10 | jq -s 'add' |