InterCode-Corrections / nl2bash_fs_2.json
westenfelder's picture
init
e547783
raw
history blame
14.3 kB
[
{
"query": "Recursively finds all files with any cased text \"Hello\" in the '/system/folder1' folder, and precedes found string with its number in file.",
"gold": "grep -inr \"Hello\" /system/folder1",
"gold2": "find /system/folder1 -type f -exec grep -inH 'hello' {} \\;"
},
{
"query": "Recursively finds all files with whole word \"foo\" in the '/system', and precedes found string with its number in file.",
"gold": "grep -rnw /system -e \"foo\"",
"gold2": "grep -ronw '/system' -e 'foo'"
},
{
"query": "Recursively list contents of the '/system' directory in a tree-like format",
"gold": "tree /system",
"gold2": "find /system -print | sed -e 's;[^/]*/;|___;g;s;___|; |;g'"
},
{
"query": "Recursively print all files and directories in the '/system/folder2' directory tree including hidden files",
"gold": "tree -a /system/folder2",
"gold2": "find /system/folder2 -print | sed -e 's;[^/]*/;|___;g;s;___|; |;g'"
},
{
"query": "Recursively prints all folders in the '/system' folder that contain files like \"*.out\".",
"gold": "find /system -type f -name \"*.out\" -print0 | xargs -0 -n1 dirname | sort -u",
"gold2": "find /system -type f -name \"*.out\" -printf '%h\\n' | sort -u"
},
{
"query": "Remove all \"*.txt\" files in the '/system' folder and answer \"y\" to any prompt",
"gold": "yes y | rm -r /system/*.txt",
"gold2": "find /system -maxdepth 1 -type f -name \"*.txt\" -exec rm -f {} \\;"
},
{
"query": "Recursively removes all empty folders from the /system/folder3/temp folder.",
"gold": "find /system/folder3/temp -depth -type d -exec rmdir {} \\;",
"gold2": "find /system/folder3/temp -type d -empty -delete"
},
{
"query": "Recursively removes all empty folders under /system/folder3/temp, printing info message on each operation, and suppressing error messages if folder is not empty.",
"gold": "find /system/folder3/temp -type d -empty -exec rmdir -vp --ignore-fail-on-non-empty {} +",
"gold2": "find /system/folder3/temp -type d -empty -print -delete 2>/dev/null"
},
{
"query": "Recursively removes all files in the /system/folder1 folder but '*txt' files.",
"gold": "find /system/folder1 -type f -not -name '*txt' | xargs rm",
"gold2": "find /system/folder1 -type f ! -name '*.txt' -print -delete"
},
{
"query": "Recursively rename all files under /system/folder2 replacing special with regular.",
"gold": "find /system/folder2 -type f -name '*special*' ! -path '*/special/*' -execdir bash -c 'mv \"$0\" \"${0/special/regular}\"' {} \\;",
"gold2": "find /system/folder1 -type f -name '*special*' -exec bash -c 'for f; do mv -- \"$f\" \"${f%/*}/${f##*/special/regular}\"; done' _ {} +"
},
{
"query": "Recursively search for \"foo\" in the '/system' folder and write the output to the console followed by the number of matched lines",
"gold": "grep -r \"foo\" /system | tee >(wc -l)",
"gold2": "grep -r \"foo\" /system | awk '{print} END {print NR}'"
},
{
"query": "Recursively search for all regular files below directory \"/system/folder3/\", and output the name of each, without any containing directories.",
"gold": "find /system/folder3/ -type f -exec basename {} \\;",
"gold2": "find /system/folder3/ -type f | xargs -n 1 basename"
},
{
"query": "Recursively unzip files to stdout in \"/system/folder2.tar.gz\" and search for \"special\"",
"gold": "zcat -r /system/folder2.tar.gz | grep \"special\"",
"gold2": "tar -xzvf /system/folder2.tar.gz -O | grep \"special\""
},
{
"query": "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",
"gold": "cat /system/folder3/temp/temp1/text1.txt | sed 's/\\r$//' | od -c",
"gold2": "cat system/folder3/temp/temp1/text1.txt | sed 's/\\r$//' | od -c -An"
},
{
"query": "Remove all *.doc files from the /system/folder1 tree",
"gold": "find /system/folder1 -name '*.doc' -exec rm \"{}\" \\;",
"gold2": "find /system/folder1 -type f -name '*.doc' -delete"
},
{
"query": "Remove all *.log files from the /system/folder1 tree",
"gold": "find /system/folder1 -name '*.log' -print0 | xargs -0 rm",
"gold2": "find /system/folder1 -type f -name '*.log' -delete"
},
{
"query": "Remove all *.txt files in '/system' directory but not in it's subdirectories",
"gold": "find /system -name '*.txt' -maxdepth 1 | xargs rm",
"gold2": "find /system -name '*.txt' -maxdepth 1 -delete"
},
{
"query": "Remove all *.sql files in the '/system/folder3/backup_dbg' directory that were last modified more than 25 days ago",
"gold": "find /system/folder3/backup_dbg/*.sql -mtime +25 -exec rm -f {} \\;",
"gold2": "find /system/folder3/backup_dbg -name '*.sql' -print -mtime +25 -delete"
},
{
"query": "Remove all *.txt files under the /system/folder1 directory modified more than 5 minutes ago",
"gold": "find /system/folder1 -mmin +5 -type f -name \"*.txt\" -delete",
"gold2": "find /system/folder1 -mmin +5 -type f -name \"*.txt\" | xargs rm -f"
},
{
"query": "Remove all *.txt files, except \"keep.txt\", under /system/folder1 directory modified more than 5 minutes ago. Do not include subdirectories.",
"gold": "find /system/folder1 -maxdepth 1 -mmin +5 -type f -name \"*.txt\" ! -name \"keep.txt\" -delete",
"gold2": "find /system/folder1 -maxdepth 1 -mmin +5 -type f -name \"*.txt\" ! -name \"keep.txt\" | xargs rm -f"
},
{
"query": "Remove all .sh files in the '/system/folder1' tree whose names begin with \"new\"",
"gold": "find /system/folder1 -name 'new*.sh' -exec rm -f '{}' \\;",
"gold2": "find /system/folder1 -name 'new*.sh' -delete"
},
{
"query": "Remove all a.out, *.o, and core files under the '/system' directory",
"gold": "find /system \\( -name a.out -o -name '*.o' -o -name 'core' \\) -exec rm {} \\;",
"gold2": "find /system -type f \\( -name \"a.out\" -o -name \"*.o\" -o -name \"core\" \\) -delete"
},
{
"query": "Print the last five lines of /system/folder1/data.csv",
"gold": "cat /system/folder1/data.csv | rev | cut -d, -f-5 | rev",
"gold2": "tail -n 1 /system/folder1/data.csv | rev | cut -d',' -f1-5 | rev"
},
{
"query": "Remove all directories called \"temp\" from the /system directory tree",
"gold": "find /system -name \"temp\" -type d -delete",
"gold2": "find /system -type d -name \"temp\" -exec rm -rf {} +"
},
{
"query": "Remove all empty files in /system/folder3/temp and below",
"gold": "find /system/folder3/temp -type f -empty -print | xargs rm -f",
"gold2": "find /system/folder3/temp -type f -empty -print -delete"
},
{
"query": "Remove all files a.out and *.o in the /system directory tree that were modified less than 7 days ago",
"gold": "find /system \\( -name a.out -o -name '*.o' \\) -mtime -7 -exec rm {} \\;",
"gold2": "find /system -type f \\( -name \"a.out\" -o -name \"*.o\" \\) -mtime -7 -delete"
},
{
"query": "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'",
"gold": "find /system/folder3/temp \\( -name '.DS_Store' -or -name '._.DS_Store' -or -name '._*' -or -name '.TemporaryItems' -or -name '.apdisk' \\) -exec rm -rf {} \\;",
"gold2": "find /system/folder3/temp \\( -name '.DS_Store' -or -name '._.DS_Store' -or -name '._*' -or -name '.TemporaryItems' -or -name '.apdisk' \\) -delete"
},
{
"query": "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",
"gold": "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",
"gold2": "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"
},
{
"query": "Remove files text2, text3, text4 in directory /system/folder1",
"gold": "find /system/folder1 -name 'text[2-4]*' -exec rm {} \\;",
"gold2": "find /system/folder1 -name 'text[2-4]*' -delete"
},
{
"query": "Remove files that are less than 1KB in size under /system directory",
"gold": "find /system -type f -size -1k -exec rm {} +",
"gold2": "find /system -type f -size -1k -delete"
},
{
"query": "Remove files modified more than 31 days ago recursively from \"/system\"",
"gold": "find /system -type f -mtime +31 -exec rm -f {} \\;",
"gold2": "find /system -type f -mtime +31 -delete"
},
{
"query": "Print \"/system/folder3/temp/temp1/text1.txt\" without newline characters.",
"gold": "paste -sd \"\" /system/folder3/temp/temp1/text1.txt",
"gold2": "tr -d '\\n' < /system/folder3/temp/temp1/text1.txt"
},
{
"query": "Remove regular files in the /system directory tree",
"gold": "find /system -type f -exec rm {} +",
"gold2": "find /system -type f -delete"
},
{
"query": "Print which files differ between /system/folder1 and /system/folder2.",
"gold": "diff -qr /system/folder1 /system/folder2 | sort",
"gold2": "diff -qr /system/folder1 /system/folder2"
},
{
"query": "Print amount of space available on the file system containing path to the /system directory in megabytes.",
"gold": "df -m /system",
"gold2": "df -m /system | grep / | tr -s ' ' | cut -d ' ' -f 4"
},
{
"query": "Display the number of sub-directories under /system",
"gold": "find /system -type d | wc -l",
"gold2": "tree -d /system | tail -n 1"
},
{
"query": "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.",
"gold": "tar --mtime='2023-01-01' --owner=0 --group=0 -czf mytarfile.tgz `find /system/folder1 -mtime -60`",
"gold2": "tar --mtime='2023-01-01' --owner=0 --group=0 -czvf mytarfile.tgz `find /system/folder1 -mtime -60`"
},
{
"query": "Create a symbolc link in the /system/folder1 to root folder",
"gold": "ln /system/folder1 -s /",
"gold2": "ln -s /system/folder1 /"
},
{
"query": "Write the current date and time followed by \" 1\" to the console and append to \"/system/folder3/temp/empty.txt\"",
"gold": "echo $(date) \"1\" | tee -a /system/folder3/temp/empty.txt",
"gold2": "echo $(date +\"%Y-%m-%d~%H:%M:%S\") \"1\" | tee -a /system/folder3/temp/empty.txt"
},
{
"query": "Concatenate all .txt files residing in the /system tree into a single file \"/system/folder3/temp/concat.txt\"",
"gold": "find /system -name \"*.txt\" -not -name \"concat.txt\" -print -exec cat {} \\; > /system/folder3/temp/concat.txt",
"gold2": "find /system -type f -name \"*.txt\" -not -name \"concat.txt\" -print -exec cat {} \\; > /system/folder3/temp/concat.txt"
},
{
"query": "Compresses all the files in the /system folder with default depth to /backup using cpio.",
"gold": "find /system -depth -print | cpio -dump /backup",
"gold2": "find /system -print | cpio -dump /backup"
},
{
"query": "Copy all files in the /system directory except those containing 'text' to '/system/folder3/backup_dbg/backup'. Do not include subdirectories.",
"gold": "find /system -maxdepth 1 -type f ! -name '*text*' -exec cp {} /system/folder3/backup_dbg/backup \\;",
"gold2": "find /system -maxdepth 1 -print -type f ! -name '*text*' -exec cp {} /system/folder3/backup_dbg/backup \\;"
},
{
"query": "Rename \"/system/folder3/temp/temp1\" to \"/system/folder3/temp/temp1_old\"",
"gold": "mv /system/folder3/temp/temp1 /system/folder3/temp/temp1_old",
"gold2": "cp -r /system/folder3/temp/temp1 /system/folder3/temp/temp1_old && rm -r /system/folder3/temp/temp1"
},
{
"query": "Dump \"/system/text1.txt\" as ASCII characters",
"gold": "od -t c /system/text1.txt",
"gold2": "hexdump -C /system/text1.txt"
},
{
"query": "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.",
"gold": "tar --mtime='2023-01-01' --owner=0 --group=0 -zcf compress_folder1.tar.gz /system/folder1",
"gold2": "tar --mtime='2023-01-01' --owner=0 --group=0 -zcvf compress_folder1.tar.gz /system/folder1"
},
{
"query": "download content from \"http://example.com/textfile.txt\" and output to 'textfile.txt' in /system",
"gold": "curl http://example.com/textfile.txt -o /system/textfile.txt",
"gold2": "curl -vo /system/textfile.txt http://example.com/textfile.txt"
},
{
"query": "Search in /system downwards all files whose size is greater than 10 bytes.",
"gold": "find /system -size +10c -print",
"gold2": "find /system -type f -size +10c"
},
{
"query": "Calculate the md5sum of each \".txt\" file under \"/system\" and sort the output.",
"gold": "find /system -type f -name '*.txt' -exec md5sum {} + | awk '{print $1}' | sort",
"gold2": "find /system -type f -name \"*.txt\" -exec md5sum {} + | sort"
},
{
"query": "Search for the system host name in \"/etc/hosts\" and print the IP address in the first awk field",
"gold": "more /etc/hosts | grep `hostname` | awk '{print $1}'",
"gold2": "grep \"$(hostname)\" /etc/hosts | awk '{print $1}'"
}
]