[ { "nl_command": "Display inputfile all on one line (replace newlines by spaces)", "bash_code": "awk 1 ORS=' ' file" }, { "nl_command": "Search the /tmp/ directory recursively for files matching regular expression \".*file[0-9]+$\"", "bash_code": "find /tmp -regex \".*file[0-9]+$\"" }, { "nl_command": "Search the /etc directory tree for symbolic links", "bash_code": "find /etc -type l -print" }, { "nl_command": "Merge each non-blank line of standard input into a single comma separated line", "bash_code": "grep -v '^$' | paste -s -d\",\" -" }, { "nl_command": "Print the sorted unique column of usernames of users who are currently logged in", "bash_code": "finger | cut -d ' ' -f1 | sort -u" }, { "nl_command": "display the count of all the directories present in a folder", "bash_code": "find /mount/point -type d | wc -l" }, { "nl_command": "Read a line from standard input with prompt \"Are you alright? \" and save the response to variable \"RESP\"", "bash_code": "read -p \"Are you alright? \" RESP" }, { "nl_command": "display all the files in the home folder which end with \".xbm\"", "bash_code": "find ~ -name '*.xbm'" }, { "nl_command": "Display a long listing of the files/directories with human readable sizes (100M, 10G etc..) under '/var' directory tree which are bigger than 10MB", "bash_code": "find /var/ -size +10M -exec ls -lh {} \\;" }, { "nl_command": "Search the /Path directory tree for files whose pathnames match pattern \"/Path/bar*\" and whose names match pattern \"file_name*\"", "bash_code": "find /Path -path \"/Path/bar*\" -name \"file_name*\"" }, { "nl_command": "display a long listing of all the files in the home folder which are bigger than 200MB", "bash_code": "find /home -size +200M -exec ls -sh {} \\;" }, { "nl_command": "Calculate the md5 sum of \"yourstring\"", "bash_code": "echo -n \"yourstring\" |md5sum" }, { "nl_command": "Look for regular files in the directory trees 'deferred', 'active', 'maildrop', 'incoming' under /var/spool/postfix/", "bash_code": "find /var/spool/postfix/{deferred,active,maildrop,incoming}/ -type f" }, { "nl_command": "Count the number of files named 'job.history' under '/data/SpoolIn' directory tree that match 'FAIL' in their contents", "bash_code": "find /data/SpoolIn -name job.history -exec grep -l FAIL {} \\; | wc -l" }, { "nl_command": "List all mounted filesystems", "bash_code": "mount" }, { "nl_command": "search for all the text files in the folder /foo and delete them", "bash_code": "find /foo/ -name \"*.txt\" -exec rm -v {} \\;" }, { "nl_command": "prints the last occurrence of text between two tags", "bash_code": "tac file | sed -n '0,/\\<\\/tag>/s//\\1/p'" }, { "nl_command": "Format the output of \"rub-script.rb\" as a tab separated table", "bash_code": "ruby-script.rb | column -s $'\\t' -t" }, { "nl_command": "Format tab delimited file \"list-of-entries.txt\" as a table", "bash_code": "column -t -s $'\\t' list-of-entries.txt" }, { "nl_command": "find all regular/normal files in the current folder whose name has the word photo or picture and which have been modified in the last 30 minutes", "bash_code": "find . \\( -iname \"*photo*\" -or -name \"*picture*\" \\) -and ! -type d -and -mmin -30" }, { "nl_command": "Format output of \"mount\" as a table", "bash_code": "mount | column -t" }, { "nl_command": "find all the directories in the $LOGDIR folder which have been modified in the last 24 hours and compress them", "bash_code": "find $LOGDIR -type d -mtime +0 -exec compress -r {} \\;" }, { "nl_command": "Find all *.xml files under current directory, search for '/dev/null; [ $? == 0 ] && echo $i; done" }, { "nl_command": "Create a symbolic link named \"~/bin/subl\" to \"/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl\"", "bash_code": "ln -s \"/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl\" ~/bin/subl" }, { "nl_command": "Find files in the current directory tree whose names begin with \"file\" and whose size is 0, and remove them", "bash_code": "find -name 'file*' -size 0 -delete" }, { "nl_command": "Prints long listing of top ten most memory using processes in a system.", "bash_code": "ps -e -orss=,args= | sort -nr | head" }, { "nl_command": "Find all Makefile's in the current directory tree and print the line 235 of each of them", "bash_code": "find . -type f -name Makefile -print -exec sed -n '235p' {} \\;" }, { "nl_command": "Find all regular files under current directory tree without descending into './dir1' (except './dir1/subdir1*' pattern) and './dir2' directories", "bash_code": "find . \\( -path './dir1/*' -and -not -path './dir1/subdir1*' -or -path './dir2' \\) -prune -or -type f -print" }, { "nl_command": "remove all core dump files from user's home directory", "bash_code": "find ~/ -name 'core*' -exec rm {} \\;" }, { "nl_command": "Creates temporary file in TMPDIR folder or /tmp/ if TMPDIR is not defined, named by template ${tempname}.XXXXXX, and saves path to new file in a TMPPS_PREFIX variable.", "bash_code": "TMPPS_PREFIX=$" }, { "nl_command": "Save full path of command \"cat\" to variable \"CAT\"", "bash_code": "CAT=`which cat`" }, { "nl_command": "Write standard output and error of \"./a.out\" to standard output and to file \"output\"", "bash_code": "./a.out |& tee output" }, { "nl_command": "List all ~/bin/FilesDvorak/.* and ~/.PAST_RC_files/.* files/directories and take common entries between these two lists", "bash_code": "comm -12 < <" }, { "nl_command": "Find all PHP files in the current directory recursively and search them for string \"$test\" with 8 simultaneous processes", "bash_code": "find . -name \\*.php -type f -print0 | xargs -0 -n1 -P8 grep -Hn '$test'" }, { "nl_command": "Split \"randn20M.csv\" into files of at most 5000000 lines each with prefix \"_tmp\"", "bash_code": "split -l5000000 randn20M.csv '_tmp';" }, { "nl_command": "Move all files that contain \"Subject: \\[SPAM\\]\" to \"your_file\"", "bash_code": "mv $(grep -l 'Subject: \\[SPAM\\]' | awk -F ':' '{print $1}') your_file" }, { "nl_command": "change the permission of all the regular files in the folder /home to 700", "bash_code": "find /home -type f -perm 0777 -print -exec chmod 700 {} \\;" }, { "nl_command": "Find all files/directories that start with 'a1a2' and end with 'txt' in their names and move their parent directories to '/home/spenx/dst/' directory", "bash_code": "find /home/spenx/src -name \"a1a2*txt\" | xargs -n 1 dirname | xargs -I list mv list /home/spenx/dst/" }, { "nl_command": "Find all regular files under ${S} directory", "bash_code": "find \"${S}\" -type f" }, { "nl_command": "Print canonical filename of \"/path/there/../../\" even if it does not exist", "bash_code": "readlink -m /path/there/../../" }, { "nl_command": "Search the /home/pankaj directory for regular files whose status has changed within the last 5 minutes", "bash_code": "find /home/pankaj -maxdepth 1 -cmin -5 -type f" }, { "nl_command": "Count the number of regular files in the current directory tree", "bash_code": "find . -type f | wc -l" }, { "nl_command": "Delete all directories found in $LOGDIR that are more than a work-week old", "bash_code": "find $LOGDIR -type d -mtime +5 -exec rm -rf {} \\;" }, { "nl_command": "Attempt to connect as root to localhost and copy /home/reportuser/dailyReport.doc to directory /root/dailyReports/20150105/ - this will normally fail because ssh won't accept root connections by default.", "bash_code": "scp -p /home/reportuser/dailyReport.doc root@localhost:/root/dailyReports/20150105/" }, { "nl_command": "Find files in the /travelphotos that are greater than 200k in size but do not have \"2015\" anywhere in the file name", "bash_code": "find /travelphotos -type f -size +200k -not -iname \"*2015*\"" }, { "nl_command": "Print each logged in user's full name", "bash_code": "finger | awk 'NR>1{print $2,$3}'" }, { "nl_command": "list all the files in the current directory which are of size 0 bytes.", "bash_code": "find . -empty" }, { "nl_command": "Run `fastqc' on all the fastqc files in the current directory tree", "bash_code": "find . -name \"*.fq\" | xargs -n 1 fastqc" }, { "nl_command": "Counts lines in file 'filename' ignoring empty lines and lines with spaces only.", "bash_code": "cat 'filename' | grep '[^ ]' | wc -l" }, { "nl_command": "Search \"inputfile\" for lines starting with \"t:\" and group the results in files with at most 200 lines each", "bash_code": "cat inputfile | grep \"^t\\:\" | split -l 200" }, { "nl_command": "using exec in find command to dispaly the searched files", "bash_code": "find . ... -exec cat {} \\; -exec echo \\;" }, { "nl_command": "Find all *.txt files/directories under current directory terminating their names/paths with null character", "bash_code": "find . -name '*.txt' -print0" }, { "nl_command": "Print epoch seconds for given time string \"Oct 21 1973\"", "bash_code": "date -d \"Oct 21 1973\" +%s" }, { "nl_command": "Write the common third space separated fields in \"file1.sorted\" and \"file2.sorted\" to \"common_values.field\"", "bash_code": "comm -12 < < > common_values.field" }, { "nl_command": "list all the files in the file system excluding proc folder and excluding symbolic links which have write permission for the user", "bash_code": "find / -path /proc -prune -o -perm -2 ! -type l -ls" }, { "nl_command": "Recursively removes all files like '4' under folder './a' and removes folders with such files if they become empty.", "bash_code": "find a -type f -name '4' -delete -printf \"%h\\0\" | xargs -0 -r rmdir" }, { "nl_command": "Go into the directory whose name is selected in the X window system, ie. double-clicked in a terminal window.", "bash_code": "cd \"`xsel`\"" }, { "nl_command": "Archive \"/path/to/sfolder\" to \"name@remote.server:/path/to/remote/dfolder\" compressing the data during transmission", "bash_code": "rsync -avlzp /path/to/sfolder name@remote.server:/path/to/remote/dfolder" }, { "nl_command": "Reattach a session and if necessary detach it first", "bash_code": "screen -dr 14313" }, { "nl_command": "Archive the directory structure under backup directory into directory-structure.tar", "bash_code": "find backup/ -type d | tar cf directory-structure.tar -T - --no-recursion" }, { "nl_command": "Find regular files modified within the last 7 days", "bash_code": "find . -mtime -7 -type f" }, { "nl_command": "Run a shell with all environment variables specified in the file 'cronenv' in the user's home directory.", "bash_code": "env - `cat ~/cronenv` /bin/sh" }, { "nl_command": "Check all .txt files whether they contain \"needle\"", "bash_code": "find . -type f -iname \"*.txt\" -print | xargs grep \"needle\"" }, { "nl_command": "Add a line number to every line in \"infile\"", "bash_code": "nl -ba infile" }, { "nl_command": "Find all files under /path/to/input/ that match the case insensitive string literal 'spammer@spammy.com' in their contents", "bash_code": "find /path/to/input/ -type f -exec grep -qiF spammer@spammy.com \\{\\} \\; -print" }, { "nl_command": "Print current shell using process ID", "bash_code": "ps -ef | grep $$ | grep -v grep" }, { "nl_command": "Recursively change the owner to \"ec2-user\" and group to \"apache\" of all files in \"/vol/html\"", "bash_code": "sudo chown -R ec2-user:apache /vol/html" }, { "nl_command": "display all files in current folder and follow the symbolic links and display the pointed file", "bash_code": "find -L ." }, { "nl_command": "find all files in /usr/bin and run the \"file\" command on them.", "bash_code": "find /usr/bin | xargs file" }, { "nl_command": "Count the number of unique 3 to 6 character file extensions are in the current directory tree", "bash_code": "find . -type f -name \"*.*\" | grep -o -E \"\\.[^\\.]+$\" | grep -o -E \"[[:alpha:]]{3,6}\" | awk '{print tolower}' | sort | uniq -c | sort -rn" }, { "nl_command": "Print each line in \"f1\" and \"f2\" separated by a space and \"f3\" separated by a tab", "bash_code": "paste <(paste -d\" \" f1 f2) f3" }, { "nl_command": "List all files that matches both the case insensitive patterns *$1* and *$2* under /home/musicuser/Music/ directory", "bash_code": "find /home/musicuser/Music/ -type f -iname \"*$1*\" -iname \"*$2*\" -exec echo {} \\;" }, { "nl_command": "Find all files/directories in current directory and execute the script itself with minimal invocation for those files/directories", "bash_code": "find . -exec $0 {} +" }, { "nl_command": "Print a summary of the command-line usage of find", "bash_code": "find --help" }, { "nl_command": "Remove spaces from output of \"echo aa | wc -l\"", "bash_code": "echo aa | wc -l | tr -d ' '" }, { "nl_command": "Lists content of the current folder.", "bash_code": "$ ls" }, { "nl_command": "count all the html files having a specifc word in a folder.", "bash_code": "find /usr/src -name \"*.html\" -exec grep -l foo '{}' ';' | wc -l" }, { "nl_command": "Find all *.java files under current directory and replace every occurrences of 'subdomainA.example.com' with 'subdomainB.example.com' in those files", "bash_code": "find /home/www -name \"*.java\" -type f -print0 | xargs -0 sed -i 's/subdomainA\\.example\\.com/subdomainB.example.com/g'" }, { "nl_command": "Read a single line from standard input and save to variable \"line\"", "bash_code": "read line" }, { "nl_command": "create a symbolic link with absolute path \"/cygdrive/c/Program Files\" to file \"/cygdrive/c/ProgramFiles\"", "bash_code": "ln -s \"/cygdrive/c/Program Files\" /cygdrive/c/ProgramFiles" }, { "nl_command": "Replace all newlines from standard input except the last with spaces", "bash_code": "sed ':a;N;$!ba;s/\\n/ /g'" }, { "nl_command": "Append all PNG and JPG files to tar archive 'images.tar'", "bash_code": "find . \\( -iname \"*.png\" -o -iname \"*.jpg\" \\) -print -exec tar -rf images.tar {} \\;" }, { "nl_command": "search for files which are writable by either their owner or their group", "bash_code": "find . -perm /220" }, { "nl_command": "Rename '.mkv' extension to '.avi' for all files/directories under '/volume1/uploads' directory tree", "bash_code": "find /volume1/uploads -name \"*.mkv\" -exec rename 's/\\.mkv$/.avi/' \\{\\} \\;" }, { "nl_command": "Find all directories under and below /root that match pattern \"*linux*\", case insensitive", "bash_code": "find /root -type d -iname \"*linux*\"" }, { "nl_command": "change the permission of all php files in current folder", "bash_code": "find . -name \"*.php\" -exec chmod 755 {} \\;" }, { "nl_command": "Sort and show top 10 processes by memory usage", "bash_code": "ps aux | awk '{print $2, $4, $11}' | sort -k2rn | head -n 10" }, { "nl_command": "Remove sequence like '\\xEF\\xBB\\xBF' from first string of every file in a current folder and subfolders, creating backup file with .bak extension for every changed file, and removing backup on success.", "bash_code": "find . -type f -exec sed '1s/^\\xEF\\xBB\\xBF//' -i.bak {} \\; -exec rm {}.bak \\;" }, { "nl_command": "Find all directories under $root and replace all newlines with : in the output", "bash_code": "find $root -type d | tr '\\n' ':'" }, { "nl_command": "find all the normal/regular files in the current folder which have been accessed in the last 24 hours and display a long listing of them", "bash_code": "find . -type f -atime -1 -exec ls -l {} \\;" }, { "nl_command": "Find files in the current directory tree whose content was changed within the last 60 minutes", "bash_code": "find . -mmin -60" }, { "nl_command": "Search the current directory and directories below for .sql files", "bash_code": "find . -name \\*.sql" }, { "nl_command": "Change permissions to u=rw,g=r,o= for all files in the current directory tree", "bash_code": "find . -type f -exec chmod u=rw,g=r,o= '{}' \\;" }, { "nl_command": "create directory dir1", "bash_code": "mkdir dir1" }, { "nl_command": "Find all *bar files/directories under current directory", "bash_code": "find -name *bar" }, { "nl_command": "Shows only process trees rooted at processes of this user.", "bash_code": "pstree user" }, { "nl_command": "Displays information about grc formula.", "bash_code": "brew info grc" }, { "nl_command": "find all the files in the current folder which have been modified in the last 60 minutes, which are atleast 1 level deep and display a long listing of these files", "bash_code": "find . -mindepth 1 -mmin -60 | xargs -r ls -ld" }, { "nl_command": "Find all the Sticky Bit set files whose permission are 551 in the file system", "bash_code": "find / -perm 1551" }, { "nl_command": "show all files in the current directory and all subdirectories", "bash_code": "find ." }, { "nl_command": "find files changed in the last 1 day", "bash_code": "find . -mtime -1 -type f" }, { "nl_command": "Move each of the directories in /path/to/folders/* to another directory whose name is constituted by appending .mbox to each directory name and create a directory named Messages in this directory then move all *.emlx files into this directory", "bash_code": "find /path/to/folders/* -type d -exec mv {} {}.mbox \\; -exec mkdir {}.mbox/Messages \\; -exec sh -c \"mv {}.mbox/*.emlx {}.mbox/Messages\" \\;" }, { "nl_command": "display all sqlite files in the current directory along with their timestamp", "bash_code": "find ./ -name \"*.sqlite\" -printf '%Tc %p\\n'" }, { "nl_command": "Move all files/directories under current directory to destDir", "bash_code": "find sourceDir -print0 | xargs -0 mv -t destDir" }, { "nl_command": "Counts total number of only lines with alphanumeric symbols in all *.php files in a current folder and subfolders.", "bash_code": "find . -name '*.php' | xargs cat | awk '/[a-zA-Z0-9]/ {i++} END{print i}'" }, { "nl_command": "Delete files with inode number 782263 under current directory", "bash_code": "find . -inum 782263 -exec rm -i {} \\;" }, { "nl_command": "Print the help message of command \"split\"", "bash_code": "split --help" }, { "nl_command": "Search the current directory tree for regular files modified within the past 24 hours whose names do not end with \".DS_Store\"", "bash_code": "find . -mtime -1 ! -name '.DS_Store' -type f -printf '%f\\n'" }, { "nl_command": "Archive \"/local/path/some_file\" to \"/some/path\" on host \"server.com\" authenticating as user \"usr\", compress data during transmission, show progress details.", "bash_code": "rsync -avz --progress local/path/some_file usr@server.com:\"/some/path/\"" }, { "nl_command": "Change to location of '$TARGET_FILE' file.", "bash_code": "cd `dirname $TARGET_FILE`" }, { "nl_command": "Return 0 if at least one \"abc\" file in the current directory tree contains text \"xyz\"", "bash_code": "find . -name 'abc' -type f -exec grep -q xyz {} +" }, { "nl_command": "search the file \"myfile.txt\" in home folder", "bash_code": "find \"$HOME/\" -name myfile.txt -print" }, { "nl_command": "Wrap each line in \"yourfile\" to fit in 79 characters and right pad any lines shorter with spaces", "bash_code": "fold -w79 yourfile | sed -e :a -e 's/^.\\{0,78\\}$/& /;ta'" }, { "nl_command": "Set permissions of all directories under \"/path/to/base/dir\" to 755", "bash_code": "chmod 755 $" }, { "nl_command": "Gets IP address of 'en1' network interface.", "bash_code": "ifconfig en1 | awk '{ print $2}' | grep -E -o \"([0-9]{1,3}[\\.]){3}[0-9]{1,3}\"" }, { "nl_command": "Receive input and print it to terminal preceeding with line number", "bash_code": "cat -n" }, { "nl_command": "search in the current folder for the file with the name \"test\"", "bash_code": "find . -name test" }, { "nl_command": "Print CPU usage and memory usage of all unique processes on a system", "bash_code": "ps aux | awk '{print $4\"\\t\"$11}' | sort | uniq -c | awk '{print $2\" \"$1\" \"$3}' | sort -nr" }, { "nl_command": "Find all SUID set files", "bash_code": "find / -perm /u=s" }, { "nl_command": "Changes group ownership of '/home/www-user/php_user.sh' to 'www-data'.", "bash_code": "chgrp www-data /home/www-user/php_user.sh" }, { "nl_command": "Exclude directory from find . command", "bash_code": "find . -type d -name proc -prune -o -name '*.js'" }, { "nl_command": "Search directory /tmp/foo for files containing \"/tmp/foo/bar\" in their full names", "bash_code": "find /tmp/foo -path /tmp/foo/bar -print" }, { "nl_command": "Delete files in /var/tmp/stuff and below that have not been modified in over 90 days", "bash_code": "find /var/tmp/stuff -mtime +90 -exec /bin/rm {} \\;" }, { "nl_command": "Mount the \"linprocfs\" filesystem on \"/proc\"", "bash_code": "mount -t linprocfs none /proc" }, { "nl_command": "Search decompressed \"filename.gz\" for case-insensitive \"user-user\"", "bash_code": "zcat filename.gz | grep -i user-user" }, { "nl_command": "Find all files/drectories under '/u/bill' directory tree that have been accessed in the last 2 to 6 minutes", "bash_code": "find /u/bill -amin +2 -amin -6" }, { "nl_command": "Determine if /full/path exists on a mounted file system.", "bash_code": "df /full/path | grep -q /full/path" }, { "nl_command": "replace a string in all the files in the current folder", "bash_code": "find . | xargs perl -p -i.old -e 's/oldstring/newstring/g'" }, { "nl_command": "delete all the text files starting with the name \"oldStuff\" in the file system", "bash_code": "find / -name \"oldStuff*.txt\" -delete" }, { "nl_command": "delete all the regular files in the temp folder which have not been changed in the last 15*24 hours", "bash_code": "find /tmp/ -ctime +15 -type f -exec rm {} \\;" }, { "nl_command": "Answer \"n\" to any prompts in the interactive recursive removal of \"dir1\", \"dir2\", and \"dir3\"", "bash_code": "yes n | rm -ir dir1 dir2 dir3" }, { "nl_command": "dsisplay all files inthe current folder", "bash_code": "find ." }, { "nl_command": "Creates temporary file with name formatted like expression in variable ${PROG}, and saves path to it in 'mytemp' variable.", "bash_code": "mytemp=\"$(mktemp -t \"${PROG}\")\"" }, { "nl_command": "Find all regular .abc files under and below /the/path and rename them prefixing their names with \"version_1\"", "bash_code": "find /the/path -type f -name '*.abc' -execdir rename 's/\\.\\/(.+)\\.abc$/version1_$1.abc/' {} \\;" }, { "nl_command": "Find files in the current directory tree whose names are of the form \"cxx_data.txt\" where xx is a number from 30 to 70", "bash_code": "find . -regextype posix-egrep -regex '.\\*c([3-6][0-9]|70).\\*'" }, { "nl_command": "Prints last modified file in a current folder.", "bash_code": "find . -type f -printf '%T@ %p\\n' | sort -n | tail -1 | cut -f2- -d\" \"" }, { "nl_command": "Find all *.mov files under current directory and run an ffmpeg command with the path and the name for each file", "bash_code": "find . -iname \"*.mov\" -printf \"%p %f\\n\" | xargs -l bash -c 'echo ffmpeg -i $0 -f flv $1' | xargs" }, { "nl_command": "Find all symlinks under current directory", "bash_code": "find . -type l" }, { "nl_command": "create a compressed archive in my_dir directory matching '.[^.]* ..?*' glob pattern", "bash_code": "tar -C my_dir -zcvf my_dir.tar.gz .[^.]* ..?* *" }, { "nl_command": "Search the current directory tree for .aux files", "bash_code": "find . -name \".aux\"" }, { "nl_command": "Find all regular files under current directory tree excluding files from './dir1' and './dir2' directories", "bash_code": "find . \\ -type f" }, { "nl_command": "Search the current user's home directory and its sub-directories for any file that ends in .tar-gz and was modified after filename was last modified.", "bash_code": "find ~/ -name *.tar.gz -newer filename" }, { "nl_command": "Find all files/directories under '/usr/share/doc' directory tree whose name start with 'README'", "bash_code": "find /usr/share/doc -name README\\*" }, { "nl_command": "Counts all files in a current folder and subfolders.", "bash_code": "find . -type f | wc -l" }, { "nl_command": "Search the current directory recursively for files containing \"needle text\"", "bash_code": "find . -type f -exec grep -Iq . {} \\; -and -print0 | xargs -0 grep \"needle text\"" }, { "nl_command": "Change to directory listed in file '$HOME/.lastdir'", "bash_code": "cd `cat $HOME/.lastdir`" }, { "nl_command": "Search the files residing in the current directory tree whose names contain \"bills\" for \"put\"", "bash_code": "find . -name '*bills*' -exec grep -H \"put\" {} \\;" }, { "nl_command": "Gets MAC address of 'eth0' network interface.", "bash_code": "ifconfig eth0 | grep -Eo ..\\{5}" }, { "nl_command": "Find all files in current directory excluding hidden files and put the output into full_backup_dir variable", "bash_code": "full_backup_dir=$(find . -depth '' -prune -o -print)" }, { "nl_command": "Remove gitlab.site.org from root's known hosts file.", "bash_code": "ssh-keygen -f \"/root/.ssh/known_hosts\" -R gitlab.site.org" }, { "nl_command": "Takes first text field from file 'file.txt' as a domain name and gets short A record for this one.", "bash_code": "awk '{print $1}' file.txt | xargs dig +short" }, { "nl_command": "Replace 'company' with 'newcompany' in all files under current directory", "bash_code": "find ./ -type f -exec sed -i 's/company/newcompany/' {} \\;" }, { "nl_command": "Find all files/directories named 'foo.rb' under current directory tree", "bash_code": "find . -name foo.rb" }, { "nl_command": "create directory backup", "bash_code": "mkdir backup" }, { "nl_command": "Immediately kill all processes listening on TCP port 3000.", "bash_code": "lsof -n -i:3000 | grep LISTEN | awk '{ print $2 }' | uniq | xargs kill -9" }, { "nl_command": "Bypass all prompts by sending return to the install script downloaded from \"https://raw.github.com/Homebrew/homebrew/go/install\"", "bash_code": "yes '' | ruby -e \"$\"" }, { "nl_command": "Find files under current directory with name expanded by $1 and save the list to /tmp/safe_del.lst", "bash_code": "find . -name \"$1\" > /tmp/safe_del.lst" }, { "nl_command": "find all the normal/regular files in /etc/sysconfig which have been accesses in the last 30 minutes", "bash_code": "find /etc/sysconfig -amin -30 -type f" }, { "nl_command": "Remount \"/media/Working/\" with a umask of 000", "bash_code": "mount /media/Working/ -oremount,umask=000" }, { "nl_command": "show all the files in current directory", "bash_code": "find ." }, { "nl_command": "Remove the passphrase from user's ssh key without prompting.", "bash_code": "echo | ssh-keygen -P ''" }, { "nl_command": "search in the current folder for the file with the name \"test\" ( case insensitive search )", "bash_code": "find . -iname test" }, { "nl_command": "Remove the passphrase from user's ssh key without prompting.", "bash_code": "echo | ssh-keygen -P ''" }, { "nl_command": "kill all jobs", "bash_code": "kill $" }, { "nl_command": "Print the time to ping \"8.8.8.8\" followed by a time stamp if the ping is greater than 58", "bash_code": "ping 8.8.8.8 | awk '{split($7,a,\"[=.]\");if (a[2]>58) print a[2], strftime()}'" }, { "nl_command": "Recursively move \"./dir\" to \"user@host:/path\" compressing data and displaying progress during transmission", "bash_code": "rsync -rvz --progress --remove-sent-files ./dir user@host:/path" }, { "nl_command": "Print each unique line that is duplicated in files \"file1\" and \"file2\" combined", "bash_code": "sort file1 file2 | uniq -d" }, { "nl_command": "Find files named \"needle\" ignoring the case", "bash_code": "find . -iname \"needle\"" }, { "nl_command": "Print nothing because B.txt is compared with itself.", "bash_code": "comm -2 -3 <(sort -n B.txt) <(sort -n B.txt)" }, { "nl_command": "Create an empty file (or update timestamp of file) specified by variable \"correctFilePathAndName\"", "bash_code": "touch \"$correctFilePathAndName\"" }, { "nl_command": "Display the 5 smallest files in the current directory and its sub-directories.", "bash_code": "find . -type f -exec ls -s {} \\; | sort -n | head -5" }, { "nl_command": "Find all files under current directory and change their permission to 600", "bash_code": "find . -type f -exec chmod 600 {} \\;" }, { "nl_command": "Compare *.csv files in the current directory tree with their analogs stored in /some/other/path/", "bash_code": "find . -name \"*.csv\" -exec diff {} /some/other/path/{} \";\" -print" }, { "nl_command": "Archive \"somedir/./foo/bar/baz.c\" to \"remote:/tmp/\" preserving the relative path of \"foo/bar/baz.c\"", "bash_code": "rsync -avR somedir/./foo/bar/baz.c remote:/tmp/" }, { "nl_command": "Remove everything in a current folder without prompting.", "bash_code": "find -mindepth 1 -maxdepth 1 -print0 | xargs -0 rm -rf" }, { "nl_command": "Finds strings matching pattern '^fields=\\\\\\|^var=' in a 'set' output.", "bash_code": "set | grep ^fields=\\\\\\|^var=" }, { "nl_command": "Rename \"/usr/bin/php\" to \"/usr/bin/~php\"", "bash_code": "sudo mv /usr/bin/php /usr/bin/~php" }, { "nl_command": "List path/filename of all PHP files under current directory whose file type description or path/name contains \"CRLF\"", "bash_code": "find . -type f -iname \"*.php\" -exec file \"{}\" + | grep CRLF" }, { "nl_command": "Find all files under current directory that are larger than 10KB in size", "bash_code": "find . -type f -size +10k" }, { "nl_command": "Print every 3 characters of standard input as a line", "bash_code": "fold -w3" }, { "nl_command": "Change the permission to 0755 for all directories under current directory", "bash_code": "find . -type d -exec chmod 0755 {} \\;" }, { "nl_command": "Search for all files owned by user www-data that are not larger than 100kb", "bash_code": "find -user www-data -not -size +100k" }, { "nl_command": "Find all files that have additional permissions", "bash_code": "find / -perm -644" }, { "nl_command": "Print count of unique lines in all files like 'list_part*'", "bash_code": "cat list_part* | sort --unique | wc -l" }, { "nl_command": "Print yesterday's date as yyy:mm:dd", "bash_code": "date +%Y:%m:%d -d \"yesterday\"" }, { "nl_command": "Save the list of files modified within a fortnight ago to `deploy.txt' removing the leading ./ from the file names", "bash_code": "find . -type f -mtime -14 | sed 's|./||' >deploy.txt" }, { "nl_command": "split the file \"/path/to/large/file\" into pieces per 50000 lines named as /path/to/output/file/prefixNNN", "bash_code": "split --lines=50000 /path/to/large/file /path/to/output/file/prefix" }, { "nl_command": "display all the files in the file system which belong to no user", "bash_code": "find / -nouser -print" }, { "nl_command": "Shuffles strings of text received by 'awk' command on the input.", "bash_code": "awk 'BEGIN{srand();} {printf \"%06d %s\\n\", rand()*1000000, $0;}' | sort -n | cut -c8-" }, { "nl_command": "Search for 'text' in all regular files under current directory tree", "bash_code": "find . -type f -exec grep \"text\" {} /dev/null \\;" }, { "nl_command": "Find all *.rb (regular) files under current directory", "bash_code": "find . -name \"*.rb\" -type f" }, { "nl_command": "find all files in the file system which have no user and no group", "bash_code": "find / -nouser -nogroup" }, { "nl_command": "Find all files under foldername directory and set their permission to 644", "bash_code": "sudo find foldername -type f -exec chmod 644 {} \";\"" }, { "nl_command": "Send the SIGTERM signal to all processes whose command matches \"bad_process\" and which have used more than 100 seconds of total CPU time.", "bash_code": "ps -o pid,bsdtime --no-header -p $ | awk 'function mmss2s {if return -1; return ((60*substr)+substr)} { if (mmss2s > 100) { print $1; }}'" }, { "nl_command": "Copy all regular files whose names end in \"~\" from the /path directory tree to ~/backups/", "bash_code": "find /path -type f -name '*~' -print0 | xargs -0 -I % cp -a % ~/backups" }, { "nl_command": "Find files/directories named 'file.txt' that belong to user 'tutonics' in the entire filesystem", "bash_code": "find / -user tutonics -name \"file.txt\"" }, { "nl_command": "Find regular files under / that contain \"stringtofind\" and clear out their contents", "bash_code": "find / -maxdepth 1 -xdev -type f -exec grep -Zli \"stringtofind\" {} + | while IFS= read -r -d $'\\0' file; do sed '/./d' \"$file\"; done" }, { "nl_command": "Find every file under the directory /var/spool that was modified more than 60 days ago.", "bash_code": "find /var/spool -mtime +60" }, { "nl_command": "Set permissions to 500 for directories under the current directory", "bash_code": "find . -type d -exec chmod 500 {} \\;" }, { "nl_command": "Remove all files last modified more than 10 days ago from the current directory tree", "bash_code": "find . -mtime +10 | xargs rm" }, { "nl_command": "Search directory trees /usr/share/doc, /usr/doc, and /usr/locale/doc for files named 'instr.txt'", "bash_code": "find /usr/share/doc /usr/doc /usr/locale/doc -name instr.txt" }, { "nl_command": "Numerically sort IPv4 addresses specified on standard input with presedence to first, second, third, then fourth octet", "bash_code": "tr '.' ' ' | sort -nu -t ' ' -k 1 -k 2 -k 3 -k 4 | tr ' ' '.'" }, { "nl_command": "Search the regular files of the current directory tree for string \"texthere\"", "bash_code": "find -type f -exec grep -Hn \"texthere\" {} +" }, { "nl_command": "Use 'top' to monitor the newest instance of ProgramName.", "bash_code": "top -p \"$\"" }, { "nl_command": "Recursively changes group ownership of everything within current folder to 'git'.", "bash_code": "chgrp -R git ./" }, { "nl_command": "Find PHP files with abstract classes", "bash_code": "find . -type f -name \"*.php\" -exec grep --with-filename -c \"^abstract class \" {} \\; | grep \":[^0]\"" }, { "nl_command": "Search the current directory recursively for regular files that have been changed less than 3 days ago and print 5 of them.", "bash_code": "find . -type f -ctime -3 | tail -n 5" }, { "nl_command": "find all the video files which are bigger than 10 MB which have not been modified in the last 60 days but have been changed in the last 100 days in /tmp and /var/tmp folder home folders", "bash_code": "find /tmp /var/tmp ~ -type f -size +10M -mtime +60 -ctime -100 -exec file -N -i -- {} + | sed -n 's!: video/[^:]*$!!p'" }, { "nl_command": "Output \"testFile.txt.1\" without the \".1\" suffix.", "bash_code": "basename testFile.txt.1 .1" }, { "nl_command": "Search the current directory tree for files and directories called \"test\"", "bash_code": "find . -name test -print" }, { "nl_command": "search in current directory downwards all files which were accessed exactly 7 days back", "bash_code": "find . -atime 7 -print" }, { "nl_command": "Delete all files/directories named 'file' under current directory tree", "bash_code": "find -name file -delete" }, { "nl_command": "Split \"filename\" into files of at most 200000 lines each", "bash_code": "split -l 200000 filename" }, { "nl_command": "display all the \".mov\" files in the current folder", "bash_code": "find . -name \"*.mov\"" }, { "nl_command": "find all the files in the current folder which are bigger than 9MB", "bash_code": "find . -size +9M" }, { "nl_command": "Find all *.foo files under current directory and print their contents", "bash_code": "cat `find . -name '*.foo' -print`" }, { "nl_command": "Creates temporary file with name formatted like 'emacs-manager.XXXXXX' in '/tmp/' folder and saves path to it in 'tmp_file' variable.", "bash_code": "tmp_file=`mktemp --tmpdir=/tmp emacs-manager.XXXXXX`" }, { "nl_command": "Change permissions to 644 for all regular files under the /path/to/dir/ tree unless these permissions are already set", "bash_code": "find /path/to/dir ! -perm 0644 -exec chmod 0644 {} \\;" }, { "nl_command": "searches through the /usr/local directory for files that end with the extension .html", "bash_code": "find /usr/local -name \"*.html\" -type f" }, { "nl_command": "Find all *.java files under current directory containing the string 'String'", "bash_code": "find . -name \"*.java\" -exec grep \"String\" {} \\;" }, { "nl_command": "Print \"test=hello world\"", "bash_code": "echo \"hello world\" | echo test=$" }, { "nl_command": "Find the first file/directory under $DIR which matches the $TMP_DIR in its path", "bash_code": "/usr/bin/find $DIR -maxdepth 1 -ipath $TMP_DIR -print -quit" }, { "nl_command": "Find all *.$input_file_type files/directories under $source_dir with the null character as the delimiter", "bash_code": "find \"$source_dir\" -name \"*.$input_file_type\" -print0" }, { "nl_command": "Finds all php processes running in system.", "bash_code": "pstree | grep php" }, { "nl_command": "Counts lines of /dir/file.txt file.", "bash_code": "cat /dir/file.txt | wc -l" }, { "nl_command": "List all *.jar files/directories under /usr, /home and /tmp directory without reporting errors", "bash_code": "find /usr /home /tmp -name \"*.jar\" 2>/dev/null" }, { "nl_command": "list all javascipts file which whole name does not contain excludeddir or excludedir2 or excludedir3", "bash_code": "find . -name '*.js' | grep -v excludeddir | grep -v excludedir2 | grep -v excludedir3" }, { "nl_command": "Merge colon-separated information from file1 and file2 where first field of both files matches", "bash_code": "join -t: < <" }, { "nl_command": "delete all the empty in the current folder and all its sub directories", "bash_code": "find . -depth -type d -empty -exec rmdir {} \\;" }, { "nl_command": "find md5sum of a string \"password\"", "bash_code": "printf 'password' | md5" }, { "nl_command": "search in all the directories of the folder /PROD for JSON files and send them as input to the python file /tmp/test.py", "bash_code": "find /PROD -type d -exec sh -c 'cd \"{}\" && for f in *.json; do /tmp/test.py \"$f\"; done' \\;" }, { "nl_command": "Build an \"svn hotcopy\" command for each subdirectory of /usr/local/svn/repos/", "bash_code": "find /usr/local/svn/repos/ -maxdepth 1 -mindepth 1 -type d -printf \"%f\\0\" | xargs -0 -I{} echo svnadmin hotcopy /usr/local/svn/repos/\\{\\} /usr/local/backup/\\{\\}" }, { "nl_command": "Find all executable files under {} and take their names only and reverse sort them", "bash_code": "find {} -type f -depth 1 -print0 -perm +0111 | xargs -n1 -0 basename | sort -r && echo" }, { "nl_command": "Recursively move all files in \"/path/to/srcdir\" to \"dest/\"", "bash_code": "find /path/to/srcdir -type f -print0 | xargs -0 -i% mv % dest/" }, { "nl_command": "Make a POST request to \"http://dweet.io/dweet/for/cycy42\" with data \"PiIP\" set to the IP address of the system", "bash_code": "wget --post-data=\"PiIP=$(hostname -I)\" http://dweet.io/dweet/for/cycy42" }, { "nl_command": "Remove all directories called \"test\" from the /path/to/dir directory tree", "bash_code": "find /path/to/dir -name \"test\" -type d -exec rm -rf {} \\;" }, { "nl_command": "Find all regular files starting from level 3 of directory tree ~/container and move them one level up", "bash_code": "find ~/container -mindepth 3 -type f -execdir mv \"{}\" $/.. \\;" }, { "nl_command": "Rename all .html files to .txt", "bash_code": "rename 's/\\.html$/\\.txt/' *.html" }, { "nl_command": "List all .jpg files in the home directory tree", "bash_code": "find . -name \"*.jpg\" -print0 | xargs -0 ls" }, { "nl_command": "Search the directory tree given as variable $root_dir for regular files", "bash_code": "find $root_dir -type f" }, { "nl_command": "Ping all hosts in file \"ips\" twice", "bash_code": "cat ips | xargs -n1 ping -c 2" }, { "nl_command": "Searches the manual pages with descriptions in section 3, that name begins with lowercase letter.", "bash_code": "apropos -s 3 . | grep ^[a-z]" }, { "nl_command": "Display the last dot-separated field, in this case \"com\".", "bash_code": "echo 'maps.google.com' | rev | cut -d'.' -f 1 | rev" }, { "nl_command": "find all the files that have been modified in exactly 7*24 hours ago", "bash_code": "find . -mtime 7" }, { "nl_command": "Find files/directories under current directory that matches the regex /path/to/something[^/]*$ in their paths", "bash_code": "find . -exec sh -c 'echo {} | grep -qi /path/to/something[^/]*$' \\; -print" }, { "nl_command": "Replace sequential tabs with a single space in \"thefile.txt\" and write to \"the_modified_copy.txt\"", "bash_code": "tr -s '\\t' < thefile.txt | tr '\\t' ' ' > the_modified_copy.txt" }, { "nl_command": "Find all files/directories with space in their names under current directory and rename them by replacing all spaces with _", "bash_code": "find . -depth -name '* *' | while IFS= read -r f ; do mv -i \"$f\" \"$/$\" ; done" }, { "nl_command": "find all the files in current directory of size greater than 2GB.", "bash_code": "find . -size +2G" }, { "nl_command": "Find all readme.txt files/directories under your home directory", "bash_code": "find ~ -name readme.txt" }, { "nl_command": "Print all lines from the last occurrence of the regex 'pattern' to the end of the file 'file'", "bash_code": "tac file | sed '/pattern/q' | tac" }, { "nl_command": "Find all files/directories with '.log' extension that belong to the group 'adm' under '/var/log' directory tree", "bash_code": "find /var/log -group adm -name \"*.log\"" }, { "nl_command": "Search all the *.pl files in the current directory and subdirectories, and print the names of any that don't have a line starting with 'use strict'", "bash_code": "find . -name '*.pl' | xargs grep -L '^use strict'" }, { "nl_command": "Find all the regular files with '.tgz' and '.gz' extensions and delete the oldest file under '/home/backups' directory tree", "bash_code": "find /home/backups -type f \\( -name \\*.tgz -o -name \\*.gz \\) -print0 | xargs -0 ls -t | tail -1 | xargs rm" }, { "nl_command": "Find all regular files with the group read permission set in your home directory and below and output detailed information about each file.", "bash_code": "find . -perm -g=r -type f -exec ls -l {} \\;" }, { "nl_command": "Removes everything from current folder but '*ddl*' and '*docs*' files.", "bash_code": "ls -1|grep -v -e ddl -e docs| xargs rm -rf" }, { "nl_command": "Report file system inodes usage in human readable format", "bash_code": "df -ih" }, { "nl_command": "Expands `whoami` as current user name, and adds resulted path to the directory stack.", "bash_code": "pushd /home/`whoami`/Pictures" }, { "nl_command": "recursively look for files ending in either .py or .py.server", "bash_code": "find . -type f -regex \".*\\.\\\"" }, { "nl_command": "Search files \"file-containing-can't\" in the current directory tree for the string \"can't\"", "bash_code": "find . -name \"file-containing-can't\" -exec grep \"can't\" '{}' \\; -print" }, { "nl_command": "Add content of \"filename\" to the existing cron jobs of user \"user\", without removing the previously existing cron jobs.", "bash_code": "crontab -l -u user | cat - filename | crontab -u user -" }, { "nl_command": "Silently and recursively change the ownership of all files in the current directory to \"www-data\"", "bash_code": "sudo chown -Rf www-data *" }, { "nl_command": "remove all the \".core\" files in the file system", "bash_code": "find / -name \"*.core\" -print -exec rm {} \\;" }, { "nl_command": "find all text files in current folder and trim the extra spaces in all lines in these files ( MAC version )", "bash_code": "find . -iname '*.txt' -type f -exec sed -i '' 's/[[:space:]]\\{1,\\}$//' {} \\+" }, { "nl_command": "Move *wp-admin/index.php files to *wp-admin/index_disabled under /var/www/", "bash_code": "find /var/www/ -path '*wp-admin/index.php' | xargs -i sh -c 'mv {} $/index_disabled'" }, { "nl_command": "Move all files listed in $i file to dir.$count directory", "bash_code": "cat $i | xargs mv -t dir.$count" }, { "nl_command": "find all the files that have not been modified in the last 24 hours", "bash_code": "find /tmp/test/* -mtime +1" }, { "nl_command": "display all the regular/normal files in current folder which have been modified exactly 60 minutes before", "bash_code": "find . -mmin 60 -type f" }, { "nl_command": "display list of all the hidden directories in the directory \"/dir/to/search/\"", "bash_code": "find /dir/to/search -path '*/.*' -ls" }, { "nl_command": "Archive directory specified by variable \"i\" to \"/iscsi\" preserving relative paths.", "bash_code": "rsync -avR $i /iscsi;" }, { "nl_command": "Display all lines contiaining 'funcname' in system map file matching current kernel.", "bash_code": "cat /boot/System.map-`uname -r` | grep funcname" }, { "nl_command": "Search for the regex expaned by the variable $SEARCH in all regular files under $DIR directory tree", "bash_code": "find \"$DIR\" -type f -exec grep \"$SEARCH\" {} \\;" }, { "nl_command": "Copy all .patch files from the current directory tree to patches/", "bash_code": "find -name '*.patch' -print0 | xargs -0 -I {} cp {} patches/" }, { "nl_command": "Output only the filetype suffix of \"foo.tar.gz\", in this case \"gz\"", "bash_code": "echo \"foo.tar.gz\" | rev | cut -d\".\" -f1 | rev" }, { "nl_command": "create a tar file of all the songs on my system that have been modified in the last 180 days (which is essentially six months)", "bash_code": "find . -name -type f '*.mp3' -mtime -180 -print0 | xargs -0 tar rvf music.tar" }, { "nl_command": "Collapse double slashes in variable \"dir\" into a single one.", "bash_code": "dir=\"`echo $dir | sed s,//,/,g`\"" }, { "nl_command": "Search all *.c files from the current directory tree for \"hogehoge\"", "bash_code": "find . -name \\*.c -exec grep hogehoge {} \\;" }, { "nl_command": "Find all files with the extension jpg regardless of case", "bash_code": "find . -type f -iname '*.jpg' -print0" }, { "nl_command": "List absolute path of files in the current directory", "bash_code": "ls -1 | xargs readlink -f" }, { "nl_command": "display all the text files in the current folder", "bash_code": "find -name \u201c*.txt\u201d" }, { "nl_command": "Mathematically sum each line in \"infile\"", "bash_code": "paste -sd+ infile | bc" }, { "nl_command": "Make directories to \"/some/path\" as needed", "bash_code": "mkdir -p ./some/path" }, { "nl_command": "find all the files which start with the name \"Metallica\" in the folder \"/mp3-collection\" and which are bigger than 10MB", "bash_code": "find /mp3-collection -name 'Metallica*' -and -size +10000k" }, { "nl_command": "Print summary of new/missing files, and which files differ between folder1 and folder2, excluding those matching pattern \"node_modules\".", "bash_code": "diff -rqyl folder1 folder2 --exclude=node_modules" }, { "nl_command": "find all text files in the current directory and display them page wise", "bash_code": "find . -name \"*.txt\" -print" }, { "nl_command": "find all files in the folder \"myfiles\" which have not been accessed in the last 30*24 hours", "bash_code": "find /myfiles -atime +30" }, { "nl_command": "Print the last mounted drive", "bash_code": "mount | tail -1 | sed 's/ on .* ([^)]*)$//'" }, { "nl_command": "Search for all files in the current directory recursively whose names contain \"linkin\", ignoring the case", "bash_code": "find . -iname *linkin*" }, { "nl_command": "find all the files in the current folder which have execute permission", "bash_code": "find . -executable" }, { "nl_command": "Archive \"/media/10001/music/\" on host \"server\" to local directory \"/media/incoming/music/\" and skip files that are newer in the destination, delete any files in the destination not in the source, and compress data during transmission", "bash_code": "rsync -avzru --delete-excluded server:/media/10001/music/ /media/Incoming/music/" }, { "nl_command": "Print out the full path name of \"mypathname\" with dots resolved", "bash_code": "readlink -ev mypathname" }, { "nl_command": "Prints last modified file in a current folder with modification time.", "bash_code": "find . -type f | sed 's/.*/\"&\"/' | xargs ls -E | awk '{ print $6,\" \",$7 }' | sort | tail -1" }, { "nl_command": "Copy all files with '.png' extension under '/home/mine' directory tree to '/home/mine/pngcoppies/' directory with new names constructed by prepending 'copy' in their names", "bash_code": "find /home/mine -iname \"*.png\" -printf \"%P\\n \" | xargs -I % -n1 cp % /home/mine/pngcoppies/copy%" }, { "nl_command": "Search the current directory tree for files whose names contain \"bills\"", "bash_code": "find . -name '*bills*' -print" }, { "nl_command": "List all files that matches both the case insensitive patterns *$1* and *$2* under /home/musicuser/Music/ directory", "bash_code": "find /home/musicuser/Music/ -type f -iname \"*$1*\" -iname \"*$2*\" -exec echo {} \\;" }, { "nl_command": "Connect to host \"remotehost\" as ssh user \"user\" to copy remote file \"/location/KMST_DataFile_*.kms\" to current directory on local host.", "bash_code": "scp -v user@remotehost:/location/KMST_DataFile_*.kms" }, { "nl_command": "search for soft links in current folder and display those links which are not pointed to files in current folder", "bash_code": "find . -type l -exec readlink -f '{}' \\; | grep -v \"^`readlink -f ${PWD}`\"" }, { "nl_command": "Find files and directories modified within the last 7 days", "bash_code": "find . -mtime -7" }, { "nl_command": "Recursively unzip files to stdout in \"/some/dir/here\" and search for \"blah\"", "bash_code": "zcat -r /some/dir/here | grep \"blah\"" }, { "nl_command": "Print the column count of compressed file \"$file\"", "bash_code": "zcat \"$file\" | awk '{print NF}' | head" }, { "nl_command": "Find process \"terminal\" displaying the searching process", "bash_code": "ps aux | grep '[t]erminal'" }, { "nl_command": "Print the files in the current directory as a list of semicolon separated values", "bash_code": "ls -1b | tr '\\n' ';'" }, { "nl_command": "Remove all files and directories in the /home directory tree whose names are \"Trash\"", "bash_code": "find /home -name Trash -exec rm {} \\;" }, { "nl_command": "Find all directories under minimum 1 level down the $GIVEN_DIR directory", "bash_code": "find \"$GIVEN_DIR\" -type d -mindepth 1" }, { "nl_command": "Get second line from text contained in variable $data.", "bash_code": "echo \"$data\" | cut -f2 -d$'\\n'" }, { "nl_command": "Archive \"path/to/working/copy\" to \"path/to/export\" excluding files or directories named \".svn\"", "bash_code": "rsync -a --exclude .svn path/to/working/copy path/to/export" }, { "nl_command": "change the permissions of the directories from 777 to 755 in the folder \"/var/www/html\"", "bash_code": "find /var/www/html -type d -perm 777 -print -exec chmod 755 {} \\;" }, { "nl_command": "List all defined bash functions", "bash_code": "set | egrep '^[^[:space:]]+ [(][)][[:space:]]*$' | sed -r -e 's/ [(][)][[:space:]]*$//'" }, { "nl_command": "Search for all files with same inode NUM", "bash_code": "find . -inum NUM" }, { "nl_command": "Find all files/directories under minimum 1 level down the $FOLDER directory and sort them", "bash_code": "find \"$FOLDER\" -mindepth 1 | sort" }, { "nl_command": "List the directory paths of all file.ext files under present working directory", "bash_code": "find `pwd` -name \"file.ext\" -exec dirname {} \\;" }, { "nl_command": "Print a sorted list of *.so files in the bla directory tree", "bash_code": "find bla -name *.so -print0 | sort -rz" }, { "nl_command": "Find all target files outside the current working directory with symbolic links in the current working directory", "bash_code": "find . -type l -exec readlink -f '{}' \\; | grep -v \"^`readlink -f ${PWD}`\"" }, { "nl_command": "Save the list of *.au files in the current directory tree to file `names.txt'", "bash_code": "find -type f -name '*.au' > names.txt" }, { "nl_command": "Search the 'tmp' directory for .mp3 files", "bash_code": "find tmp -maxdepth 1 -name '*.mp3'" }, { "nl_command": "Remove all \"core\" regular files in the /tmp/ directory tree", "bash_code": "find /tmp -name core -type f -print | xargs /bin/rm -f" }, { "nl_command": "find all \".flac\" files in current folder starting with \"cmn-\"", "bash_code": "find . -name 'cmn-*.flac'" }, { "nl_command": "Show what content owned by root has been modified within the last day", "bash_code": "find /etc/ -user root -mtime 1" }, { "nl_command": "search for all the regular/normal mp3 files in the file system and move them to the folder /mnt/mp3", "bash_code": "find / -iname \"*.mp3\" -type f -print0 | xargs -0 -I '{}' /bin/mv \"{}\" /mnt/mp3/" }, { "nl_command": "Read a line from standard input and save received words sequentially in variables XPID XUSERID XPRIORITY XVIRTUAL XRESIDENT XSHARED XSTATE XCPU XMEM XTIME XCOMMAND", "bash_code": "read XPID XUSERID XPRIORITY XVIRTUAL XRESIDENT XSHARED XSTATE XCPU XMEM XTIME XCOMMAND" }, { "nl_command": "Creates full path with parents, that matches to folder path extracted from $f variable.", "bash_code": "mkdir -p -- \"$(dirname -- \"$f\")\"" }, { "nl_command": "Count the number of users logged in minus one", "bash_code": "who | sed 1d | wc -l" }, { "nl_command": "Locates Erlang distribution, and prints release number from 'RELEASES' file.", "bash_code": "awk -F, 'NR==1 {gsub(/\"/,\"\",$3);print $3}' \"$(dirname $(readlink -f $(which erl)))/../releases/RELEASES\"" }, { "nl_command": "Write to standard error a trace for each command after it expands the command and before it executes it", "bash_code": "set -x" }, { "nl_command": "Find all the files that are not named \"MyCProgram.c\" in the current directory only and without regards to case.", "bash_code": "find -maxdepth 1 -not -iname \"MyCProgram.c\"" }, { "nl_command": "Split \"file\" into 10 files of about equal size without splitting lines", "bash_code": "split -n l/10 file" }, { "nl_command": "Find all .svn directories under current directory and delete them", "bash_code": "find . -type d -name \".svn\" -print | xargs rm -rf" }, { "nl_command": "Read a line from standard input into the variable \"yn\" with the prompt \"Do you wish to install this program?\"", "bash_code": "read -p \"Do you wish to install this program?\" yn" }, { "nl_command": "display all the directories in the current folder", "bash_code": "find . -type d -print" }, { "nl_command": "List the files from the current directory tree that contain lines matching regular expression '^Subject:.*unique subject'", "bash_code": "find . -type f -print | xargs grep -il '^Subject:.*unique subject'" }, { "nl_command": "Print the text file paths that match 'needle text' in their contents under 'my_folder' recursively", "bash_code": "grep -rl \"needle text\" my_folder | tr '\\n' '\\0' | xargs -r -0 file | grep -e ':[^:]*text[^:]*$' | grep -v -e 'executable'" }, { "nl_command": "Find all $2 files in $1 path and search for the regex expanded by $3 in those files excluding the files with /proc in their paths", "bash_code": "find $1 -name \"$2\" | grep -v '/proc' | xargs grep -Hn \"$3\" {} \\;" }, { "nl_command": "perform a case insensitive search", "bash_code": "find / -type d -iname \"apt\" -ls" }, { "nl_command": "force delete all the temp files which are of size 0 bytes and which have not been accessed in the last 10 days", "bash_code": "find /tmp -size 0 -atime +10 -exec rm -f {} \\;" }, { "nl_command": "display all the files on the current folder excluding those that are present in the folder \"./src/emacs\"", "bash_code": "find . -path ./src/emacs -prune -o -print" }, { "nl_command": "Print a frequency count of column two for every file in the current directory", "bash_code": "awk -F '\\t' '{print $2}' * | sort | uniq -c | sort -nr" }, { "nl_command": "List all variables with names containing X.", "bash_code": "env | awk -F= '{if print $1}'" }, { "nl_command": "Find files under /some/path that are not executable by the owner", "bash_code": "find /some/path -type f ! -perm -100 -ls" }, { "nl_command": "Prompt user to type a list of cron jobs directly at the terminal, then use these replacing previously existing cron jobs.", "bash_code": "crontab" }, { "nl_command": "Count the number of lines recursively in the current directory", "bash_code": "find ./ -type f -exec wc -l {} \\; | cut -d' ' -f1 | paste -sd+ | bc" }, { "nl_command": "Remove all directories found in directory tree $LOGDIR that were modified more than 5 days ago", "bash_code": "find $LOGDIR -type d -mtime +5 -exec rm -f {} \\;" }, { "nl_command": "Locate all files in the current directory and below that do not have \"testfileasdf\" in their names", "bash_code": "find -not -name \"*testfileasdf*\"" }, { "nl_command": "Print the first 24 alphanumeric characters from \"/dev/urandom\", determining C locale for all categories", "bash_code": "cat /dev/urandom | LC_ALL=C tr -dc 'a-zA-Z0-9' | fold -w 24 | head -n 1" }, { "nl_command": "Print the 10 most used commands", "bash_code": "history | awk '{print $2}' | awk 'BEGIN {FS=\"|\"}{print $1}' | sort | uniq -c | sort -n | tail | sort -nr" }, { "nl_command": "Search the /home/www directory tree for regular files", "bash_code": "find /home/www -type f" }, { "nl_command": "Display a detailed listing of the current directory, pausing for user input after each page.", "bash_code": "ls -l | more" }, { "nl_command": "Search for \"pattern\" in \"file\" and join each line by a space", "bash_code": "cat file | grep pattern | paste -sd' '" }, { "nl_command": "Change the owner to \"hduser\" and group to \"hadoop\" of \"{directory path}\"", "bash_code": "sudo chown hduser:hadoop {directory path}" }, { "nl_command": "File 'save_pid.txt' contains a process ID, instantly kill this process with SIGKILL signal.", "bash_code": "kill -9 `cat save_pid.txt`" }, { "nl_command": "Find all files/directories named 'file_name' under current directory tree", "bash_code": "find . -name file_name" }, { "nl_command": "display all the files in current folder which have write permission to all the users", "bash_code": "find . -perm /222" }, { "nl_command": "find all the text files in current folder and move all these to another folder appending \".bar\" at the end of these files", "bash_code": "find . -name \"*.txt\" | xargs -I '{}' mv '{}' /foo/'{}'.bar" }, { "nl_command": "Find all files under current directory tree named 'filename_regex' excluding '.svn' and '.pdv' directories and files then search for the case insensitive pattern 'your search string' in those files", "bash_code": "find . -name \"filename_regex\"|grep -v '.svn' -v '.pdv'|xargs grep -i 'your search string'" }, { "nl_command": "List all unique parent directories of .class files found under the current directory", "bash_code": "find -name '*.class' -printf '%h\\n' | sort -u" }, { "nl_command": "Find all *$VERSION* files/directories under current directory where $VERSION is a variable", "bash_code": "find . -name \"*$VERSION*\"" }, { "nl_command": "List all processes with detailed information", "bash_code": "ps -ef" }, { "nl_command": "search for al cpp files in current folder and display unique parent directory of these files in sorted order", "bash_code": "find . -name \"*.cpp\" -exec dirname {} \\; | sort -u" }, { "nl_command": "Find all files/directories under /home/baumerf/public_html/ that were modified less than 60 minutes ago excluding error_log files/directories", "bash_code": "find /home/baumerf/public_html/ -mmin -60 -not -name error_log" }, { "nl_command": "Print the base name of the current working directory", "bash_code": "basename $(pwd)" }, { "nl_command": "Search the system for files whose names begin with letters 'a', 'b', or 'c'", "bash_code": "find / -name '[a-c]*'" }, { "nl_command": "create directory certs", "bash_code": "mkdir certs/" }, { "nl_command": "This command find displays the files which are modified in the last 15 minutes. And it lists only the unhidden files. i.e hidden files that starts with a . are not displayed in the find output.", "bash_code": "find . -mmin -15 \\" }, { "nl_command": "List files larger than 10MB under /var/log", "bash_code": "find /var/log -size +10M -ls" }, { "nl_command": "List all files in a current folder, separating names with comma", "bash_code": "ls -1 | tr '\\n' ','" }, { "nl_command": "search for a word in all the normal/regular files in the current folder", "bash_code": "find . -type f | xargs grep \"text\"" }, { "nl_command": "Find all catalina* files/directories under current directory", "bash_code": "find -name 'catalina*'" }, { "nl_command": "Display a long listing of all the files/directories under current directory tree that are newer than the file 'Nov' by modification time", "bash_code": "find . -newer Nov -ls" }, { "nl_command": "Lists all files in a current folder, separating names with comma.", "bash_code": "ls | sed '$!s/$/,/' | tr -d '\\n'" }, { "nl_command": "Gets IP address of 'eth0' network interface.", "bash_code": "ifconfig eth0 | awk '/inet /{sub(/[^0-9]*/,\"\"); print $1}'" }, { "nl_command": "Print a list of all filepattern-*2009* files/directories under data directory to filesOfInterest.txt file", "bash_code": "find -x data -name \"filepattern-*2009*\" -print0 > filesOfInterest.txt" }, { "nl_command": "long list all the files in the curent folder starting with \"Tes\"", "bash_code": "find . -type f -name \"Tes*\" -exec ls -l {} \\;" }, { "nl_command": "Go to directory named \"~\"", "bash_code": "cd \"~\"" }, { "nl_command": "Remove all *.tmp files from the /tmp directory tree", "bash_code": "find /tmp -name \"*.tmp\" -print0 | xargs -0 rm" }, { "nl_command": "Find all files under current directory that are larger than 10KB in size", "bash_code": "find . -type f -size +10k" }, { "nl_command": "Remove the last two alphanumeric file extensions from \"mpc-1.0.1.tar.gz\"", "bash_code": "echo \"mpc-1.0.1.tar.gz\" | sed -r 's/\\.[[:alnum:]]+\\.[[:alnum:]]+$//'" }, { "nl_command": "Find .rm files in the current directory tree and convert them to the MP3 format", "bash_code": "find . -type f -name \"*.rm\" -exec ffmpeg -i {} -sameq {}.mp3 \\; -exec rm {} \\;" }, { "nl_command": "find all files ending with \"js.compiled\" in current folder (print0 is used to handle files with newlines in their names)", "bash_code": "find ./js/ -name \"*.js.compiled\" -print0" }, { "nl_command": "Opens gawk info manual and goes to command-line options node.", "bash_code": "info -O gawk" }, { "nl_command": "Find all regular files under current directory tree and replace all '1.2.3.4' with '5.6.7.8' in these files modiying the files in-place", "bash_code": "find . -type f -exec sed -i \"s/1\\.2\\.3\\.4/5.6.7.8/g\" {} \\" }, { "nl_command": "search for all the files with the name \"dummy\" in the current folder", "bash_code": "find -type f -name dummy" }, { "nl_command": "find all normal/regular files in current folder an save the output to the files /tmp/grep1 & /tmp/grep2", "bash_code": "find ./ -type f | tee /tmp/grep1 /tmp/grep2 >/dev/null" }, { "nl_command": "SSH into $1 with login name 'pete'", "bash_code": "ssh \"$1\" -l pete" }, { "nl_command": "Prepends date to ping output", "bash_code": "ping www.google.fr | while read pong; do echo \"$: $pong\"; done" }, { "nl_command": "Display compter's hostname", "bash_code": "echo `uname -a | awk '{print $2}'`" }, { "nl_command": "Copy a large sparse file \"sparse-1\" to \"sparse-1-copy\"", "bash_code": "rsync --sparse sparse-1 sparse-1-copy" }, { "nl_command": "List all files/directories under current directory with their inode numbers, disk space, permission, number of hard links, user name, group name, size, status change time in Y-m-d format and name filed, then write the outptut to /tmp/files.txt", "bash_code": "find . -type f -fprintf /tmp/files.txt \"%i,%b,%M,%n,%u,%g,%s,%CY-%Cm-%Cd %CT,%p\\n\"" }, { "nl_command": "For each line in 'file', print \"result = \" followed by the line backwards.", "bash_code": "rev file | awk '{print \"result =\",$0}'" }, { "nl_command": "find all the files in the current folder which have been modified in the last one minute", "bash_code": "find . -type f -mmin 0" }, { "nl_command": "Print a welcome message with the current user's user name", "bash_code": "echo \"Welcome `whoami`!\"" }, { "nl_command": "Gets IP address of 'en1' network interface.", "bash_code": "my_ip=$(ifconfig en1 | grep 'inet addr' | awk '{print $2}' | cut -d: -f 2)" }, { "nl_command": "Print the list of files in the current directory tree skipping SVN files", "bash_code": "find . -type d -name .svn -prune -o -print" }, { "nl_command": "Search the current directory for regular files whose names start with my", "bash_code": "find . -name 'my*' -type f" }, { "nl_command": "Write the current date and time followed by \" 1\" to the console and append to \"log.csv\"", "bash_code": "echo $ \"1\" | tee -a log.csv" }, { "nl_command": "Let the user page through 'filename.csv' with long lines chopped so they fit within the width of the screen/window.", "bash_code": "csvtopretty filename.csv | less -S" }, { "nl_command": "search for the word \"damian\" in all the regular/normal files in the /etc folder and display only the matched file name", "bash_code": "find /etc -type f | xargs grep -l -i \"damian\"" }, { "nl_command": "search for the file foo.txt in the entire file system", "bash_code": "find / -name foo.txt" }, { "nl_command": "Locate all *.csv regular files under the current directory tree", "bash_code": "find . -type f -name \"*.csv\"" }, { "nl_command": "Filnd all files in root directory with 777 permission and change permision 644 with chmod commad .", "bash_code": "find / -type f -perm 777 -print -exec chmod 644 {} \\;" }, { "nl_command": "display all directories in current folder and do not search in sub directories", "bash_code": "find . -maxdepth 1 -mindepth 1 -type d" }, { "nl_command": "Do a dry run of renaming file extension '.andnav' to '.tile' for all files/directories under current directory tree", "bash_code": "find . -name \"*.andnav\" | rename -vn \"s/\\.andnav$/.tile/\"" }, { "nl_command": "Remove what follows the forth occurrence of the character \":\" in any field which contains it", "bash_code": "perl -pe 's/({3}):\\S*/$1/g' file | column -t" }, { "nl_command": "SSH into $1 with login name 'pete'", "bash_code": "ssh \"$1\" -l pete" }, { "nl_command": "Find all directories in /path/to/dir/ without going into sub-directories and append a null character at the end of each paths", "bash_code": "find /path/to/dir/ -mindepth 1 -maxdepth 1 -type d -print0" }, { "nl_command": "convert all the png images in the current folder to jpg images", "bash_code": "find . -iname '*.png' | while read i; do mogrify -format jpg \"$i\" && rm \"$i\"; echo \"Converted $i to ${i%.*}.jpg\"; done" }, { "nl_command": "Append all regular files modified in the last 24 hours to the \"$archive.tar\" tar archive", "bash_code": "find . -mtime -1 -type f -print0 | xargs -0 tar rvf \"$archive.tar\"" }, { "nl_command": "List all empty files in the current directory tree", "bash_code": "find . -empty -exec ls {} \\;" }, { "nl_command": "find all files in the current folder that are not modified in the last 10 minutes", "bash_code": "find . -mmin +10 -print" }, { "nl_command": "Find all files/directories named '.todo' under $STORAGEFOLDER directory tree and print the parent directory names", "bash_code": "find \"$STORAGEFOLDER\" -name .todo -printf '%h\\n'" }, { "nl_command": "Add \"Added line\" on top of each *.py files under current directory", "bash_code": "for a in `find . -name '*.py'` ; do cp \"$a\" \"$a.cp\" ; echo \"Added line\" > \"$a\" ; cat \"$a.cp\" >> \"$a\" ; rm \"$a.cp\" ; done" }, { "nl_command": "List all files in /home/bozo/projects directory tree that were modified exactly one day ago.", "bash_code": "find /home/bozo/projects -mtime 1" }, { "nl_command": "Replace all instances of \";\" with \"\\n\" in \"bla@some.com;john@home.com\"", "bash_code": "echo \"bla@some.com;john@home.com\" | sed -e 's/;/\\n/g'" }, { "nl_command": "Merge colon-separated information from standard input and file1.txt where the first field of both files matches, print unpairable lines from standard input, replace missing fields with \"no-match\", and output the second field from standard input and the second and third field from file1.txt", "bash_code": "join -t, -o 1.2,2.2,2.3 -a 1 -e 'no-match' - <" }, { "nl_command": "Search the files under and below /directory/containing/files for \"text to search\"", "bash_code": "find /directory/containing/files -type f -print0 | xargs -0 grep \"text to search\"" }, { "nl_command": "Count the number of lines in every regular .rb file in the current directory tree", "bash_code": "find . -name \"*.rb\" -type f -exec wc -l \\{\\} \\;" }, { "nl_command": "find all instances of a specific file in the current directory and discard all the errors and remove all permission denied statements from search results", "bash_code": "find . -name \"openssl\" 2>&1 | sed '/Permission denied/d;'" }, { "nl_command": "Print \"Total generated: \" followed by the number of unique lines in \"$generated_ports\"", "bash_code": "echo \"Total generated: $(echo \"$generated_ports\" | sort | uniq | wc -l).\"" }, { "nl_command": "Copy /my/configfile to all empty directories of the $somedir directory tree", "bash_code": "find \"$somedir\" -type d -empty -exec cp /my/configfile {} \\;" }, { "nl_command": "Find all *.txt files under / and print their sizes and paths", "bash_code": "find / -name '*.txt' -exec du -hc {} \\;" }, { "nl_command": "Move all *.emlx files/directories under /path/to/folders/ to ./Messages/ directory", "bash_code": "find /path/to/folders/ -name \\*.emlx -print0 | xargs -0 -I {} mv {} ./Messages/" }, { "nl_command": "Find all files in the current user's home directory and its sub-directories with the optional constraints of \u043e\u043f\u0446\u0438\u044f_\u043f\u043e\u0438\u0441\u043a\u0430, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 and/or \u043e\u043f\u0446\u0438\u044f_\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f.", "bash_code": "find ~/ [\u043e\u043f\u0446\u0438\u044f_\u043f\u043e\u0438\u0441\u043a\u0430] [\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435] [\u043e\u043f\u0446\u0438\u044f_\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f]" }, { "nl_command": "display a long listing of all the xls or csv files in the entire file system", "bash_code": "find / -type f \\( -name \"*.xls\" -o -name \"*.csv\" \\) -exec ls -l {} \\;" }, { "nl_command": "set alias \"pwd\" for command \"echo -n $ | pbcopy'\"", "bash_code": "alias pwd='echo -n $ | pbcopy'" }, { "nl_command": "Display a long listing of all directories under '/nas' directory tree", "bash_code": "find /nas -type d -ls" }, { "nl_command": "search for the directory \"uploads\" in current folder and change the permission of the folder and all the files to 755", "bash_code": "find . -type d -name 'uploads' -print0 | xargs -0 chmod -R 755" }, { "nl_command": "search for all the non-hidden files in the current directory and do not search in the subfolders and dispaly their name and size.", "bash_code": "find . -maxdepth 1 -name '[!.]*' -printf 'Name: %16f Size: %6s\\n'" }, { "nl_command": "Change permissions of \"mksdcard\" to 755", "bash_code": "sudo chmod 755 mksdcard" }, { "nl_command": "delete all the mp4 files in the folder /home which are bigger than 10MB", "bash_code": "find /home -type f -name *.mp4 -size +10M -exec rm {} \\;" }, { "nl_command": "Find files and directories that are at least seven levels of nesting in the directory /usr/src excluding CVS directory", "bash_code": "find /usr/src -name CVS -prune -o -depth +6 -print" }, { "nl_command": "Sort tab separated file \"file\" using a version sort for field 6 and a numeric sort for field 7", "bash_code": "sort -t$'\\t' -k6V -k7n file" }, { "nl_command": "Find all the files that were modified within the last day", "bash_code": "find . -mtime -1" }, { "nl_command": "Search the /root directory recursively for the regular file named \"myfile\"", "bash_code": "find /root/ -name myfile -type f" }, { "nl_command": "Remove each unique item listed on standard input and do nothing if empty", "bash_code": "sort | uniq -u | xargs -r rm" }, { "nl_command": "Find all directories under 'test' directory tree that match the regex '[course*]' in their paths", "bash_code": "find test -regex \"[course*]\" -type d" }, { "nl_command": "Prints \"$NEWFILE\" to the terminal and file '/etc/timezone' as a root user.", "bash_code": "echo \"$NEWFILE\" | sudo tee /etc/apt/sources.list" }, { "nl_command": "Recursively counts non-blank lines in all files in a current folder, that match regex '\\.php|\\.as|\\.sql|\\.css|\\.js', but skip folders './pma', './blog', './punbb', './js/3rdparty' and files like '*.svn'.", "bash_code": "find . -path './pma' -prune -o -path './blog' -prune -o -path './punbb' -prune -o -path './js/3rdparty' -prune -o -print | egrep '\\.php|\\.as|\\.sql|\\.css|\\.js' | grep -v '\\.svn' | xargs cat | sed '/^\\s*$/d' | wc -l" }, { "nl_command": "Find all the *.c files at any level of directory Programming under any 'src' directory", "bash_code": "find ~/Programming -path '*/src/*.c'" }, { "nl_command": "Find all *.txt files under current directory that contains the regex 'pattern' and list them with their filenames and matches", "bash_code": "find . -type f -name '*.txt' -exec egrep pattern {} /dev/null \\;" }, { "nl_command": "Search the regular files of the current directory tree for string \"stuff\"", "bash_code": "find . -type f -exec grep -n \"stuff\" {} \\; -print" }, { "nl_command": "Find all regular files that reside in the current directory tree and were last modified more than 2 days ago", "bash_code": "find . -type f -mtime +2" }, { "nl_command": "Print space separated list of numbers from \"$start\" to \"$end\"", "bash_code": "echo `seq $start $end`" }, { "nl_command": "Find the process id of mysql", "bash_code": "ps -A|grep mysql" }, { "nl_command": "Print the current directory", "bash_code": "find -mindepth 0 -maxdepth 0" }, { "nl_command": "Find all files in maximum 2 levels down the current directory", "bash_code": "find . -maxdepth 2 -type f" }, { "nl_command": "Split \"database.sql\" into files of at most 100000 lines each with prefix \"database-\"", "bash_code": "split -l 100000 database.sql database-" }, { "nl_command": "prints top 10 commands used", "bash_code": "history | awk '{print $2}' | awk 'BEGIN {FS=\"|\"}{print $1}' | sort | uniq -c | sort -nr | head" }, { "nl_command": "Send SIGWINCH process to current shell, causing it to update the LINES and COLUMNS variables which describe the size of the screen/window in characters.", "bash_code": "kill -s WINCH $$" }, { "nl_command": "Write every two lines in \"infile\" on a single line separated by a space", "bash_code": "cat infile | paste -sd ' \\n'" }, { "nl_command": "Search for the case insensitive regex expanded by $2 in all files named $1 under current directory", "bash_code": "find . -name \"$1\" -type f -print0 | xargs -0 grep -i \"$2\"" }, { "nl_command": "Find hard links to the same file lpi104-6/file1 in the directory tree lpi104-6", "bash_code": "find lpi104-6 -samefile lpi104-6/file1" }, { "nl_command": "Locating large files (> 100 MB) in /home/ for 'cleaning'", "bash_code": "find /home -type f -size +100M -delete" }, { "nl_command": "display all the files in the home folder that have been modified in the last 24 hours", "bash_code": "find $HOME -mtime -1" }, { "nl_command": "Find files and directories in the /tmp/ tree that contain spaces in their names and replace those spaces with underscores", "bash_code": "find /tmp/ -depth -name \"* *\" -execdir rename 's/ /_/g' \"{}\" \\;" }, { "nl_command": "Find all directories in /path/to/dir/ without going into sub-directories and append a null character at the end of each paths", "bash_code": "find /path/to/dir/ -mindepth 1 -maxdepth 1 -type d -print0" }, { "nl_command": "find all the files older than 30 days", "bash_code": "find /tmp -mtime +30 -print" }, { "nl_command": "list all files in the current directory recursively", "bash_code": "find ." }, { "nl_command": "show the list of all the files in the current folder which have been modified within the 24 hours", "bash_code": "find . -mtime 0 -print" }, { "nl_command": "Numerically sort each line in file \"bb\" and output the result to console from greatest value to least value", "bash_code": "sort -nr bb" }, { "nl_command": "Search the specified user for the given \"filename\"", "bash_code": "find / -user pat -iname \"filename\"" }, { "nl_command": "Type unique list of all directories contiaining each file named 'myfile' under the /home directory", "bash_code": "find /home/ -name 'myfile' -type f | rev | cut -d \"/\" -f2- | rev | sort -u" }, { "nl_command": "Run 'otherscript.sh' script with all environment variables specified in the file 'xxxx'", "bash_code": "env `cat xxxx` otherscript.sh" }, { "nl_command": "Create a compressed archive named 'my_directory.tar.gz' with files inside directory 'my_directory' without including the directory entry 'my_directory' itself", "bash_code": "tar -czvf my_directory.tar.gz -C my_directory ." }, { "nl_command": "Set prompt to the system host name and history number", "bash_code": "PS1=\"`hostname`:\\!>\"" }, { "nl_command": "Find SUID files", "bash_code": "find / -perm +u=s" }, { "nl_command": "search for the folder .dummy and remove it from the folder \"Test folder\"", "bash_code": "find \"Test Folder\" -type d -name .dummy -exec rm -rf \\\"{}\\\" \\;" }, { "nl_command": "Recursively change ownership of \"/usr/local/lib\" to the current user", "bash_code": "sudo chown -R `whoami` /usr/local/lib" }, { "nl_command": "recursively change owner of the directory /usr/local/lib/node_modules/ to the current user", "bash_code": "sudo chown -R $USER /usr/local/lib/node_modules" }, { "nl_command": "Make directories to \"/tmp/test/blah/oops/something\" as needed", "bash_code": "mkdir -p /tmp/test/blah/oops/something" }, { "nl_command": "Find directories in the current directory tree that were modified within the last 24 hours and move them to /path/to/target-dir", "bash_code": "find . -type d -mtime -0 -exec mv -t /path/to/target-dir {} +" }, { "nl_command": "Copy all files in the current directory tree matching \"textToSearch\" to \"$destination_path\"", "bash_code": "find . -type f | xargs grep -l \"textToSearch\" | cpio -pV $destination_path" }, { "nl_command": "display all the files in the current folder which have not been modified in the last 7 days and which are not in the list \"file.lst\" and save the output to a file", "bash_code": "find -mtime +7 -print | grep -vf file.lst > found.lst" }, { "nl_command": "Displays info about users currently in system.", "bash_code": "\\w" }, { "nl_command": "Delete all files named 'sample' under '/home/user/Series' directory tree with superuser privilege", "bash_code": "sudo find /home/user/Series/ -iname sample -exec rm {} \\;" }, { "nl_command": "Raise an error if there is a reference to a non-existent environment variable and exit the shell immediately if there is any error", "bash_code": "set -eu" }, { "nl_command": "Prints number of files with extension \"${EXTENSION}\" in the \"${SEARCHPATH}\" directory.", "bash_code": "echo \"Number files in SEARCH PATH with EXTENSION:\" $(ls -1 \"${SEARCHPATH}\"/*.\"${EXTENSION}\" | wc -l)" }, { "nl_command": "Find all empty directories in the current one and delete them", "bash_code": "find . -type d -maxdepth 1 -empty -print0 | xargs -0 /bin/rmdir" }, { "nl_command": "Recursively removes all files like \"\" in a current folder.", "bash_code": "find . | grep -E \"\" | xargs rm -rf" }, { "nl_command": "Overwrites file $FILE with random content, then truncates and deletes it.", "bash_code": "shred -u $FILE" }, { "nl_command": "Run the file command on every regular file under current directory", "bash_code": "find . -type f -exec file '{}' \\;" }, { "nl_command": "Rename all .txt files to .bak in the current directory tree", "bash_code": "find . -name \"*.txt\" | sed \"s/\\.txt$//\" | xargs -i echo mv {}.txt {}.bak | sh" }, { "nl_command": "Find \"*prefs copy\" files in the /mnt/zip directory tree and remove them", "bash_code": "find /mnt/zip -name \"*prefs copy\" -print0 | xargs rm" }, { "nl_command": "Mount partition with label \"WHITE\" on \"/mnt/WHITE\"", "bash_code": "mount -L WHITE /mnt/WHITE" }, { "nl_command": "find all the files in the current folder which end with \"ext1\" or \"ext2\" or \"ext3\"", "bash_code": "find -E . -regex \".*ext1|.*ext2|.*ext3\"" }, { "nl_command": "Search for the string 'magic' in all regular files under current directory tree and display long listing of them", "bash_code": "find . -type f -exec grep \"magic\" {} \\; -ls" }, { "nl_command": "extract \"filename.tar.xz\" with verbose output", "bash_code": "$ tar xvfJ filename.tar.xz" }, { "nl_command": "Recursively find the latest modified file in the current directory and print the modification time and filename", "bash_code": "find . -type f -printf '%TY-%Tm-%Td %TH:%TM: %Tz %p\\n'| sort -n | tail -n1" }, { "nl_command": "Print a colon-separated list of all directories from the $root directory tree", "bash_code": "find $root -type d -printf '%p:'" }, { "nl_command": "Find recursively regular files in the directory given as the script's command line argument #1, skipping hidden files and directories", "bash_code": "find \"$1\" -path \"*/.*\" -prune -o \\( -type f -print0 \\)" }, { "nl_command": "Counts number of *.php files in a current folder and subfolders.", "bash_code": "find . -name '*.php' | wc -l" }, { "nl_command": "search for all the files in the folder /usr/bin which have not been accessed in the last 100*24 hours", "bash_code": "find /usr/bin -type f -atime +100" }, { "nl_command": "find StringBuffer in all *.java files", "bash_code": "find . -type f -name \"*.java\" -exec grep -l StringBuffer {} \\;" }, { "nl_command": "Move all directories under current directory to new paths obtained by replacing all occurrences of 'foo' with 'Bar' in their paths", "bash_code": "find . -type d -exec bash -c 'mv \"$1\" \"${1//foo/Bar}\"' -- {} \\;" }, { "nl_command": "Find all *.txt files under current directory and print their timestamps and paths", "bash_code": "find . -name \"*.txt\" -printf \"%T+ %p\\n\"" }, { "nl_command": "find the most recently changed files under current directory", "bash_code": "find . -type f -printf '%TY-%Tm-%Td %TT %p\\n' | sort" }, { "nl_command": "Show the subdirectories of the current directory", "bash_code": "find . -maxdepth 1 -type d -print | parallel -X echo Directories:" }, { "nl_command": "Start program 'scriptname' with an empty environment.", "bash_code": "env - scriptname" }, { "nl_command": "Display a dump of standard input as floating point values of double size", "bash_code": "od -t fD" }, { "nl_command": "Trim leading and trailing whitespace from variable 'var'.", "bash_code": "var=`echo $var | awk '{gsub}1'`" }, { "nl_command": "Print a count of each unique line in \"ip_addresses.txt\" sorted numerically", "bash_code": "sort -n ip_addresses.txt | uniq -c" }, { "nl_command": "change permissions for directories in the entire file system", "bash_code": "chmod 751 `find ./ -type d -print`" }, { "nl_command": "Search for $SEARCH in all regular files under $DIR directory tree and display the number of bytes of the matched output", "bash_code": "find $DIR -type f -exec grep $SEARCH /dev/null {} \\; | wc --bytes" }, { "nl_command": "find all \".flac\" files starting with \"cmn-\" and search for files having CJK characters using unicodes", "bash_code": "find . -name 'cmn-*.flac' -print | grep -P '[\\x4e00-\\x9fa5]'" }, { "nl_command": "Create symbolic links in the current directory for all files located in directory \"/path/with/files\" with a name containing \"txt\"", "bash_code": "find /path/with/files -type f -name \"*txt*\" -exec ln -s {} . ';'" }, { "nl_command": "Find files named \"ppp.conf\" in the /etc directory tree", "bash_code": "find /etc -name ppp.conf" }, { "nl_command": "Remove all regular files in the current directory", "bash_code": "find ./ -type f -exec rm -rf {} \\;" }, { "nl_command": "display all files in the entire file system", "bash_code": "find /" }, { "nl_command": "Find all files that have either a .php or a .js extension", "bash_code": "find -regextype posix-egrep -regex '.*$'" }, { "nl_command": "display all the text files in current folder and save the output to a file", "bash_code": "find . -name \"*.txt\" -printf \"%f\\n\" > /tmp/a" }, { "nl_command": "search the word \"MySearchStr\" in all the regular/normal files in the current folder and display the line number and the file name", "bash_code": "find . -type f -print0 | xargs -0 -e grep -nH -e MySearchStr" }, { "nl_command": "find file which name like 'foo.*' in current directory.", "bash_code": "find . -name \"foo.*\"" }, { "nl_command": "kill all jobs", "bash_code": "kill $(jobs -p)" }, { "nl_command": "Find all files modified less than 5 minutes ago, and page interactively through the output.", "bash_code": "find -cmin -5 | less -R" }, { "nl_command": "Rename .jpg files to .jpeg in all subdirectories of the current directory", "bash_code": "find . -maxdepth 2 -mindepth 2 -name '*.jpg' -exec sh -c 'echo mv -- \"$0\" \"${0%%.jpg}.jpeg\"' {} \\;" }, { "nl_command": "Get the total sizes of all files under current directory", "bash_code": "find . -type f -printf '%p %s\\n' | perl -n -a -e '$sum+=$F[1]; print \"$sum\\n\"' | tail -n 1" }, { "nl_command": "Search the current directory recursively for files containing \"string\"", "bash_code": "find . -type f -exec grep -l 'string' {} \\;" }, { "nl_command": "Search for 'example' in all regular files from the current directory tree", "bash_code": "find -type f -print0 | xargs -r0 grep -F 'example'" }, { "nl_command": "find directory which name is Cookbook under /users/al", "bash_code": "find /users/al -name Cookbook -type d" }, { "nl_command": "find all files in the current folder that are not modified in the last 10 minutes", "bash_code": "find . -mmin +10 -print" }, { "nl_command": "Search the src/ directory recursively for .c and .h files", "bash_code": "find src/ -name '*.[ch]'" }, { "nl_command": "display all shell scripts in current folder", "bash_code": "find . -name \"*.sh\"" }, { "nl_command": "Save first IP address of domain 'google.com' in 'address' variable", "bash_code": "address=$(dig +short google.com | grep -E '^[0-9.]+$' | head -n 1)" }, { "nl_command": "Find all executable files under {} and reverse sort them", "bash_code": "find {} -type f -depth 1 -perm +0111 | sort -r" }, { "nl_command": "Append the current date in '%d%m%Y-%H-%M' format, '_' and the current username, then save it in 'name' variable", "bash_code": "name=\"$(date +'%d%m%Y-%H-%M')_$(whoami)\"" }, { "nl_command": "Recursively finds all *.dbf files from the root folder and prints list of folders with such files.", "bash_code": "find / -name \\*.dbf -print0 | xargs -0 -n1 dirname | sort | uniq" }, { "nl_command": "split file \"your_file\" into pieces per 9 lines", "bash_code": "split -l9 your_file" }, { "nl_command": "Find all orm.* files/directories under current directory", "bash_code": "find . -name \"orm.*\"" }, { "nl_command": "searches through the root filesystem (\"/\") for the file named Chapter1.", "bash_code": "find / -name Chapter1 -type f" }, { "nl_command": "Find all files whose names do not begin with \"zsh\" on ext3 file systems", "bash_code": "find / -fstype ext3 -name zsh*" }, { "nl_command": "Replace \",,\" with \", ,\" in \"$file\" and display the \",\" delimited result as a table in \"less\" with a shift value of 5 and line numbers", "bash_code": "cat \"$file\" | sed -e 's/,,/, ,/g' | column -s, -t | less -#5 -N -S" }, { "nl_command": "Open a ssh connection to \"user@host\" with a control socket \"/tmp/%r@%h:%p\"", "bash_code": "ssh user@host -S /tmp/%r@%h:%p" }, { "nl_command": "Set 644 permission to all regular files under /home/my/special/folder directory", "bash_code": "chmod 644 `find /home/my/special/folder -type f`" }, { "nl_command": "Read a single character from standard input into variable \"runCommand\" with the prompt \"Pick a letter to run a command [A, B, or C for more info] \"", "bash_code": "read -n1 -p \"Pick a letter to run a command [A, B, or C for more info] \" runCommand" }, { "nl_command": "Print the second line of output of \"ls -l\"", "bash_code": "ls -l | tail -n +2 | head -n1" }, { "nl_command": "Copy *.mp3 files to /tmp/MusicFiles", "bash_code": "find . -type f -name \"*.mp3\" -exec cp {} /tmp/MusicFiles \\;" }, { "nl_command": "Find all files/directories with '.txt' extension that are less than 100 KB in size under '/home' directory tree", "bash_code": "find /home -name \"*.txt\" -size -100k" }, { "nl_command": "Read 10 bytes from $0 and print them by replacing the set '\\000-\\377' with '#'", "bash_code": "head -c 10 \"$0\" | tr '\\000-\\377' '#'" }, { "nl_command": "Show all of the .conf files in Pat's user folder and subdirectories using the less pager", "bash_code": "find /home/pat -iname \"*.conf\" | less" }, { "nl_command": "Search the current directory tree for files named \"somename\", case insensitive", "bash_code": "find -iname 'somename'" }, { "nl_command": "display all the text files in the current folder which have been modified in the last half minute ( 30 seconds )", "bash_code": "find . -mmin 0.5" }, { "nl_command": "Find files that have been modified within the last month and copy them somewhere", "bash_code": "find /etc/ -mtime -30 | xargs -0 cp /a/path" }, { "nl_command": "Find all files under current directory and run the command fromdos for each of them with the file path as argument", "bash_code": "find . -type f -exec fromdos {} \\;" }, { "nl_command": "Recursively copy \"dir_a\" to \"dir_b\" and delete any new files in \"dir_b\"", "bash_code": "rsync -u -r --delete dir_a dir_b" }, { "nl_command": "Change to directory 'xyz' and resolve any symlinks in the resulting path, making the physical path the current one.", "bash_code": "cd -P xyz" }, { "nl_command": "Search the Movies folder in the user's home directory for files larger than 1024 megabytes in size.", "bash_code": "find ~/Movies/ -size +1024M" }, { "nl_command": "List all regular files residing in the current directory tree and containing string \"/bin/ksh\"", "bash_code": "find . -type f -exec grep -li '/bin/ksh' {} \\;" }, { "nl_command": "find all the php files in the current folder (discards any directory which has an extension of \".php\")", "bash_code": "find . -name \\*.php -type f" }, { "nl_command": "Lists all running tmux sessions.", "bash_code": "tmux ls" }, { "nl_command": "List the directory paths of all file.ext files under present working directory", "bash_code": "find `pwd` -name file.ext |xargs -l1 dirname" }, { "nl_command": "Prints a process tree for each process of user 'username'.", "bash_code": "ps -aux | grep ^username | awk '{print $2}' | xargs pstree" }, { "nl_command": "Locate file \"file1\"", "bash_code": "find -name file1" }, { "nl_command": "Find all directories under htdocs directory and set their permission to 775", "bash_code": "find htdocs -type d -exec chmod 775 {} +" }, { "nl_command": "Creates temporary file with appended suffix '.cmd' and saves path to it in 'LGT_TEMP_FILE' variable.", "bash_code": "LGT_TEMP_FILE=\"$(mktemp --suffix .cmd)\"" }, { "nl_command": "Recursively search for all files not ending in \".xml\" under the current directory, append \".xml\" to the end of each file name", "bash_code": "find . -type f \\! -name '*.xml' -print0 | xargs -0 rename 's/$/.xml/'" }, { "nl_command": "search the entire file system for the file \"jan92.rpt\"", "bash_code": "find / -name jan92.rpt -print" }, { "nl_command": "Find all empty regular files in the current directory and below", "bash_code": "find . -type f -empty" }, { "nl_command": "Remove all *.mp3 files in tmp directory but not in it's subdirectories", "bash_code": "rm `find tmp -maxdepth 1 -name '*.mp3'`" }, { "nl_command": "List the names of the directories in current directory without going into sub-directories", "bash_code": "find . -maxdepth 1 -mindepth 1 -type d -printf '%f\\n'" }, { "nl_command": "Find and delete all core files in the user's home directory and below.", "bash_code": "find ~/ -name 'core*' -exec rm {} \\" }, { "nl_command": "sleep for 1 second", "bash_code": "sleep 1" }, { "nl_command": "Find all *.ogg files/directories under your home directory that are greater than 20MB in size", "bash_code": "find $HOME -iname '*.ogg' -size +20M" }, { "nl_command": "Calculate md5 sum of file $ecriv", "bash_code": "md5sum \"$ecriv\"" }, { "nl_command": "Print the directory name of the real full path of \"relative/path/to/file\" where each symbolic link component must exist", "bash_code": "dirname `readlink -e relative/path/to/file`" }, { "nl_command": "Prefix all files in the current directory with \"unix_\"", "bash_code": "for f in *; do [[ -f \"$f\" ]] && mv \"$f\" \"unix_$f\"; done" }, { "nl_command": "Execute 'top -n1 | grep mysql' every 2 seconds and highlight the differences between runs", "bash_code": "watch -d 'top -n1 | grep mysql'" }, { "nl_command": "Output the last slash-separated component of specified path, in this case \"data_report_PD_import_script_ABF1_6\"", "bash_code": "basename /EBF/DirectiveFiles/data_report_PD_import_script_ABF1_6" }, { "nl_command": "Print login name and full name of all users currently logged in and delete instances of \"of group.*\"", "bash_code": "finger -l | awk '/^Login/' | sed 's/of group.*//g'" }, { "nl_command": "Sort file \"foo.txt\" by line to standard output", "bash_code": "sort foo.txt" }, { "nl_command": "Forcibly removes ${temp} file.", "bash_code": "rm --force \"${temp}\"" }, { "nl_command": "Find directories with permissions 777 and change them to 755 recursively", "bash_code": "find /home -type d -perm 777 -print -exec chmod 755 {} \\;" }, { "nl_command": "Run `fastqc' on all the fastqc files in the current directory tree", "bash_code": "find . -name \"*.fq.gz\" -exec gunzip -c '{}' ';' | fastqc /dev/stdin" }, { "nl_command": "Print a list of all duplicate filenames in the current directory tree if there is no white space in filenames", "bash_code": "find . |sed 's,\\(.*\\)/\\(.*\\)$,\\1/\\2\\t\\1/\\L\\2,'|sort|uniq -D -f 1|cut -f 1" }, { "nl_command": "Find all files/directories that do not belong to any user under '/home' directory tree", "bash_code": "find /home -nouser -print" }, { "nl_command": "Find all regular files in the current directory tree that are not readable by anyone", "bash_code": "find . -type f ! -perm -444" }, { "nl_command": "Write to standard error a trace for each command after it expands the command and before it executes it", "bash_code": "set -x" }, { "nl_command": "Search for 'whatIWantToFind' in all files under current directory", "bash_code": "find . -exec grep whatIWantToFind {} \\;" }, { "nl_command": "find all directories in the current directory", "bash_code": "find . -type d -name \"*\"" }, { "nl_command": "File \"files.txt\" contains a list of files, copy all files listed to host \"remote\", connecting as ssh user \"user\", and copying the files to this user's home directory - this will not work with files/directory names containing spaces.", "bash_code": "cat files.txt | xargs scp user@remote:" }, { "nl_command": "Remove all files under /home/user/Maildir/.SPAM/cur", "bash_code": "find /home/user/Maildir/.SPAM/cur -type f | xargs rm" }, { "nl_command": "Insert \"|\" every 30 characters in file \"longline\"", "bash_code": "fold -w30 longline | pr -20ts'|'" }, { "nl_command": "Delete all files in the current directory tree whose names end with ~", "bash_code": "find . -name \"*~\" -exec rm {} \\;" }, { "nl_command": "find all instances of a file in current folder and discard the errors", "bash_code": "find . -name \"my.txt\" 2>/dev/null" }, { "nl_command": "Locate all \"copyright\" files under and below /usr/share/doc", "bash_code": "find /usr/share/doc -name \"copyright\"" }, { "nl_command": "download content from \"http://example.com/textfile.txt\" and output to \"textfile.txt\"", "bash_code": "curl http://example.com/textfile.txt -o textfile.txt" }, { "nl_command": "Find all files named \"file.ext\" in the current directory tree and print the path names of the directories they are in", "bash_code": "find `pwd` -name \"file.ext\" -exec echo $ \\;" }, { "nl_command": "search for the word \"mysql\" in all the files in the current containing the word \"notes\" in their name. print0 is used to handle files with newlines in their names or those which have only spaces in their names", "bash_code": "find . -iname \"*notes*\" -print0 | xargs -I{} -0 grep -i mysql \"{}\"" }, { "nl_command": "display all the files in the current folder which have the permissions 777 and which have been modified in the last 24 hours.", "bash_code": "find . -perm 777 -mtime 0 -print" }, { "nl_command": "Connect to host \"hostname\" as user \"username\", automatically add the host key to the list of known hosts, and execute \"pwd; ls\" non-interactively", "bash_code": "ssh -o StrictHostKeyChecking=no -l username hostname \"pwd; ls\"" }, { "nl_command": "find all files that match \"[a-f0-9\\-]{36}\\.jpg\" of grep", "bash_code": "find . * | grep -P \"[a-f0-9\\-]{36}\\.jpg\"" }, { "nl_command": "Remove trailing white spaces from all files under dir directory and keep backups of the originals", "bash_code": "find dir -type f -print0 | xargs -0 sed -i .bak -E \"s/[[:space:]]*$//\"" }, { "nl_command": "Change directory to the directory containing the current script", "bash_code": "cd $(dirname $(which $0) )" }, { "nl_command": "Make directory \"subdirectory\"", "bash_code": "mkdir subdirectory" }, { "nl_command": "Find all files/directories in 1 level down the current directory", "bash_code": "find -mindepth 1 -maxdepth 1" }, { "nl_command": "Export full path of command \"git\" to variable \"git\"", "bash_code": "export git=$" }, { "nl_command": "Get files that last had their meta information changed more than 3 days ago", "bash_code": "find / -ctime +3" }, { "nl_command": "Archive \"./dir\" to \"user@host:/path\" via ssh on port 2222 and display progress", "bash_code": "rsync -rvz -e 'ssh -p 2222' --progress ./dir user@host:/path" }, { "nl_command": "Saves list of logged in users in system together with 'USER' header in the 'b' variable.", "bash_code": "b=`w|cut -d' ' -f1`;" }, { "nl_command": "Numerically sort each line of standard input", "bash_code": "sort -n" }, { "nl_command": "Delete all hidden files/directories under $some_directory", "bash_code": "find \"$some_directory\" -name '.*' ! -name '.' ! -name '..' -delete" }, { "nl_command": "find all the zip files in the current folder and create a tar ball of these zip files", "bash_code": "find . -type f -name '*.zip' -print0 | xargs -0 tar -xzf" }, { "nl_command": "Execute `find -type f | egrep -i \"(jpg|bmp|png|gif)$\"` every 300 seconds and display without title", "bash_code": "watch -n 300 -t `find -type f | egrep -i \"(jpg|bmp|png|gif)$\"`" }, { "nl_command": "Unzip \"file.gz\" to stdout", "bash_code": "zcat file.gz" }, { "nl_command": "Check if a drive with UUID \"$UUID\" is mounted", "bash_code": "mount | grep $" }, { "nl_command": "Print sorted list of unique users logged in followed by a total count", "bash_code": "who | awk '{ print $1; }' | sort -u | awk '{print $1; u++} END{ print \"users: \" u}'" }, { "nl_command": "create symbolic links in current directory to all files located in directory \"/original\" and have filename extension \".processname\"", "bash_code": "ln -s $ ." }, { "nl_command": "Locate and rename unprintable directories using inode numbers", "bash_code": "find . -inum 211028 -exec mv {} newname.dir \\;" }, { "nl_command": "Find all files/directories with space in their names under current directory and rename them by replacing all spaces with _", "bash_code": "find . -depth -name \"* *\" -execdir rename \"s/ /_/g\" \"{}\" \\;" }, { "nl_command": "Find all files under /path/to/Dir and set their permission to 644", "bash_code": "sudo find /path/to/Dir -type f -print0 | xargs -0 sudo chmod 644" }, { "nl_command": "Create a symbolic link named \"$tmpdir/bam\" to the full path of command \"bam2\" found in \"$PATH\"", "bash_code": "ln -s \"$\" \"$tmpdir\"/bam" }, { "nl_command": "List files/directories at least three levels down the directory tree", "bash_code": "find / -mindepth 3 -name \"*log\"" }, { "nl_command": "Unzip and merge all \"small-*.gz\" files into files of 2000000 lines", "bash_code": "zcat small-*.gz | split -d -l2000000 -a 3 - large_" }, { "nl_command": "Move all files and directories matching \"*.boo\" in the current directory to \"subdir\"", "bash_code": "mv `ls *.boo` subdir" }, { "nl_command": "Getting a detailed list of files/dirs", "bash_code": "find / -name \"apt\" -ls" }, { "nl_command": "Go back to last directory.", "bash_code": "cd -" }, { "nl_command": "Find all files under current directory and print only the filenames (not paths)", "bash_code": "find . -type f -printf \"%f\\n\"" }, { "nl_command": "Find files whose name starts with \"MyFile\", ignoring the case", "bash_code": "find . -iname 'MyFile*'" }, { "nl_command": "Change permissions to 644 for all regular files under the /path/to/dir/ tree unless these permissions are already set", "bash_code": "find /path/to/dir/ -type f ! -perm 0644 -print0 | xargs -0 chmod 644" }, { "nl_command": "Get a recursive file list of directory $dir", "bash_code": "find \"$dir\" -type f" }, { "nl_command": "Find all files/directories under /myfiles that were accessed more than 30 days ago", "bash_code": "find /myfiles -atime +30" }, { "nl_command": "Print A record for domain 'domain.' from 'ns2.newnameserver' nameserver", "bash_code": "dig @ns2.newnameserver domain. a" }, { "nl_command": "search for a word in all the php files in the current folder and display the matching lines", "bash_code": "find . -name \\*.php -type f -exec grep -Hn '$test' {} \\;" }, { "nl_command": "change owner and group of all files and directory into current directory to user and group apache", "bash_code": "find . -maxdepth 1 -not -name \".\" -print0 | xargs --null chown -R apache:apache" }, { "nl_command": "create an archive excluding files and directories matching {*.png, *.mp3, *.wav, .git, node_modules}", "bash_code": "tar --exclude={*.png,*.mp3,*.wav,.git,node_modules} -Jcf ${target_tarball} ${source_dirname}" }, { "nl_command": "find all the .jpg files in / and copy them to the current folder.", "bash_code": "find / -type f -name *.jpg -exec cp {} . \\;" }, { "nl_command": "search for multiple files in the current folder", "bash_code": "find . -name photoA.jpg photoB.jpg photoC.jpg" }, { "nl_command": "Create a directory named 'alpha_real' in the current directory", "bash_code": "mkdir alpha_real" }, { "nl_command": "Change permissions to 644 recursively only for files", "bash_code": "find . -type f -exec chmod 644 {} \\;" }, { "nl_command": "Display standard input as a table with \"${tab}\" separators", "bash_code": "column -s\"${tab}\" -t" }, { "nl_command": "Compresses file 'example.log' keeping original file in place.", "bash_code": "bzip2 -k example.log" }, { "nl_command": "Remove files from the file system that are owned by nobody", "bash_code": "find / -nouser -exec rm {} +" }, { "nl_command": "search for a word in all the regular files in the current folder without traversing the sub directories .", "bash_code": "find -maxdepth 1 -type f | xargs grep -F 'example'" }, { "nl_command": "Find all regular files under $FILES_PATH directory tree and save the output to 'FILES' variable", "bash_code": "FILES=$" }, { "nl_command": "display long listing of all the text files in the current folder", "bash_code": "find . -name \"*.txt\" -exec ls -la {} \\;" }, { "nl_command": "Delete all files in the current user's home directory and its sub-directories that have not been accessed for more than 100 days.", "bash_code": "find ~ -atime +100 -delete" }, { "nl_command": "Find recursively all Python files in the current directory tree and count the number of lines in them", "bash_code": "find . -name '*.py' | xargs wc -l" }, { "nl_command": "List environment variables whose name contains \"X\"", "bash_code": "set | cut -d= -f1 | grep X" }, { "nl_command": "Remove all directories in and below the current directory", "bash_code": "find \\! -name . -type d -print0 | xargs -0 rmdir" }, { "nl_command": "Create a zip file of all *.log files under $sourcePath", "bash_code": "find $sourcePath -type f -name \"*.log\" | xargs zip $zipFile -@" }, { "nl_command": "Search directory tree `foo' for files named `Headers'", "bash_code": "find foo -name Headers" }, { "nl_command": "Prints current month calendar, without highlighting of a current date.", "bash_code": "cal -h" }, { "nl_command": "Search for .zip files that are larger than 100M found anywhere in the file system and delete those files.", "bash_code": "find / -type f -name *.zip -size +100M -exec rm -i {} \\;" }, { "nl_command": "Finds name of a current month and saves it in a 'month' variable.", "bash_code": "month=$(cal | head -1 | grep -oP \"[A-Za-z]+\")" }, { "nl_command": "Save the first three octets of the current host's IP address to variable \"local\"", "bash_code": "local=$" }, { "nl_command": "Find all files in the current directory tree whose names are \".DS_STORE\" and delete them", "bash_code": "find . -name \".DS_STORE\" -delete" }, { "nl_command": "Find all broken symlinks under current directory", "bash_code": "find ./ -type l -exec file {} \\; |grep broken" }, { "nl_command": "Recursively change owner and group of \"/usr/local/rvm/gems/ruby-2.0.0-p481/\" to the current user", "bash_code": "sudo chown $(whoami):$(whoami) /usr/local/rvm/gems/ruby-2.0.0-p481/ -R" }, { "nl_command": "List the files/directories under /PATH_to_SEARCH, do a numeric sort and print the ones with different inode numbers", "bash_code": "find /PATH_to_SEARCH -ls | sort -n | awk '!seen[$1]++'" }, { "nl_command": "search for all the directories in the current directory and do not search in sub directories", "bash_code": "find . -mindepth 1 -maxdepth 1 -type d" }, { "nl_command": "create a symbolic link named \"-pdf-kundendienst\" to \"local--pdf-kundendienst\" file", "bash_code": "ln -s -- ./local--pdf-kundendienst -pdf-kundendienst" }, { "nl_command": "List recursively all files and directories in /var/www", "bash_code": "find /var/www" }, { "nl_command": "Search the /dir directory tree for files whose names match regular expression '2015.*'", "bash_code": "find /dir|egrep '2015.*'" }, { "nl_command": "Remove all files with a txt extension under current directory", "bash_code": "find . -type f -name \"*.txt\" -exec rm {} \\; -print" }, { "nl_command": "display all the files in the current folder excluding the file states_to_csv.pl and those that are present in the directories whose name starts with \".git\"", "bash_code": "find . \\! -path \"./.git*\" -a \\! -name states_to_csv.pl" }, { "nl_command": "SSH into \"$NAME\" as user \"${USERNAME}\" using key file \"${KEYDIR}/${KEY}.pem\", automatically add the host to list of known hosts and execute \"${COMMANDS}\"", "bash_code": "ssh -o \"StrictHostKeyChecking no\" -i ${KEYDIR}/${KEY}.pem ${USERNAME}@$NAME \"${COMMANDS}\"" }, { "nl_command": "Find all files under current directory and set read-write permission for owner, read permission for group and no permission for other for those files", "bash_code": "find . -type f -exec chmod u=rw,g=r,o= '{}' \\;" }, { "nl_command": "list files in /usr modified after February 1 of the current year", "bash_code": "find /usr -newermt \"Feb 1\"" }, { "nl_command": "Find all regular files under current directory non-recursively that have execute permission set for all", "bash_code": "find . -maxdepth 1 -type f -perm -uga=x" }, { "nl_command": "find all the files ending with \".coffee\" in the current folder and search for the words \"re\" in each line", "bash_code": "find . -name \\*.coffee -exec grep -m1 -i 're' {} \\;" }, { "nl_command": "Move all files from the `sourceDir' directory to the `destDir' directory", "bash_code": "find sourceDir -mindepth 1 -maxdepth 1 -exec mv --target-directory=destDir '{}' +" }, { "nl_command": "force delete all the regular/normal files in the current folder", "bash_code": "find . -type f -exec rm -fv {} \\;" }, { "nl_command": "display all directories in current folder", "bash_code": "find -type d" }, { "nl_command": "For each line of colon-separated information in files 'empsal' and 'empname' whose first field matches in both files, output: first field of empname, second field of empname, fourth field of empname, and third field of empsal.", "bash_code": "join -j 1 -t : -o 2.1,2.2,2.4,1.3 < <" }, { "nl_command": "Allow anyone to run command \"Xvfb\" as the owner of \"Xvfb\"", "bash_code": "sudo chmod u+s `which Xvfb`" }, { "nl_command": "find all the undo files in the current folder and display the toal lines, words, characters", "bash_code": "find ./ -name *.undo | xargs wc" }, { "nl_command": "display the count of regular/normal files in the current folder do not search in sub directories", "bash_code": "find . -maxdepth 1 -type f |wc -l" }, { "nl_command": "Find all the .mp3 files in the music folder and pass to the ls command, -print0 is required if any filenames contain whitespace", "bash_code": "find ./music -name \"*.mp3\" -print0 | xargs -0 ls" }, { "nl_command": "Find out all hard links in the /home directory to file1", "bash_code": "find /home -xdev -samefile file1" }, { "nl_command": "delete all the hidden in the folder Musica after user confirmation", "bash_code": "find M\u00fasica/* -type f -name \".*\" -exec /usr/bin/rm -i {} \\;" }, { "nl_command": "Search for files specifying the maximum depth of the search", "bash_code": "find -maxdepth num -name query" }, { "nl_command": "Find files in the /home/user directory tree changed exactly 10 minutes ago", "bash_code": "find /home/user/ -cmin 10 -print" }, { "nl_command": "split the file data.csv into pieces per 100 mb named as data.tsv.NNN with digital prefixes", "bash_code": "split -C 100m -d data.tsv data.tsv." }, { "nl_command": "Displays the count of of each unique line read from standard input", "bash_code": "sort | uniq -c" }, { "nl_command": "Make directory \"new_dir\"", "bash_code": "mkdir new_dir" }, { "nl_command": "Find all files/directories named 'photoA.jpg' under current directory tree", "bash_code": "find . -name photoA.jpg" }, { "nl_command": "Make directory \"/etc/cron.minute\"", "bash_code": "mkdir /etc/cron.minute" }, { "nl_command": "Find all .txt files in the /home/user1 directory tree and copy them to /home/backup", "bash_code": "find /home/user1 -name '*.txt' | xargs cp -av --target-directory=/home/backup/ --parents" }, { "nl_command": "Find all files/directories that belong to the group 'audio' under '/dev' directory tree", "bash_code": "find /dev -group audio" }, { "nl_command": "Look for regular files in the directory trees 'deferred', 'active', 'maildrop', 'incoming' under /var/spool/postfix/", "bash_code": "find /var/spool/postfix/{deferred,active,maildrop,incoming}/ -type f" }, { "nl_command": "Print your/dir if it's empty", "bash_code": "find your/dir -prune -empty" }, { "nl_command": "Print 'cp' commands that would copy a file xyz.c to all the files with '.c' extension present in the ./C directory and below", "bash_code": "find ./C -name \"*.c\" | xargs -n1 echo cp xyz.c" }, { "nl_command": "Compress every file in the current directory that matches \"*cache.html\" and keep the original file", "bash_code": "gzip -k *cache.html" }, { "nl_command": "find all files in etc which have been changed in the last 1 day", "bash_code": "find /etc -daystart -ctime -1" }, { "nl_command": "Show the subdirectories of the current directory", "bash_code": "find . -maxdepth 1 -type d -print | xargs -I {} echo Directory: {}" }, { "nl_command": "Counts total lines in all *.php files in the current directory recursively", "bash_code": "find . -name '*.php' -type f | xargs cat | wc -l" }, { "nl_command": "Remove all .gz files in the current directory tree", "bash_code": "find . -name '*.gz' -type f -printf '\"%p\"\\n' | xargs rm -f" }, { "nl_command": "Find all files under /var/www directory and set their permission to 644", "bash_code": "sudo find /var/www -type f -print0 | xargs -0 chmod 644" }, { "nl_command": "Enables shell options 'expand_aliases', 'extglob', 'xpg_echo'.", "bash_code": "shopt -s expand_aliases extglob xpg_echo" }, { "nl_command": "Find all files/directories that belong to the group 'accts' under '/apps' directory tree", "bash_code": "find /apps -group accts -print" }, { "nl_command": "Save the logical current working directory to variable \"basedir\"", "bash_code": "basedir=$(pwd -L)" }, { "nl_command": "find all the files that have been modified in the last 1 day", "bash_code": "find . -type f -daystart -mtime -1" }, { "nl_command": "Read a line from standard input with prompt \"Are you sure? [Y/n]\" and save response in variable \"response\"", "bash_code": "read -r -p \"Are you sure? [Y/n]\" response" }, { "nl_command": "List all files/directories under current directory with 'FooBar' in their names ensuring white space safety", "bash_code": "find . -name 'FooBar' -print0 | xargs -0" }, { "nl_command": "Find all OGG files in the home directory larger than 20 megabytes", "bash_code": "find $HOME -iname '*.ogg' -size +20M" }, { "nl_command": "Print the output of history without line numbers", "bash_code": "history | cut -d' ' -f4- | sed 's/^ \\/\\1/g'" }, { "nl_command": "Print '111 22 3\\n4 555 66\\n' by replacing the spaces with tabs and '\\n' with newlines", "bash_code": "echo -en '111 22 3\\n4 555 66\\n' | tr ' ' '\\t'" }, { "nl_command": "display all the html files in the current folder", "bash_code": "find . -name \"*.html\" -print" }, { "nl_command": "search for all the mp3 files in the file system and move them to the folder /mnt/mp3", "bash_code": "find / -iname \"*.mp3\" -exec mv {} /mnt/mp3 \\;" }, { "nl_command": "SSH into \"myhost.com\" as user \"myname\" with a check every 60 seconds that the server is still alive", "bash_code": "ssh -o ServerAliveInterval=60 myname@myhost.com" }, { "nl_command": "Sets shell options 'globstar', 'dotglob' and 'nullglob'.", "bash_code": "shopt -s globstar nullglob dotglob" }, { "nl_command": "find all the text files in the current folder and display the results pagewise", "bash_code": "find . -name \"*.txt\" -print | less" }, { "nl_command": "Change permissions to 600 for all regular .rb files in the current directory tree", "bash_code": "find . -name \"*.rb\" -type f -exec chmod 600 {} \\;" }, { "nl_command": "Format file \"list-of-entries.txt\" as new-line separated columns", "bash_code": "column -t -s $'\\n' list-of-entries.txt" }, { "nl_command": "Recursively finds all files not like *.itp, *ane.gro, *.top in a current folder and removes them.", "bash_code": "find . -depth -type f -not -name *.itp -and -not -name *ane.gro -and -not -name *.top -exec rm '{}' +" }, { "nl_command": "Remove all broken symlinks from the /usr/ports/packages directory tree", "bash_code": "find -L /usr/ports/packages -type l -delete" }, { "nl_command": "find all the normal/regualar files in the current folder which have a size of 10KB and display a long listing details of them.", "bash_code": "find . -type f -size +10000 -exec ls -al {} \\;" }, { "nl_command": "find for xml files in current folder using regular expressions", "bash_code": "find ./ -regex \"cmn-.*[\\x4e00-\\x9fa5]*\\.xml\"" }, { "nl_command": "Display all files in a folder", "bash_code": "find /usr/X11/man/man5 -print" }, { "nl_command": "Find out if there are any files on the system owned by user `account'", "bash_code": "find / -path /proc -prune -o -user account -ls" }, { "nl_command": "Search the /myfiles directory tree for files whose names contain \"blue\"", "bash_code": "find /myfiles -name '*blue*'" }, { "nl_command": "Archive all filepattern-*2009* files/directories under data/ into 2009.tar", "bash_code": "find data/ -name 'filepattern-*2009*' -exec tar uf 2009.tar '{}' +" }, { "nl_command": "display all the files in the current folder which have been modified in the last 14*24 hours", "bash_code": "find . -mtime -14 -print" }, { "nl_command": "Cut off three last symbols from string '1234567890 *'", "bash_code": "echo '1234567890 *' | rev | cut -c 4- | rev" }, { "nl_command": "Send 4 ping requests to host \"google.comz\", displaying only the summary info after the last request completed.", "bash_code": "ping -c 4 -q google.comz" }, { "nl_command": "Find all .mpg files in the current ditrectory tree and convert them to the MP4 format", "bash_code": "find . -name \"*.mpg\" -type f -print0 | xargs -0 -I {} -n 1 -P 4 ffmpeg -i {} {}.mp4" }, { "nl_command": "Print amount of space available on the file system containing path to the current working directory in megabytes.", "bash_code": "df . -B MB | tail -1 | awk {'print $4'} | cut -d'%' -f1" }, { "nl_command": "Serach for all the files containing grep in man pages", "bash_code": "find /usr/share/man/ -regex .*grep*" }, { "nl_command": "Find all files and directories under current directory", "bash_code": "find ." }, { "nl_command": "find all the file which name end with c or h and content contain 'thing'", "bash_code": "find . -name '*.[ch]' | xargs grep -l thing" }, { "nl_command": "replaces the second to last line of file", "bash_code": "tac file | sed '2 s/,$//' | tac" }, { "nl_command": "display a long listing of all the regular/normal files in the current folder", "bash_code": "find . -type f -ls" }, { "nl_command": "Search for the case insensitive pattern 'PATTERN' in all files under current directory tree and display the matched files", "bash_code": "find . -print | xargs grep -l -i \"PATTERN\"" }, { "nl_command": "Print full date of yesterday", "bash_code": "echo `date -v-1d +%F`" }, { "nl_command": "display all the files ending with .c in the current folder", "bash_code": "find . -name \\*.c -print0" }, { "nl_command": "find all the jpg images in the folder /path/to/files and convert them into pdf.", "bash_code": "find /path/to/files -iname '*.jpg' -exec mogrify -format pdf {} +" }, { "nl_command": "List all files and directories (including hidden) in the current working directory in a long list format sorted by the oldest modification time", "bash_code": "ls -alrt `pwd`/*" }, { "nl_command": "Delete every second line from output of \"seq 10\"", "bash_code": "seq 10 | sed '0~2d'" }, { "nl_command": "Find files created in the last minute; works on Mac OS X", "bash_code": "find / -newerct '1 minute ago' -print" }, { "nl_command": "Print information about all users who are logged in", "bash_code": "who -la" }, { "nl_command": "Create a symbolic link in target directory \"~/newlinks\" to \"$source\"", "bash_code": "ln -s \"$source\" -t ~/newlinks" }, { "nl_command": "Replace spaces with underscores in the names of all files and directories in the \"/tmp\" directory tree", "bash_code": "find /tmp/ -depth -name \"* *\" -execdir rename 's/ /_/g' \"{}\" \\;" }, { "nl_command": "Copy a file xyz.c to all directories or over all files matching the letter 'c' at the end of their names under current directory tree", "bash_code": "find . -name \"*c\" -print0 | xargs -0 -n1 cp xyz.c" }, { "nl_command": "Find all *.p[lm] files/directories under current directory", "bash_code": "find -name '*.p[lm]'" }, { "nl_command": "List the names of all files under current directory", "bash_code": "find . -type f -exec basename {} \\;" }, { "nl_command": "Print the full name of \"$USER\"", "bash_code": "finger $USER |head -n1 |cut -d : -f3" }, { "nl_command": "Find all *.mp3 files in entire file system greater than 10MB and delete them", "bash_code": "find / -type f -name *.mp3 -size +10M -exec rm {} \\;" }, { "nl_command": "Print the first 2 lines of tree's help message by redirecting it from standard error to standard output", "bash_code": "tree --help |& head -n2" }, { "nl_command": "Search for files/directories with the case insensitive pattern anaconda* in /var/log", "bash_code": "find /var/log/ -iname anaconda*" }, { "nl_command": "Search the current directory tree for files larger than 10MB but smaller than 50MB", "bash_code": "find . -size +10M -size -50M -print" }, { "nl_command": "Find all *.php (case insensitive) files and *.js files/directories (case insensitive) under /home/jul/here excluding *.js files/directories under /home/jul/here/exclude/* paths", "bash_code": "find /home/jul/here -type f -iname \"*.php\" -o -iname \"*.js\" ! -path \"/home/jul/here/exclude/*\"" }, { "nl_command": "Saves byte size of all content of $1 folder in 'uiTotalSize' variable.", "bash_code": "uiTotalSize=$" }, { "nl_command": "Search for all files with either \"sitesearch\" or \"demo\" in their path names", "bash_code": "find . -iregex '.*sitesearch.*' -iregex '.*demo.*'" }, { "nl_command": "Remount \"/\" without writing in \"/etc/mtab\"", "bash_code": "mount -n -o remount /" }, { "nl_command": "Replace the first occurrence of \"string1\" on each line with \"string2\" in all regular files in the current directory tree", "bash_code": "find ./ -type f -exec sed -i 's/string1/string2/' {} \\;" }, { "nl_command": "Replace \"foo\" with \"bar\" in all PHP files in the current directory tree", "bash_code": "find . -name \"*.php\" -exec sed -i 's/foo/bar/g' {} \\;" }, { "nl_command": "display all the .sh scripts in the folder /usr", "bash_code": "find /usr -name '*.sh'" }, { "nl_command": "change the extension of all the \".lst\" files in the current folder to \"a.lst\"", "bash_code": "find -name \u2018*.lst\u2019 -exec rename .lst a.lst {} \\;" }, { "nl_command": "find all the bit map files in the current folder and convert them to .png", "bash_code": "find . -name \"*bmp\" -print0 | xargs -0 -l -i basename \"{}\" \".bmp\" | xargs -0 -l -i convert \"{}.bmp\" \"{}.png\"" }, { "nl_command": "Find all files/directories under current directory in maximum 3 levels deep", "bash_code": "find -maxdepth 3" }, { "nl_command": "Find all files in current directory and execute multiple commands for each file", "bash_code": "find . -type f -exec sh -c 'echo first; true' \\; -exec echo second \\;" }, { "nl_command": "search in current directory downwards all files which were accessed exactly 7 days back", "bash_code": "find . -atime 7 -print" }, { "nl_command": "Find all files/directories under current directory and put the output into full_backup_dir variable", "bash_code": "full_backup_dir=\"`find . -depth -print0`\"" }, { "nl_command": "Make directorie 'es_MX.utf8/LC_MESSAGES' as needed in the current directory", "bash_code": "mkdir --parents ./es_MX.utf8/LC_MESSAGES" }, { "nl_command": "Give all files in the /path/to/base/dir tree read privileges", "bash_code": "find /path/to/base/dir -type f -exec chmod 644 {} +" }, { "nl_command": "Go to directory /cygdrive/c/Program Files (x86)/$dollarsign using single quotes to escape special characters, including dollar signs", "bash_code": "cd '/cygdrive/c/Program Files (x86)/$dollarsign'" }, { "nl_command": "display all the files in the current folder which do not belong to any user", "bash_code": "find . -nouser" }, { "nl_command": "Delete all hidden files in the directory tree given as variable $FOLDER", "bash_code": "find $FOLDER -name \".*\" -delete" }, { "nl_command": "Recursively find the latest modified \"zip\" file in the current directory", "bash_code": "find . -name \"*zip\" -type f | xargs ls -ltr | tail -1" }, { "nl_command": "check if there any files from the .git folder after excluding it using the prune command", "bash_code": "find . -path ./.git -prune -o -print -a \\( -type f -o -type l -o -type d \\) | grep '.git'" }, { "nl_command": "Unzip file \"$empty_variable\"", "bash_code": "gunzip $empty_variable" }, { "nl_command": "Change the permission to 644 for all files under current directory", "bash_code": "find . -type f | xargs -I{} chmod -v 644 {}" }, { "nl_command": "Write current directory listing to standard output and to \"files.txt\"", "bash_code": "ls |& tee files.txt" }, { "nl_command": "Display a long listing of all files/directories that are bigger than 10MB under '/var/' directory tree", "bash_code": "find /var/ -size +10M -ls" }, { "nl_command": "Get the grandparent directory of each found 'pattern' file in $SEARCH_PATH", "bash_code": "find \"$SEARCH_PATH\" -name 'pattern' | rev | cut -d'/' -f3- | rev" }, { "nl_command": "Find all executable symlinks or upvoter-* files under maximum 1 level down the {} directory", "bash_code": "find {} -name 'upvoter-*' -type f -or \\ -maxdepth 1 -perm +111" }, { "nl_command": "find all files ending with \"js.compiled\" in current folder", "bash_code": "find ./js/ -name \"*.js.compiled\" -print0" }, { "nl_command": "search for all the files in the current directory which have the name a.out or core or which end with .o and delete them.", "bash_code": "find . \\ -exec rm {} \\;" }, { "nl_command": "Exclude directory from find . command", "bash_code": "find ! -path \"dir1\" -iname \"*.mp3\"" }, { "nl_command": "Write output of \"ls -hal /root/\" to standard output and to \"/root/test.out\"", "bash_code": "ls -hal /root/ | sudo tee /root/test.out" }, { "nl_command": "search for files in the current folder ending with \".au\" and save the output to the file names.txt", "bash_code": "find -type f -name '*.au' > names.txt" }, { "nl_command": "Print ls output for all non-empty files under under current directory", "bash_code": "find . -type f ! -size 0 -exec ls -l '{}' \\;" }, { "nl_command": "find all the files in the folder /work which belong to the user \"olivier\"", "bash_code": "find /work -user olivier -print" }, { "nl_command": "Print which files differ between \"dir1/\" and \"dir2/\"", "bash_code": "diff --brief -r dir1/ dir2/" }, { "nl_command": "Print short TXT record of domain o-o.myaddr.l.google.com from nameserver ns1.google.com", "bash_code": "dig TXT +short o-o.myaddr.l.google.com @ns1.google.com" }, { "nl_command": "Immediately exit the shell if a command fails", "bash_code": "set -e" }, { "nl_command": "Clean up the output of \"unzip -l\" and print only the \"jar\" files", "bash_code": "unzip -l some-jars-and-textfiles.zip | tr '[:blank:]' \\\\t | cut -f 5 | grep jar" }, { "nl_command": "Search for 'Text To Find' in all regular files under current directory tree and show the matched files and matched lines with line numbers", "bash_code": "find ./ -type f -exec grep -Hn \"Text To Find\" {} \\;" }, { "nl_command": "Convert the first 16 characters in \"/dev/random\" to a single hexadecimal value", "bash_code": "head /dev/random -c16 | od -tx1 -w16 | head -n1 | cut -d' ' -f2- | tr -d ' '" }, { "nl_command": "List all files bigger than 10000 blocks", "bash_code": "find . -type f -size +10000 -exec ls -al {} \\;" }, { "nl_command": "Find all directories under minimum 1 level down the current directory and set their permission to 755", "bash_code": "find . -type d -mindepth 1 -print -exec chmod 755 {}/* \\;" }, { "nl_command": "Find all files under current directory with their size and paths, reverse sort them numerically, then print the 2nd field (with space as the delimiter) of the first 4 entries", "bash_code": "find -type f -printf \"%s %p\\n\" | sort -nr | head -n 4 | awk \"{print $2}\"" }, { "nl_command": "Find all SUID set files in the file system", "bash_code": "find / -perm /u=s" }, { "nl_command": "display the name of all directories in the current folder and do not search in sub directories ( mindepth ensures that the current folder name is removed from the output)", "bash_code": "find . -type d -maxdepth 1 -mindepth 1 -exec basename {} \\;" }, { "nl_command": "Find all files/directories under '/usr/share/doc' directory tree whose name start with 'README'", "bash_code": "find /usr/share/doc -name README\\*" }, { "nl_command": "Find all directories in the /path/to/base/dir tree", "bash_code": "find /path/to/base/dir -type d" }, { "nl_command": "Read a single character from standard input in zsh", "bash_code": "read -sk" }, { "nl_command": "Continuously print \"123456789\" and line buffer the output via \"grep\" for input to \"{ head -n 1; head -n 1; }\"", "bash_code": "yes 123456789 | grep --line-buffered . | { head -n 1; head -n 1; }" }, { "nl_command": "Print a unique list of characters from standard input showing backslash escapes for non-displayables", "bash_code": "od -cvAnone -w1 | sort -bu" }, { "nl_command": "Save the user name in all capitals of the current user to variable \"v\"", "bash_code": "v=$(whoami | awk '{print toupper}')" }, { "nl_command": "Find all files/directories under /home/foo/public_html/ that were modified less than 60 minutes ago", "bash_code": "grep ! error_log | find /home/foo/public_html/ -mmin -60" }, { "nl_command": "Recursively find the latest modified file in the current directory", "bash_code": "find . -type f | xargs ls -ltr | tail -n 1" }, { "nl_command": "Print the first line of each file under the home directory", "bash_code": "find $HOME/. -name *.txt -exec head -n 1 -v {} \\;" }, { "nl_command": "find all the files which have been changed after the modification of a file.", "bash_code": "find -cnewer /etc/fstab" }, { "nl_command": "Remove all regular files from the current directory tree except textfile.txt, backup.tar.gz, script.php, database.sql, info.txt", "bash_code": "find . -type f ! -regex \".*/\\(textfile.txt\\|backup.tar.gz\\|script.php\\|database.sql\\|info.txt\\)\" -delete" }, { "nl_command": "Immediately terminate all processes whose command or arguments match \"myProcessName\"", "bash_code": "ps -ef | grep myProcessName | grep -v grep | awk '{print $2}' | xargs kill -9" }, { "nl_command": "run somecommand with as many arguments as fit on the command line at once for files recursively in /path that match 'pattern'", "bash_code": "find /path -name 'pattern' -exec somecommand {} +" }, { "nl_command": "Find all directories named \"D\" in the \"A\" directory tree", "bash_code": "find A -type d -name 'D'" }, { "nl_command": "Make directory \"dirname\" with permissions set to 777", "bash_code": "mkdir -m 777 dirname" }, { "nl_command": "Move all *.mp4 files from directory /foo/bar and its subdirectories to /some/path", "bash_code": "find /foo/bar -name '*.mp4' -print0 | xargs -0 mv -t /some/path {}" }, { "nl_command": "Set up SSH connection forwarding in the background with no terminal or command execution from localhost port 8888 to \"proxyhost\" port 8888 and a reverse connection from \"officefirewall\" port 22222 to \"localhost\" port 22", "bash_code": "ssh -fNT -L8888:proxyhost:8888 -R22222:localhost:22 officefirewall" }, { "nl_command": "Find every vim undo file in the current directory tree", "bash_code": "find -type f -iname '*.un~'" }, { "nl_command": "Remove all spaces from standard input", "bash_code": "tr -d ' '" }, { "nl_command": "Count the number of lines in all files in the xargstest/ directory tree that match pattern 'file??'", "bash_code": "find xargstest/ -name 'file??' | sort | xargs wc -l" }, { "nl_command": "Changes group ownership of 'public' to 'pub'.", "bash_code": "chgrp pub public" }, { "nl_command": "Print all lines from the last occurrence of the regex 'pattern' to the end of the file 'file'", "bash_code": "tac file | awk '/pattern/{print;exit}1' | tac" }, { "nl_command": "Find a size of only the target directory in MB format", "bash_code": "du -s --block-size=M /path/to/your/directory/" }, { "nl_command": "Count number of lines for each file containing ASCII text under git repository.", "bash_code": "git ls-files | xargs file | grep \"ASCII\" | cut -d : -f 1 | xargs wc -l" }, { "nl_command": "Execute awk script \"script.awk\" with 2 arguments both \"file.txt\" and format the output as a table", "bash_code": "awk -f script.awk file.txt{,} | column -t" }, { "nl_command": "Find all *.rb files under current directory ensuring white space safety and print at most two file names/paths per line", "bash_code": "find . -name \"*.rb\" -type f -print0 | xargs -0 -n 2 echo" }, { "nl_command": "Print current UTC date in ISO format with precision to seconds", "bash_code": "date -u -Iseconds" }, { "nl_command": "Search the current directory recursively for text files containing at least one character", "bash_code": "find . -type f -exec grep -Iq . {} \\; -and -print" }, { "nl_command": "Find all regular files whose names contain \"@\" in directory tree ~/$folder", "bash_code": "find ~/$folder -name \"*@*\" -type f -print0" }, { "nl_command": "search for all the files excluding directories ending with old or sccs or core or orig in the project folder and save the output to the file exclude", "bash_code": "find project ! -type d -print | egrep '/,|%$|~$|\\.old$|SCCS|/core$|\\.o$|\\.orig$' > Exclude" }, { "nl_command": "Find the \"param1\" string in regular files under and below /var", "bash_code": "find /var -type f | xargs grep \"param1\"" }, { "nl_command": "Finds recursively all folders in current folder which path not contains \"NameToExclude\" string and removes only ones without files and another folders within.", "bash_code": "find . -type 'd' | grep -v \"NameToExclude\" | xargs rmdir" }, { "nl_command": "Print source of the file system containing current working directory.", "bash_code": "df . | tail -1 | awk '{print $1}'" }, { "nl_command": "Print the first line of \"seq 1 10000\"", "bash_code": "seq 1 10000 | head -1" }, { "nl_command": "Search the current directory tree for files whose names are not \"a.txt\"", "bash_code": "find . ! -name \"a.txt\" -print" }, { "nl_command": "create a symbolic link named \"www\" to file \"www1\"", "bash_code": "ln -s www1 www" }, { "nl_command": "Find number of different rows between File1 and File2.", "bash_code": "diff --suppress-common-lines --speed-large-files -y File1 File2 | wc -l" }, { "nl_command": "Find all directories under var/ directory and change their permission to 700", "bash_code": "find var/ -type d -exec chmod 700 {} \\;" }, { "nl_command": "Page through the contents of 'input_file_name' hexdumped with space-separated 2-byte units.", "bash_code": "od -xcb input_file_name | less" }, { "nl_command": "Print a time stamp for each successful ping to \"host\"", "bash_code": "ping host | awk '{if{print strftime\"|\"$0}else print}'" }, { "nl_command": "Write output of \"ls -a\" to standard output and to \"output.file\"", "bash_code": "ls -a | tee output.file" }, { "nl_command": "Change to the directory of the executable \"python\"", "bash_code": "cd `dirname $(which python)`" }, { "nl_command": "Find files/directories with exactly read,write and execute permission for all (owner, group and others) under /path", "bash_code": "find /path -perm ugo+rwx" }, { "nl_command": "find all the css files", "bash_code": "find -name '*.css'" }, { "nl_command": "find all text files in the folder \"FFF\" and find the md5sum for them", "bash_code": "find FFF -name \"*.txt\" -exec md5sum '{}' \\;" }, { "nl_command": "Search for files/directories with the case insensitive pattern anaconda.* in var/log directory and create an archive (somefile.tar) of all the files found", "bash_code": "tar -cvf file.tar `find var/log/ -iname \"anaconda.*\"`" }, { "nl_command": "Print file information of command \"passwd\"", "bash_code": "ls -l `which passwd`" }, { "nl_command": "Find PHP files with abstract classes", "bash_code": "find . -type f -name \"*.php\" -exec grep --with-filename -c \"^abstract class \" {} \\; | grep \":[^0]\"" }, { "nl_command": "List and remove all regular files named \"core\" under /prog that are larger than 500k", "bash_code": "find /prog -type f -size +1000 -print -name core -exec rm {} \\;" }, { "nl_command": "find all the files in the home folder which have been modified in 1 year or more .", "bash_code": "find $HOME -mtime +365" }, { "nl_command": "display a long listing of all the xls or csv files in the entire file system", "bash_code": "find / -regex \".*\\.\\\"" }, { "nl_command": "Send SIGHUP signal to all parents of zombie processes.", "bash_code": "kill -HUP $" }, { "nl_command": "Output two lines of \"-tcp\"", "bash_code": "yes -- -tcp | head -n 2" }, { "nl_command": "Find all directories whose name is Tecmint in / directory", "bash_code": "find / -type d -name Tecmint" }, { "nl_command": "dispaly a long listig of all the files in the current folder which are bigger than 100KB", "bash_code": "find . -size +100000 -ls" }, { "nl_command": "Prints the absolute directory path of the current script preceded by the string \"dirname/readlink: \"", "bash_code": "echo \"dirname/readlink: $(dirname $(readlink -f $0))\"" }, { "nl_command": "Print unique lines of \"second-file-sorted.txt\" compared to \"first-file-sorted.txt\"", "bash_code": "comm -23 second-file-sorted.txt first-file-sorted.txt" }, { "nl_command": "Set permissions to 644 for all regular files under the current directory tree that have permissions 755", "bash_code": "find . -type f -perm 755 -exec chmod 644 {} \\;" }, { "nl_command": "find all the files in the folder /opt which have been modified exactly 20 days ago", "bash_code": "find /opt -mtime 20" }, { "nl_command": "Search the current directory tree for files whose names contain \"bills\"", "bash_code": "find . -name '*bills*' -print" }, { "nl_command": "Find all files/directories in entire file system for which owner has at least read/write permissions, or the group has at least read permission, or others have at least read permission", "bash_code": "find / -perm /u+rw,g+r,o+r" }, { "nl_command": "Find all files in /var/www/html/zip/data/*/*/*/*/* that are older than 90 days and print only unique parent directory paths", "bash_code": "find /var/www/html/zip/data/*/*/*/*/* -type f -mtime +90 -printf \"%h\\n\" | sort | uniq" }, { "nl_command": "find all the directories in current folder which start with test", "bash_code": "find . -type d -name \"test*\"" }, { "nl_command": "Remove all the files and directories that are in /dir1 but not in /dir2.", "bash_code": "diff -rq /dir1 /dir2 | grep -E \"^Only in /dir1.*\" | sed -n 's/://p' | awk '{print $3\"/\"$4}' xargs -I {} rm -r {}" }, { "nl_command": "find all the text files in the current folder and do not search in somedir, bin directories", "bash_code": "find . \\( -name somedir -prune \\) , \\( -name bin -prune \\) -o \\( -name \"*.txt\" -print \\)" }, { "nl_command": "Exits from process with exit code 255.", "bash_code": "exit -1" }, { "nl_command": "Read a line from standard input with prompt \"Is this a good question ? \" and save the response to variable \"answer\"", "bash_code": "read -p \"Is this a good question ? \" answer" }, { "nl_command": "Create a symbolic link in the current directory for each .jpg file under \"dir\"", "bash_code": "ln -s \"$(find dir -name '*.jpg')\" ." }, { "nl_command": "Show process tree with command-line arguments of a process that has id 20238.", "bash_code": "pstree -a -p 20238" }, { "nl_command": "Archive \"directory\" preserving hard links from host \"remote\" to the current local directory and keep partial files, handle sparse files efficiently, and itemize changes made", "bash_code": "rsync -aPSHiv remote:directory ." }, { "nl_command": "Ping hostname, grep for 192.168.11 and print the IP from the output", "bash_code": "ping -c 1 hostname | grep 192.168.11 | grep 'bytes from' | awk '{print $4}' | sed 's/://g'" }, { "nl_command": "search for the files \"foo.txt\" in the current folder", "bash_code": "find . -name foo.txt" }, { "nl_command": "Find all the regular files under current directory tree that have not been modified in the last 31 days and delete them", "bash_code": "find . -type f -mtime +31 -print0 | xargs -0 -r rm -f" }, { "nl_command": "sleep for 5 seconds", "bash_code": "sleep 5" }, { "nl_command": "Print all unique file paths under \"dir1\" compared to \"dir2\"", "bash_code": "comm -23 <(find dir1 -type f | sed 's/dir1/\\//'| sort) <(find dir2 -type f | sed 's/dir2/\\//'| sort) | sed 's/^\\//dir1/'" }, { "nl_command": "find all regular files exclude .o and exclude *.swp and output line number of soc_attach if it has", "bash_code": "find . \\ -a \\ -a \\ -a \\ | xargs grep -n soc_attach" }, { "nl_command": "Search the current directory tree for files matching regular expression '^myfile[0-9][0-9]?$'", "bash_code": "find . -\\( -name \"myfile[0-9][0-9]\" -o -name \"myfile[0-9]\" \\)" }, { "nl_command": "Find .log files in the /var/log directory tree and copy them to a bzip2 archive", "bash_code": "find /var/log -name '*.log' | tar cv --files-from=- | bzip2 > log.tar.bz2" }, { "nl_command": "Search the .sh files in the current directory tree for string \"ksh\"", "bash_code": "find . -name \"*.sh\" | xargs grep \"ksh\"" }, { "nl_command": "Find all files/directories under /home/bozo/projects directory that were modified 1 day ago", "bash_code": "find /home/bozo/projects -mtime 1" }, { "nl_command": "List all broken symlinks excluding cyclic links under current directory", "bash_code": "find . -type l -printf \"%Y %p\\n\" | grep -w '^N'" }, { "nl_command": "Find all files under current directory and set their permission to 775", "bash_code": "find . -type f -exec chmod 775 {} +" }, { "nl_command": "Find all files under /somefolder matching the pattern expanded by $FILE_PATTERN in thier names", "bash_code": "find /somefolder -type f -name $FILE_PATTERN" }, { "nl_command": "Count files in $DIR_TO_CLEAN that are older than $DAYS_TO_SAVE days", "bash_code": "find \"$DIR_TO_CLEAN\" -mtime +$DAYS_TO_SAVE | wc -l" }, { "nl_command": "Find all files/directories under current directory tree excluding hidden files/directories", "bash_code": "find . -not -path '*/\\.*'" }, { "nl_command": "Lists all directories in the current folder.", "bash_code": "ls -d ./*/" }, { "nl_command": "Unzip files \"file1.gz\" and \"file2.gz\" as arguments to \"command -1 -2\"", "bash_code": "command -1 < -2 <" }, { "nl_command": "Find all files/directories named 'testfile.txt' under current directory tree", "bash_code": "find . -name testfile.txt" }, { "nl_command": "Remove all the files and directories that are in /dir1 but not in /dir2.", "bash_code": "diff -rq /dir1 /dir2 | grep -E \"^Only in /dir1.*\" | sed -n 's/://p' | awk '{print $3\"/\"$4}' xargs -I {} rm -r {}" }, { "nl_command": "Extract host name part from URL.", "bash_code": "echo \"$url\" | cut -d'/' -f3" }, { "nl_command": "prints a line 19 lines from the line containing PATTERN", "bash_code": "tac | sed -n '/PATTERN/,+19{h;d};x;/^$/!{p;s/.*//};x' | tac" }, { "nl_command": "Find files that are 0 bytes in size in the current directory and remove them", "bash_code": "find . -maxdepth 1 -size 0c -exec rm {} \\;" }, { "nl_command": "Find all files named \"file.ext\" under the current working directory tree and print its filename", "bash_code": "find `pwd` -name \"file.ext\" -printf \"%f\\n\"" }, { "nl_command": "display the files modified between last 18 to 24 months in the format filename, file size, Last access date, modification date and save the output to the file /dir/dir/output.csv", "bash_code": "find /dir/dir -type f -mtime +540 -mtime -720 -printf \\\u201d%p\\\u201d,\\\u201d%s\\\u201d,\\\u201d%AD\\\u201d,|\u201d%TD\\\u201d\\\\n > /dir/dir/output.csv" }, { "nl_command": "find all the html files in the current folder and rename them to .var files", "bash_code": "find -name '*.html' -print0 | xargs -0 rename 's/\\.html$/.var/'" }, { "nl_command": "Append history lines from this session to the history list", "bash_code": "history -a" }, { "nl_command": "set alias \"devn\" for command \"cat > /dev/null\"", "bash_code": "alias devn='cat > /dev/null'" }, { "nl_command": "Removes all empty folders under current folder.", "bash_code": "find . -type d -empty -exec rmdir \"{}\" \\;" }, { "nl_command": "Recursively search the current directory for unique entries of \"searchtext\" and replace \"matchtext\" with \"replacetext\"", "bash_code": "grep -r -l 'searchtext' . | sort | uniq | xargs perl -e \"s/matchtext/replacetext/\" -pi" }, { "nl_command": "Lists all content in a current folder but names like *.c and *.h.", "bash_code": "ls -d !(*@)" }, { "nl_command": "Print the list of all regular files residing in the current directory and below", "bash_code": "find ./ -type f -print" }, { "nl_command": "Forcefully delete all files in the current directory that begin with spam-", "bash_code": "find . -name 'spam-*' | xargs rm" }, { "nl_command": "Find all fglrx-libglx* files under and below debian/fglrx/", "bash_code": "find debian/fglrx/ -name 'fglrx-libglx*'" }, { "nl_command": "Kill all processes matching the string \"myProcessName\"", "bash_code": "ps -ef | grep myProcessName | grep -v grep | awk '{print $2}' | xargs kill -9" }, { "nl_command": "Wrap each line in \"file.txt\" to fit in 80 characters", "bash_code": "cat file.txt | fold" }, { "nl_command": "Find files with 002 permission in entire file system and print them with the string 'has world write permissions' appended after every path", "bash_code": "find / -type f -perm -002 -printf '%p has world write permissions\\n'" }, { "nl_command": "find in the entire file system for the files which have sticky bit.", "bash_code": "find / -perm 0551" }, { "nl_command": "list all *.java files under the src directory", "bash_code": "find src -name \"*.java\"" }, { "nl_command": "find all the files in current directory of size smaller than 10KB.", "bash_code": "find . -size -10k" }, { "nl_command": "Reverse the order of lines in \"myfile.txt\" using BSD \"tail\" command", "bash_code": "tail -r myfile.txt" }, { "nl_command": "Replace all instances of \"STRING_TO_REPLACE\" with \"STRING_TO_REPLACE_IT\" in file \"index.html\" and make a backup with suffix \".bak\"", "bash_code": "sed -i.bak s/STRING_TO_REPLACE/STRING_TO_REPLACE_IT/g index.html" }, { "nl_command": "Search the *.code files from the current directory tree for string 'pattern'", "bash_code": "find . -name '*.code' -print0 | xargs -0 grep -H 'pattern'" }, { "nl_command": "Find all Read Only files", "bash_code": "find / -perm /u=r" }, { "nl_command": "Print A record for domain 'domain.' from 'ns1.newnameserver' nameserver", "bash_code": "dig @ns1.newnameserver domain. a" }, { "nl_command": "Find files in the current directory tree that are named \"some_pattern\" and move them to directory \"target_location\"", "bash_code": "find . -name some_pattern -print0 | xargs -0 -i mv {} target_location" }, { "nl_command": "Find all files/directories under current directory in maximum 3 levels deep", "bash_code": "find -maxdepth 3" }, { "nl_command": "Find all files/directories under '/home/user/' directory tree whose status was changed exactly 10 minitues ago", "bash_code": "find /home/user/ -cmin 10 -print" }, { "nl_command": "Search the .java files from the /Applications/ directory tree for TODO lines", "bash_code": "find /Applications/ -name \"*.java\" -exec grep -i TODO {} +" }, { "nl_command": "Replace all occurrence of \"toreplace\" with \"replaced\" in all files under /home/www", "bash_code": "find . -maxdepth 1 -type f -print0 | xargs -0 sed -i 's/toreplace/replaced/g'" }, { "nl_command": "Search the current directory tree for regular files named `doc.txt' and print \"found\" for each of them", "bash_code": "find ./ -type f -name doc.txt -printf \"found\\n\"" }, { "nl_command": "Find all *.cls files/directories under current directory and print '{if(length > L) { LINE=$0; L = length}} END {print LINE\"L\"L}' for each of them where $0 is expanded to the file/directory path", "bash_code": "find . -iname \"*.cls\" -exec echo '{if(length > L) { LINE=$0; L = length}} END {print LINE\"L\"L}' {} \\;" }, { "nl_command": "Find all files/directories under $something directory", "bash_code": "find $something" }, { "nl_command": "Prints path location of $BASH_SOURCE file.", "bash_code": "echo this dir: `dirname $BASH_SOURCE`" }, { "nl_command": "search for all html files in current folder folder and create a zip file of all these files", "bash_code": "find . -name \"*.html\" -print | zip all-html-files.zip -@" }, { "nl_command": "Count the number of open files for PID \"$PYTHONPID\" every 2 seconds", "bash_code": "watch \"ls /proc/$PYTHONPID/fd | wc -l\"" }, { "nl_command": "Find all files recursively which end in \".php\"", "bash_code": "find . -name \"*.php\" -print" }, { "nl_command": "Find all the files in the current directory recursively whose permissions are not 777", "bash_code": "find . -type f ! -perm 777 | head" }, { "nl_command": "Find all regular files on the system whose names are 'myfile'", "bash_code": "find / -name myfile -type f -print" }, { "nl_command": "Lists all files in a current folder, separating names with comma.", "bash_code": "ls -1 | paste -sd \",\" -" }, { "nl_command": "Use 'top' to monitor the newest instance of ProgramName.", "bash_code": "top -p $" }, { "nl_command": "Find sqlite3 databases in the current directory tree and execute query 'SELECT * FROM table WHERE column1=\"value\"' on all of them", "bash_code": "find . -name 'sqlite.db' -exec sqlite3 \"{}\" 'SELECT * FROM table WHERE column1=\"value\"' \\;" }, { "nl_command": "Recursively prints paths to all text file in folder (ignores binary files).", "bash_code": "grep -RIl \"\" ." }, { "nl_command": "Make directory \"/data/db\"", "bash_code": "sudo mkdir /data/db" }, { "nl_command": "Count the number of .gz files in the current directory tree", "bash_code": "find -name \"*.gz\" | wc -l" }, { "nl_command": "Change the timestamp of symbolic link \"somesymlink\" to current date/time", "bash_code": "touch -h somesymlink" }, { "nl_command": "Save the current working directory with resolved symbolic links to variable \"real1\"", "bash_code": "real1=$" }, { "nl_command": "Replace any sequence of spaces in file 'text.txt' with single space and print 4th space separated field", "bash_code": "cat text.txt | tr -s ' ' | cut -d ' ' -f 4" }, { "nl_command": "Recursively change the owner to \"$USER\" and group to \"$GROUP\" of \"/var/log/cassandra\"", "bash_code": "sudo chown -R $USER:$GROUP /var/log/cassandra" }, { "nl_command": "find all the files in the folder /usr/bin which have been modified in the last 10 days", "bash_code": "find /usr/bin -type f -mtime -10" }, { "nl_command": "Print the names of the subdirectories of /usr/local/svn/repos/ prepending \"/usr/local/backup\" to them", "bash_code": "find /usr/local/svn/repos/ -maxdepth 1 -mindepth 1 -type d -exec echo /usr/local/backup{} \\;" }, { "nl_command": "display all the files in the current folder that end with \".ksh\"", "bash_code": "find . -name \"*.ksh\" -prune" }, { "nl_command": "Search the current directory tree for regular files whose names end in \".shtml\" or \".css\"", "bash_code": "find . -type f | egrep '\\.$'" }, { "nl_command": "Set the prompt to \"title: \"", "bash_code": "export PS1='\\[\\e]0;`hostname`\\a\\]${debian_chroot:+}\\u@\\h:\\w\\$ '" }, { "nl_command": "display all the regular files in current folder that belong to the user \"tom\"", "bash_code": "find . -type f -user tom" }, { "nl_command": "Remove all files under current directory", "bash_code": "find -exec rm '{}' +" }, { "nl_command": "Print the names of all the files from directory tree ~/some/directory whose names end in \"rb\"", "bash_code": "find ~/some/directory -name \"*rb\" -exec basename {} \\;" }, { "nl_command": "Enables shell options 'extglob' and 'progcomp'", "bash_code": "shopt -s extglob progcomp" }, { "nl_command": "Page through the contents of BIG_FILE.txt, letting the user move around with the arrow keys, the Q key quits.", "bash_code": "cat BIG_FILE.txt | less" }, { "nl_command": "Display all environment variables, functions, and aliases, pausing for user interaction after each page of output.", "bash_code": "set | more" }, { "nl_command": "Compare each C header file in or below the current directory with file /tmp/master", "bash_code": "find . -name '*.h' -execdir /bin/diff -u '{}' /tmp/master ';'" }, { "nl_command": "list regular files under the current directory ending in .mbox putting a null between each file found", "bash_code": "find . -type f -wholename \\*.mbox -print0" }, { "nl_command": "Mount \"/windows\" using /etc/fstab entry", "bash_code": "mount /windows" }, { "nl_command": "Print content of all files found regarding seach options '[whatever]'", "bash_code": "find [whatever] | xargs cat" }, { "nl_command": "Add group write permission to all files matching \"*\" or \"...*\"", "bash_code": "chmod g+w * ...*" }, { "nl_command": "create an archive and show a progress bar", "bash_code": "tar -c --checkpoint=1000 --checkpoint-action=dot /var" }, { "nl_command": "create directory temp into home directory", "bash_code": "mkdir ~/temp" }, { "nl_command": "Move each of the 'm?' directories in $path_to_folders to another directory whose name is constituted by appending .mbox to each directory name and create a directory named Messages in this directory then move all *.emlx files into this directory", "bash_code": "find \"$path_to_folders\" -name 'm?' -type d -exec mv {} {}.mbox \\; -exec mkdir {}.mbox/Messages \\; -exec sh -c \"mv {}.mbox/*.emlx {}.mbox/Messages\" \\;" }, { "nl_command": "Unzip and untar \"openssl-fips-2.0.1.tar.gz\"", "bash_code": "gunzip -c openssl-fips-2.0.1.tar.gz | tar xf \u00ad-" }, { "nl_command": "Prints process tree of a process having id $mypid, with command options and process id number.", "bash_code": "pstree -aAp $(ps -ejH | awk -v v1=$mypid '$1==v1 {print $3}')" }, { "nl_command": "Execute \"ls -l\" on host \"something\" as user \"root\"", "bash_code": "ssh root@something 'ls -l'" }, { "nl_command": "find any files or directories called \".svn\" under the current directory and run a recursive delete command on each one.", "bash_code": "find . -iname .svn -exec bash -c 'rm -rf {}' \\;" }, { "nl_command": "find files in the current directory with pattern` '*.[ch]' which are contain \u2018thing\u2019 string and print file names which can contain spaces", "bash_code": "find . -name '*.[ch]' -print0 | xargs -r -0 grep -l thing" }, { "nl_command": "Print 1000 astarisk ('*')", "bash_code": "head -c 1000 /dev/zero | tr '\\0' '*'" }, { "nl_command": "Find all 'test' directories in the current directory tree and remove them", "bash_code": "find . -type d -name 'test' -exec rm -rf {} \\;" }, { "nl_command": "recursively delete, without prompting, directories under /data/bin/test, that are older than 10 days and where the name starts with a number", "bash_code": "find /data/bin/test -type d -mtime +10 -name \"[0-9]*\" -exec rm -rf {} \\;" }, { "nl_command": "search for the file foo.txt in the current folder and open it in vi editor", "bash_code": "find -name foo.txt -execdir vim '{}' ';'" }, { "nl_command": "gives the chars in line 5 and chars 5 to 8 of line 5, in tst.txt", "bash_code": "head -5 tst.txt | tail -1 |cut -c 5-8" }, { "nl_command": "Find all *.plist files/directories under current directory", "bash_code": "find -name \\*.plist" }, { "nl_command": "Delete all files/directories in minimum 2 levels down the root directory", "bash_code": "find root -mindepth 2 -delete" }, { "nl_command": "Display a long listing of all files/directories named 'file' under current directory tree", "bash_code": "find -name file -ls" }, { "nl_command": "find all posix-extended regex \"[a-f0-9\\-]\\{36\\}\\.jpg\" files", "bash_code": "find . -regextype posix-extended -regex \"[a-f0-9\\-]\\{36\\}\\.jpg\"" }, { "nl_command": "Find all *.foo files under current directory and print their contents", "bash_code": "find . -name '*.foo' -exec cat {} \\;" }, { "nl_command": "Display a long listing of all the files/directories under current directory tree that are newer than the file 'Nov' by modification time", "bash_code": "find . -newer Nov -ls" }, { "nl_command": "Change permissions of \"mksdcard\" to 755", "bash_code": "sudo chmod 755 mksdcard" }, { "nl_command": "Counts lines of 'file' file.", "bash_code": "wc -l file" }, { "nl_command": "Find all regular files starting from level 3 of directory tree ~/container and move them to the current directory's parent", "bash_code": "find ~/container -mindepth 3 -type f -exec mv {} .. \\;" }, { "nl_command": "Reconnect to a named screen session", "bash_code": "screen -x screen id" }, { "nl_command": "Find all 777 permission directories and use chmod command to set permissions to 755", "bash_code": "find . -type d -perm 777 -print -exec chmod 755 {} \\;" }, { "nl_command": "Print second section of space-separated data coming from stdin.", "bash_code": "cut -d\\ -f 2" }, { "nl_command": "Search all of /usr for any directory named 'My Files', for each directory found, copy it to /iscsi preserving full paths and attributes, then remove it.", "bash_code": "find /usr -type d -name 'My Files' -exec rsync -avR '{}' /iscsi \\; -exec rm -rf '{}'\\;" }, { "nl_command": "Find symlinks in the current directory tree", "bash_code": "find . -type l | xargs ls -ld" }, { "nl_command": "find all the files that have not been modified in the last 2 days", "bash_code": "find -mtime +2" }, { "nl_command": "Number each non-blank line of standard input", "bash_code": "nl" }, { "nl_command": "Find all files/directories with spaces in their names under ~/Library directory", "bash_code": "find ~/Library -name '* *'" }, { "nl_command": "Find all the files/directories with '.conf' extension under '/etc' directory non-recursively and display the last ten files", "bash_code": "find /etc -maxdepth 1 -name \"*.conf\" | tail" }, { "nl_command": "find all txt files under the current folder except ./misc folder", "bash_code": "find . -path ./misc -prune -o -name '*.txt' -print" }, { "nl_command": "Unzip all *.zip files under current directory", "bash_code": "find . -name '*.zip' -exec unzip '{}' ';'" }, { "nl_command": "Set the environment variable \"DISPLAY\" to the system host name followed by \":0 skype\"", "bash_code": "env DISPLAY=`hostname`:0 skype" }, { "nl_command": "Find all files modified on \"Mar 4\" and unzip and search their contents for \"12345\"", "bash_code": "ls -ltr | grep 'Mar 4' | awk '{print 9}' | xargs zcat -fq | grep 12345" }, { "nl_command": "Bind mount \"/something\" on \"/new_something\"", "bash_code": "mount --bind /something /new_something" }, { "nl_command": "Display the entire file system in a tree-like format", "bash_code": "tree /" }, { "nl_command": "find all the files in the current folder which are exactly 1234 bytes", "bash_code": "find . -size 1234c" }, { "nl_command": "Move all lines starting with \"Ca\" to the beginning of the file", "bash_code": "nl -n rz ca | awk -vOFS=\"\\t\" '/Ca/{$1=\"#\"$2} {$1=$1}1' | sort -k1,1 | cut -f2-" }, { "nl_command": "search for the file chapter1 in the folder /work", "bash_code": "find /work -name chapter1" }, { "nl_command": "Removes files ~/.android/adbkey and ~/.android/adbkey.pub without prompting.", "bash_code": "rm -f ~/.android/adbkey ~/.android/adbkey.pub" }, { "nl_command": "searches through the /usr/local directory for files that end with the extension .html", "bash_code": "find /usr/local -name \"*.html\" -type f" }, { "nl_command": "Count all files under \"/DIR\"", "bash_code": "find /DIR -type f -print0 | tr -dc '\\0' | wc -c" }, { "nl_command": "Find all files/directories named 'query' under current directory tree", "bash_code": "find -iname \"query\"" }, { "nl_command": "Print canonical filename of \"/path/here/..\"", "bash_code": "readlink -f /path/here/.." }, { "nl_command": "find all the files in the current folder which have been modified in the last one day", "bash_code": "find . -daystart -mtime -1 -ls" }, { "nl_command": "Execute \"sleep 30; touch nohup-exit\" in the background on target machine \"REMOTE\"", "bash_code": "ssh REMOTE \"sh -c \\\" > /dev/null &\\\"\"" }, { "nl_command": "display all executable files in the folder /home", "bash_code": "find /home -perm /a=x" }, { "nl_command": "Gets MAC address of 'eth0' network interface.", "bash_code": "ifconfig eth0 | head -n1 | tr -s ' ' | cut -d' ' -f5" }, { "nl_command": "Replace all occurrences of edx (case insensitive) with gurukul in all *.css (case insensitive) files under ./cms/djangoapps/contentstore/management/commands/tests directory", "bash_code": "find ./cms/djangoapps/contentstore/management/commands/tests -iname *.css | xargs sed -i s/[Ee][Dd][Xx]/gurukul/g" }, { "nl_command": "Search the current directory tree for files and directories whose names do not end in \".exe\" and \".dll\"", "bash_code": "find . ! \\( -name \"*.exe\" -o -name \"*.dll\" \\)" }, { "nl_command": "Find all files/directories named 'openssl' under current directory tree without printing 'Permission denied' error messages", "bash_code": "find . -name \"openssl\" | sed '/Permission denied/d;'" }, { "nl_command": "display all the text files in the current folder and do not search in the bin directory", "bash_code": "find . -name bin -prune -o -name \"*.txt\" -print" }, { "nl_command": "Change to folder where the oracle binary is.", "bash_code": "cd $(dirname $(which oracle))" }, { "nl_command": "Count the number of regular files in the current directory that contain a vowel in their names", "bash_code": "find . -maxdepth 1 -type f -iname '*[aeiouy]*' -printf \".\\n\" | wc -l" }, { "nl_command": "Split all files in the directory tree \"/dev/shm/split/\" into files of at most 1000 lines each and use the filename as the prefix", "bash_code": "find /dev/shm/split/ -type f -exec split -l 1000 {} {} \\;" }, { "nl_command": "Find all files/directories with 755 permission under current directory tree", "bash_code": "find ./ -perm 755" }, { "nl_command": "find all the files ending with undo in the current folder and calculate the total size of these files", "bash_code": "find -name *.undo -exec stat -c%s {} \\; | awk '{total += $1} END {print total}'" }, { "nl_command": "Create a ssh tunnel on local port 2222 through \"bridge.example.com\" to \"remote.example.com\" port 22 without executing any commands and run in the background", "bash_code": "ssh -N -L 2222:remote.example.com:22 bridge.example.com&" }, { "nl_command": "Finds users with X session in system and puts the result into USERS variable", "bash_code": "USERS=$(awk '/\\/X/ {print $1}' <(w))" }, { "nl_command": "Display source and mount point of the file system containing /some/path.", "bash_code": "df '/some/directory' | awk '{print $1, $6}'" }, { "nl_command": "Decompress \"path/to/test/file.gz\" to standard output and save all lines matching \"my regex\" and not matching \"other regex\" to files with a 1000000 line limit", "bash_code": "gzip -dc path/to/test/file.gz | grep -P 'my regex' | grep -vP 'other regex' | split -dl1000000 - file" }, { "nl_command": "Search the current directory and all of its sub-directory for any PDF files.", "bash_code": "find . -name \"*.pdf\" -print" }, { "nl_command": "create directory practice into home directory", "bash_code": "mkdir ~/practice" }, { "nl_command": "Search the current directory tree for executable files", "bash_code": "find . -type f -executable -print" }, { "nl_command": "Execute `find -type f | egrep -i \"$\"` every 300 seconds and display without title", "bash_code": "watch -n 300 -t `find -type f | egrep -i \"$\"`" }, { "nl_command": "Print 'file' file, splitting lines into pieces with no more that 3 words in each one.", "bash_code": "cat file | xargs -n3" }, { "nl_command": "Find and remove all .core files", "bash_code": "find / -name \"*.core\" | xargs rm" }, { "nl_command": "Find all *.txt files under current directory with their timestamps and paths, sort them and print the last entry only", "bash_code": "find . -name \"*.txt\" -printf \"%T+ %p\\n\" | sort | tail -1" }, { "nl_command": "Find .java files in the current directory tree that contain 'TODO', and print their pathnames", "bash_code": "find . -name \"*.java\" -exec grep -Hin TODO {} + | cut -d \":\" -f 1" }, { "nl_command": "Create a symbolic link named \"wh\" to \"$wh\"", "bash_code": "ln -s \"$wh\" wh" }, { "nl_command": "Find files named \"xxx\" and pass their names as arguments to the \"command\"", "bash_code": "find . -name xxx -exec command {} +" }, { "nl_command": "Find files that are 100k", "bash_code": "find -size 100k" }, { "nl_command": "Find all broken symlinks under current directory", "bash_code": "find ./ -type l -exec file {} \\; |grep broken" }, { "nl_command": "Create a symbolic link in \"/bar/tmp/\" for each file in directory \"/foo\" that does not start with \"runscript\"", "bash_code": "find /foo -maxdepth 1 -type f ! -name 'runscript*' -exec ln -s {} /bar/tmp/ \\;" }, { "nl_command": "Copy directory hierarchy from the current working directory to \"/path/to/backup/\"", "bash_code": "find . -type d -exec mkdir -p -- /path/to/backup/{} \\;" }, { "nl_command": "Unset IFS and read a single character from standard input with timeout of 0.01 seconds and save the response in variable \"keypress\"", "bash_code": "IFS= read -t 0.01 -d '' -n1 keypress" }, { "nl_command": "Unzip all files matching \"test1/*/*.gz\"", "bash_code": "gunzip test1/*/*.gz" }, { "nl_command": "Rename \"original.filename\" to \"new.original.filename\"", "bash_code": "mv original.filename new.original.filename" }, { "nl_command": "Search the current directory tree for all files except SVN ones", "bash_code": "find . ! -regex \".*[/]\\.svn[/]?.*\"" }, { "nl_command": "Force create a hard link named \"non_secret_file.txt\" to \"secret_file.txt\"", "bash_code": "ln -f secret_file.txt non_secret_file.txt" }, { "nl_command": "Display infinite scroll of random ASCII art", "bash_code": "yes 'c=;printf ${c[RANDOM%2]}'|bash" }, { "nl_command": "Search the current directory recursively for files last modified within the past 24 hours ignoring .swp files and paths ./es* and ./en*", "bash_code": "find \"$\" -mtime 0 -not \\" }, { "nl_command": "Change directory to the real path of the current working directory of process \"$PID\"", "bash_code": "cd $(readlink /proc/$PID/cwd)" }, { "nl_command": "Copy a file xyz.c to all the .c files present in the C directory and below", "bash_code": "find ./C -name \"*.c\" | xargs -n1 cp xyz.c" }, { "nl_command": "Split \"input.txt\" into files with 1 line each and use a prefix \"output.\" and a suffix length of 5", "bash_code": "split --lines=1 --suffix-length=5 input.txt output." }, { "nl_command": "Remove all files with names like \"vmware-*.log\" from the current directory tree", "bash_code": "find . -name vmware-*.log -print0 | xargs -0 rm" }, { "nl_command": "Print 'This should print the filename twice if an implicit -print is applied: ' appended with file paths for all files named 'file' under current directory tree", "bash_code": "find -name file -exec echo 'This should print the filename twice if an implicit -print is applied: ' {} +" }, { "nl_command": "Counts lines of /etc/fstab file.", "bash_code": "cat /etc/fstab | wc -l" }, { "nl_command": "Save number of lines with any-cased 'merge' from $COMMIT_EDITMSG file in 'MERGE' variable", "bash_code": "MERGE=$(cat $COMMIT_EDITMSG|grep -i 'merge'|wc -l)" }, { "nl_command": "Search all of /usr for any directory named 'My Files', for each directory found, copy it to /iscsi preserving full paths and attributes.", "bash_code": "find /usr -type d -name My\\ Files -exec rsync -avR '{}' /iscsi \\;" }, { "nl_command": "recursively change owner of the directory /Users/xxx/Library/Developer/Xcode/Templates and all files to user xxx", "bash_code": "sudo chown -R xxx /Users/xxx/Library/Developer/Xcode/Templates" }, { "nl_command": "change permissions for directories in the entire file system", "bash_code": "chmod 751 `find ./ -type d -print`" }, { "nl_command": "Split \"/etc/gconf/schemas/gnome-terminal.schemas\" into 1000000 files of about equal size", "bash_code": "split -n 1000000 /etc/gconf/schemas/gnome-terminal.schemas" }, { "nl_command": "display all text files in the folder /user/directory which have been modified in today", "bash_code": "find /user/directory/* -name \"*txt\" -mtime 0 -type f" }, { "nl_command": "Find all regular files that reside in the current directory tree and were last modified at least 1 day ago", "bash_code": "find . -type f -mtime +0" }, { "nl_command": "bind \"\\C-i\" to \"complete\" function", "bash_code": "bind '\"\\C-i\":complete'" }, { "nl_command": "list the files with a name ending with '.mp3' or '.jpg' and beginning with 'foo'", "bash_code": "find . \\( -name '*.mp3' -o -name '*.jpg' \\) -name 'foo*' -print" }, { "nl_command": "Counts lines in each of *.php files in a current folder and subfolders and prints total count as well.", "bash_code": "find . -name \"*.php\" | xargs wc -l" }, { "nl_command": "Find and remove multiple files such as *.mp3 or *.txt under current directory", "bash_code": "find . -type f -name \"*.txt\" -exec rm -f {} \\;" }, { "nl_command": "Set the 'xtrace' shell option", "bash_code": "set -x" }, { "nl_command": "Calculate the md5 sum of hex byte 61", "bash_code": "echo -n -e '\\x61' | md5sum" }, { "nl_command": "as root, find from / all files called \"file.txt\"", "bash_code": "sudo find / -name file.txt" }, { "nl_command": "Find all .zip files in the current directory tree and unzip them deleting the archives on success", "bash_code": "find . -depth -name '*.zip' -exec /usr/bin/unzip -n {} \\; -delete" }, { "nl_command": "display the names without extensions of all the data files in current folder which have not been changed in the last 60 mins", "bash_code": "find . -prune -name \"*.dat\" -type f -cmin +60 |xargs -i basename {} \\;" }, { "nl_command": "Delete all files named 'Waldo' under ~/Books directory tree where '~' expands to user's home directory", "bash_code": "find ~/Books -type f -name Waldo -exec rm {} \\;" }, { "nl_command": "Find all directories under $path", "bash_code": "find $path -type d" }, { "nl_command": "Find all files/directories under $1 which have at least read permission for their owner and set read permission for group for these files/directories", "bash_code": "find \"$1\" -perm -u+r -print0 | xargs chmod g+r" }, { "nl_command": "Compresses all files listed in array $*, executing in background.", "bash_code": "compress $* &" }, { "nl_command": "Print the list of files modified within a fortnight ago removing the leading ./ from the file names", "bash_code": "find . -mtime -14 | sed -e 's/^\\.\\///'" }, { "nl_command": "Find files/directories that does not have write permssion for group and others", "bash_code": "find /path ! -perm /022" }, { "nl_command": "Display the last colon-separated field of variable 'var'", "bash_code": "echo \"$var\" | rev | cut -d: -f1 | rev" }, { "nl_command": "create archive \"backup.tar.gz\" from /path/to/catalog", "bash_code": "tar czfP backup.tar.gz /path/to/catalog" }, { "nl_command": "Saves index number of file 'script.sh' in the 'inode' variable.", "bash_code": "inode=`ls -i ./script.sh | cut -d\" \" -f1`" }, { "nl_command": "Remove leading and trailing spaces or tabs from \"$string\"", "bash_code": "echo \"$string\" | sed -e 's/^[ \\t]*//' | sed -e 's/[ \\t]*$//'" }, { "nl_command": "Delete all regular files with inode number 314167125 under current directory tree", "bash_code": "find . -type f -inum 314167125 -delete" }, { "nl_command": "Print all matching commands in $PATH for command \"python\"", "bash_code": "which -a python" }, { "nl_command": "search for the regular/normal file \"foo.bar\" and force delete it", "bash_code": "find /home -name foo.bar -type f -exec rm -f \"{}\" ';'" }, { "nl_command": "SSH login in 'middle.example.org' via port 2222 as user 'deviceuser' using a private key file './device_id.pem'", "bash_code": "ssh -i ./device_id.pem deviceuser@middle.example.org:2222" }, { "nl_command": "show all files in the current folder that belongs to a specific userid", "bash_code": "find . -user " }, { "nl_command": "Prefix each non-blank line in \"filename\" with a line number", "bash_code": "nl filename" }, { "nl_command": "Copy and always overwrite all files in \"/zzz/zzz\" to \"/xxx/xxx\"", "bash_code": "yes | cp -rf /zzz/zzz/* /xxx/xxx" }, { "nl_command": "Merge files 'text.txt' and 'codes.txt' by outputting any lines whose second field in the first matches the first field in the second.", "bash_code": "join -1 2 -2 1 text.txt codes.txt" }, { "nl_command": "search for the word \"nameserver\" in all the regular/normal files in the /etc directory and display the name of the file along with the matched line", "bash_code": "find /etc/ -iname \"*\" -type f -print0 | xargs -0 grep -H \"nameserver\"" }, { "nl_command": "Set 644 permission to all regular files under current directory", "bash_code": "chmod 644 `find -type f`" }, { "nl_command": "prints absolute file paths for files in current directory", "bash_code": "find `pwd` -maxdepth 1" }, { "nl_command": "Print the current directory tree with file permissions", "bash_code": "tree -p" }, { "nl_command": "Make directory \"dir\" and do not cause an error if it exists", "bash_code": "mkdir -p dir" }, { "nl_command": "For each line in file2 whose first field appears as a first field in file1, print an output line constructed following the specified -o format.", "bash_code": "join -11 -21 -o1.1,1.2,1.3,2.3 file1 file2" }, { "nl_command": "Display system information: kernel name, hostname, kernel release and version, machine architecture, processor type, hardware platform, and operating system type.", "bash_code": "uname -a" }, { "nl_command": "Mount \"project1/link1\" as a bind directed at \"/absolute/path/to/some/where/else\"", "bash_code": "mount --bind /absolute/path/to/some/where/else project1/link1" }, { "nl_command": "Run 'make -e' with an environment variable 'HOSTNAME' set to the system hostname", "bash_code": "HOSTNAME=$ make -e" }, { "nl_command": "Rename all regular files under current directory tree with inode number 31467125 to 'new_name.html'", "bash_code": "find . -type f -inum 31467125 -exec mv {} new_name.html \\;" }, { "nl_command": "Setup a local SSH tunnel from port 1234 to \"remote2\" port 22 via connection to \"remote1\" as \"user1\" on port 45678", "bash_code": "ssh -L 1234:remote2:22 -p 45678 user1@remote1" }, { "nl_command": "Display inputfile all on one line", "bash_code": "awk '{printf \"%s \", $0}' inputfile" }, { "nl_command": "find all files in the current directory and sub-directories that were modified after the /etc/passwd file was modified", "bash_code": "find -newer /etc/passwd" }, { "nl_command": "Delete all regular files that reside in directory $OUTPUTDIR and below, and were last modified more than 7 days ago", "bash_code": "find $OUTPUTDIR -type f -mtime +7 -delete" }, { "nl_command": "Count the number of times each person is logged in on the system", "bash_code": "who | awk '{print $1}' | sort | uniq -c | sort -n" }, { "nl_command": "Remove all directories called \"test\" from the /path/to/dir directory tree", "bash_code": "find /path/to/dir -name \"test\" -type d -exec rm -rf {} \\;" }, { "nl_command": "Search the /mnt/raid/upload directory tree for files that have been modified within the last 7 days", "bash_code": "find /mnt/raid/upload -mtime -7 -print" }, { "nl_command": "Clear the terminal's search history", "bash_code": "history -c" }, { "nl_command": "Prints help on 'yum' utility.", "bash_code": "yum --help" }, { "nl_command": "Answer \"y\" to any prompts in the interactive recursive removal of \"dir1\", \"dir2\", and \"dir3\"", "bash_code": "yes y | rm -ir dir1 dir2 dir3" }, { "nl_command": "Find all *.txt files/directories under current directory", "bash_code": "find . -name *.txt -print" }, { "nl_command": "Find all files/directories under /export/home/someone directory in a remote host and upload the files/directories to ftp://somehost/tmp/", "bash_code": "ssh someone@somehost \"cd /export/home/someone && find . -name '*' -print | parallel -j1 'sleep 10;curl -u someone:password ftp://somehost/tmp/ -vT'" }, { "nl_command": "find all the files which have been modified in the last 15 minutes excluding hidden files.", "bash_code": "find . -mmin -15 \\( ! -regex \".*/\\..*\" \\)" }, { "nl_command": "Prints path to folder that contains file \"/path/to/vm.vmwarevm/vm.vmx\".", "bash_code": "dirname \"/path/to/vm.vmwarevm/vm.vmx\"" }, { "nl_command": "Print the total disk usage in bytes of all files listed in \"files.txt\"", "bash_code": "cat files.txt | xargs du -c | tail -1 | awk '{print $1}'" }, { "nl_command": "Find all files/directories in entire file system that match the pattern '' in their names and print a sorted list of their unique parent directory paths", "bash_code": "find / -name '' | perl -pe 's/.*$/$1/' | sort | uniq" }, { "nl_command": "Find all regular files in the current directory tree that do not contain a whitespace", "bash_code": "find . -type f \\( -exec grep -q '[[:space:]]' {} \\; -o -print \\)" }, { "nl_command": "display the size of all the files in the folder \"${START_DIR}\" which have been modified in the last \"${DAYS}\"*24 hours", "bash_code": "find ${START_DIR} -mtime -${DAYS} |xargs stat -c \"%s\"|awk '{sum += $1}END{print sum}'" }, { "nl_command": "Run command specified by $line, replace space with newline and save the output to variable 'arr'", "bash_code": "arr=$" }, { "nl_command": "Find all files under and below the current working directory with the word California in the file", "bash_code": "find . -type f -exec grep California {} \\; -print" }, { "nl_command": "Return the depth of the current directory tree", "bash_code": "find . -type d -printf '%d:%p\\n' | sort -n | tail -1" }, { "nl_command": "list jobs including its PIDs", "bash_code": "jobs -l" }, { "nl_command": "display a long listing of all the directories in the entire file system", "bash_code": "find / -print0 -type d | xargs -0 ls -al" }, { "nl_command": "Removes all files from current folder but 5 newest ones.", "bash_code": "find . -maxdepth 1 -type f -printf '%T@ %p\\0' | sort -r -z -n | awk 'BEGIN { RS=\"\\0\"; ORS=\"\\0\"; FS=\"\" } NR > 5 { sub(\"^[0-9]*(.[0-9]*)? \", \"\"); print }' | xargs -0 rm -f" }, { "nl_command": "create a tar ball of all pdf files in current folder", "bash_code": "find . -name '*.pdf' -print0 | tar czvf pdf.tar --null -T -" }, { "nl_command": "find all the directories in current folder and delete them", "bash_code": "find . -type d -delete" }, { "nl_command": "Go to previous working directory.", "bash_code": "cd -" }, { "nl_command": "search for \"flac\" files in current folder using regular expressions", "bash_code": "find ./ -regex \"./cmn-.\\.flac\"" }, { "nl_command": "This command find displays the files which are modified in the last 15 minutes. And it lists only the unhidden files. i.e hidden files that starts with a . (period) are not displayed in the find output.", "bash_code": "find . -mmin -15 \\( ! -regex \".*/\\..*\" \\)" }, { "nl_command": "Find all *.mp4 files under directory named 'working' and show the first one found", "bash_code": "find working -type f -name \"*.mp4\" | head -1" }, { "nl_command": "calculate the total size of jpg files in current folder", "bash_code": "find . -name \"*jpg\" -exec du -k {} \\; | awk '{ total += $1 } END { print total/1024 \" Mb total\" }'" }, { "nl_command": "Replace all colons (':') with newlines in $list and search for the first match to the regex \"^$removepat\\$\" where $removepat is a variable and save the result to variable 'removestr'", "bash_code": "removestr=$(echo \"$list\" | tr \":\" \"\\n\" | grep -m 1 \"^$removepat\\$\")" }, { "nl_command": "List the names of all file.ext files/directories under present working directory", "bash_code": "find `pwd` -name \"file.ext\" -printf \"%f\\n\"" }, { "nl_command": "Delete all contents form the files that contain the case insensitive regex 'stringtofind' in maximum 1 level down the / directory excluding other partitions", "bash_code": "find / -maxdepth 1 -xdev -type f -exec grep -Zli \"stringtofind\" {} + | parallel -0 sed \"'/./d'\" '{}'" }, { "nl_command": "Show the list of files modified more than 31 days ago", "bash_code": "find / -mtime +31 -print" }, { "nl_command": "Prints the absolute directory path of the current script preceded by the string \"dirname/readlink: \"", "bash_code": "echo \"dirname/readlink: $(dirname $)\"" }, { "nl_command": "Move all *.emlx files/directories under /path/to/folders/ to ./Messages/ directory", "bash_code": "find /path/to/folders/ -name \\*.emlx -print0 | xargs -0 -I {} mv {} ./Messages/" }, { "nl_command": "Search the current directory tree for symbolic links to files matching pattern '*test*'", "bash_code": "find . -lname '*test*'" }, { "nl_command": "Recursively changes group ownership of everything within a '/path/to/repo' to 'GROUP'.", "bash_code": "chgrp -R GROUP /path/to/repo" }, { "nl_command": "Change directory to the directory containing the executable file of command \"oracle\"", "bash_code": "cd $" }, { "nl_command": "Find directories that have \"755\" permissions and modify them to have \"700\" permissions", "bash_code": "find . -type d -perm 755 -exec chmod 700 {} \\;" }, { "nl_command": "list regular files under the user's home directory that are over 100KB and have not been accessed in over 30 days.", "bash_code": "find $HOME -type f -atime +30 -size 100k" }, { "nl_command": "Find all files/directories with 'my key phrase' in their names under current directory", "bash_code": "find . -name '*my key phrase*'" }, { "nl_command": "Find all files that are less than 50 bytes", "bash_code": "find / -size -50c" }, { "nl_command": "find all the text files in the temp folder and search for the word hello in all these files and display the matched files", "bash_code": "find /tmp -type f -name \u2018*.txt*\u2019 | sed -e \u2018s/.*/\\\u201d&\\\u201d/\u2019 |xargs -n 1 grep -l hello|sed -e \u2018s/.*/\\\u201d&\\\u201d/\u2019" }, { "nl_command": "Clean the current directory from all subversion directories recursively", "bash_code": "find . -type d -name \".svn\" -print | parallel rm -rf" }, { "nl_command": "download content from \"http://127.0.0.1:8000\" and output to \"index.html\"", "bash_code": "curl http://127.0.0.1:8000 -o index.html" }, { "nl_command": "find directory which name is Cookbook under /users/al", "bash_code": "find /users/al -name Cookbook -type d" }, { "nl_command": "Go to directory /some/where/long", "bash_code": "cd /some/where/long" }, { "nl_command": "Locate all OGG files that reside in the home directory and have not been accessed in the past 30 days", "bash_code": "find $HOME -iname '*.ogg' -atime +30" }, { "nl_command": "Delete files in /var/tmp/stuff and below that have not been modified in over 90 days", "bash_code": "find /var/tmp/stuff -mtime +90 -delete" }, { "nl_command": "find all files in the home folder which are modified in the last 2 days.", "bash_code": "find ~ -type f -mtime -2" }, { "nl_command": "Find all files named 'Makefile' in the /usr/ports directory tree and count the number of lines in them matching regular expression '^MASTER_SITE.*CPAN'", "bash_code": "find /usr/ports/ -name Makefile -exec grep '^MASTER_SITE.*CPAN' '{}' '+' | wc -l" }, { "nl_command": "List all *fink* files/directories under current directory", "bash_code": "find . -name \"*fink*\" |xargs ls -l" }, { "nl_command": "Remove the passphrase from ~/.ssh/id_rsa.", "bash_code": "ssh-keygen -f ~/.ssh/id_rsa -P \"\"" }, { "nl_command": "Find all regular files under and below /somepath that have extensions PDF, TIF, TIFF, PNG, JPG, JPEG, BMP, PCX, or DCX, ignoring the case and excluding \"*_ocr.pdf\" files", "bash_code": "find /somepath -type f -iregex \".*\\.\" ! -name \"*_ocr.pdf\" -print0" }, { "nl_command": "Find all directories under current directory and replace all null delimiters with : in the output then remove the last :", "bash_code": "find -type d -print0 | sed -e \"y/\\d0/:/;s/:$//;\"" }, { "nl_command": "Find all symbolic links in the current directory tree", "bash_code": "find -type l" }, { "nl_command": "Show filename and filetype description of all PHP files in current directory whose name or filetype description includes \"UTF\"", "bash_code": "file *.php | grep UTF" }, { "nl_command": "Find all directories under and below parent_directory", "bash_code": "find parent_directory -type d" }, { "nl_command": "Saves listing of a current folder in 'OUTPUT' variable.", "bash_code": "OUTPUT=\"$\"" }, { "nl_command": "find all the files in the current folder and save the output to the file dir-list", "bash_code": "find -type d > dir-list" }, { "nl_command": "Search the current directory tree for files whose names are not \"a.txt\"", "bash_code": "find . ! -name \"a.txt\" -print" }, { "nl_command": "display all the files and directories with the name \"CVS\" from /usr/src folder that are at least seven levels deep and do not descend onto the folders", "bash_code": "find /usr/src -name CVS -prune -o -depth +6 -print" }, { "nl_command": "Split \"complete.out\" into files with at most \"$lines_per_file\" lines each", "bash_code": "split --lines $lines_per_file complete.out" }, { "nl_command": "Find all Read Only files in the file system", "bash_code": "find / -perm /u=r" }, { "nl_command": "Display all lines contiaining 'funcname' in system map file matching current kernel.", "bash_code": "cat /boot/System.map-`uname -r` | grep funcname" }, { "nl_command": "display all regular files in the folder image-folder", "bash_code": "find image-folder/ -type f" }, { "nl_command": "Create tar archive \"foo.tar\" and copy all files from directory tree /tmp/a1 to it", "bash_code": "find /tmp/a1 | xargs tar cvf foo.tar" }, { "nl_command": "Find all files in the current directory tree named 'FILES.EXT'", "bash_code": "find . -name \"FILES.EXT\"" }, { "nl_command": "Open all .c files in the current directory tree in the vim editor", "bash_code": "find . -name \"*.c\" -print | vim -" }, { "nl_command": "Search the current directory tree for regular files whose names end in \".shtml\" or \".css\"", "bash_code": "find . -type f \\( -name \"*.shtml\" -o -name \"*.css\" \\) -print" }, { "nl_command": "Force pseudo tty allocation on connection to \"somehost\" and execute \"~/bashplay/f\"", "bash_code": "ssh -t somehost ~/bashplay/f" }, { "nl_command": "Create a copy of the current working directory structure in the usr/project directory,", "bash_code": "find . -type d -print|sed 's@^@/usr/project/@'|xargs mkdir -p" }, { "nl_command": "find all normal/regular files in current folder and replace a word in all these files", "bash_code": "find . -type f -print0 | xargs -0 sed -i '' 's/2013/2012/g'" }, { "nl_command": "Recursively change the owner and group of \"subdir1\" to \"user1\"", "bash_code": "chown user1:user1 -R subdir1" }, { "nl_command": "Find all files that contain the case insensitive regex 'stringtofind' in maximum 1 level down the / directory without descending into other partitions", "bash_code": "find / -maxdepth 1 -xdev -type f -print -exec grep -i \"stringtofind\" -q {} \\;" }, { "nl_command": "Find all files/directories under current directory tree whose paths start with './sr' and end with 'sc'", "bash_code": "find . -path './sr*sc'" }, { "nl_command": "Save the network node hostname append with '-', the current date and '.txt' into variable 'filename'", "bash_code": "filename=\"$-$.txt\"" }, { "nl_command": "Clean up all zombie processes by instantly killing their parent process with SIGKILL signal.", "bash_code": "kill -9 $" }, { "nl_command": "find all text files in the current directory", "bash_code": "find . -name \"*.txt\" -print" }, { "nl_command": "Print the percentage of packets lost of the 5 packets sent to \"$host\"", "bash_code": "ping -c 5 -q $host | grep -oP '\\d+'" }, { "nl_command": "Archive all *.xml files under current directory tree to xml.tar excluding the files that match '/workspace/' in their paths", "bash_code": "find . -name \\*.xml | grep -v /workspace/ | tr '\\n' '\\0' | xargs -0 tar -cf xml.tar" }, { "nl_command": "Find all regular files whose names do not end in \"*.html\"", "bash_code": "find . -type f -not -name \"*.html\"" }, { "nl_command": "Print file type of command \"gcc\"", "bash_code": "file -L `which gcc`" }, { "nl_command": "display the manual page of find", "bash_code": "man find" }, { "nl_command": "Convert all DOS files under and below the current directory to the Unix format", "bash_code": "find . -type f -exec dos2unix {} \\;" }, { "nl_command": "Compress all \".txt\" files in all sub directories with gzip", "bash_code": "gzip */*.txt" }, { "nl_command": "search for all empty directories in the folder /home", "bash_code": "find /home -type d -empty" }, { "nl_command": "Remove all text files in the home directory with confirmation", "bash_code": "find $HOME/. -name *.txt -ok rm {} \\;" }, { "nl_command": "Pass all the files from the current directory tree as arguments to a single 'echo' command", "bash_code": "find . -exec echo {} +" }, { "nl_command": "create a symbolic link named \"/usr/bin/my-editor\" to file \"/usr/share/my-ditor/my-editor-executable\"", "bash_code": "ln -s /usr/share/my-ditor/my-editor-executable /usr/bin/my-editor" }, { "nl_command": "file1 and file2 contain lines of comma-separated information, for each line whose first field matches, and where 3rd field of file1 matches 2nd field of file2, 6th field of file1 matches 3rd field of file2, and 7th field of file1 matches 4th field of file2, output: fields 1, 2, 3, 4, 6, and 7 of file1.", "bash_code": "join -t, file1 file2 | awk -F, 'BEGIN{OFS=\",\"} {if ($3==$8 && $6==$9 && $7==$10) print $1,$2,$3,$4,$6,$7}'" }, { "nl_command": "Prints all child processes of a process with id 20238, separated with comma.", "bash_code": "pstree -p 20238 | sed 's/(/\\n(/g' | grep '(' | sed 's/(\\).*/\\1/' | tr \"\\n\" ," }, { "nl_command": "Isolate first comma-delimited field of each line in \"file\", discard consecutive duplicates, and search \"file\" for first matching occurrence of that field.", "bash_code": "cut -d, -f1 file | uniq | xargs -I{} grep -m 1 \"{}\" file" }, { "nl_command": "Make directories \"foo/bar/baz\" as needed and do not cause an error if it exists", "bash_code": "mkdir -p foo/bar/baz" }, { "nl_command": "Find all 777 permission regular files and use chmod command to set permissions to 644", "bash_code": "find / -type f -perm 0777 -print -exec chmod 644 {} \\;" }, { "nl_command": "Sends current job to the background.", "bash_code": "bg %" }, { "nl_command": "delete all files in $DIR that have not been accessed in at least 5 days", "bash_code": "find \"$DIR\" -type f -atime +5 -exec rm {} \\;" }, { "nl_command": "find all the files and folder that were created in 2012 on Friday of every month", "bash_code": "find / -daystart -mtime +41 -mtime -408 \\ -printf \"%M %n %u %g %10s %TY-%Tm-%Td %Ta %TH:%TM:%TS %h/%f\\n\" | awk '{print}'" }, { "nl_command": "Compresses file 'example.log' keeping original file in place.", "bash_code": "bzip2 -k example.log" }, { "nl_command": "Print chmod commands that can change permissions of regular files residing in the current directory tree to u=rw,g=r,o=", "bash_code": "find . -type f -exec echo chmod u=rw,g=r,o= '{}' \\;" }, { "nl_command": "Find all files/directories named 'findcommandexamples.txt' (case insensitive) in the entire filesystem", "bash_code": "find / -iname findcommandexamples.txt" }, { "nl_command": "Search for all files with either \"sitesearch\" or \"demo\" in their path names", "bash_code": "find . -iregex '.*sitesearch.*' -iregex '.*demo.*'" }, { "nl_command": "Count the number of files in the current directory and below", "bash_code": "find . -type d -exec basename {} \\; | wc \u2013l" }, { "nl_command": "search for the file \"myletter.doc\" in the home folder", "bash_code": "find ~ -name myletter.doc -print" }, { "nl_command": "Enables shell option 'autocd'.", "bash_code": "shopt -s autocd" }, { "nl_command": "Set the permissions of all directories inside the current directory tree to ug=rwx,o=", "bash_code": "find . -type d -name files -exec chmod ug=rwx,o= '{}' \\;" }, { "nl_command": "Print mount point of the file system containing $path.", "bash_code": "df \"$path\" | tail -1 | awk '{ print $6 }'" }, { "nl_command": "Print appended data in \"/var/log/some.log\" that match \"foo\" and \"bar\"", "bash_code": "tail -f /var/log/some.log | grep --line-buffered foo | grep bar" }, { "nl_command": "display all the text files and hidden files in the home folder", "bash_code": "find ~ -name \"*.txt\" \u2014 print -o -name \".*\" \u2014 print" }, { "nl_command": "Remove all files and directories called \"test\" from the current directory tree", "bash_code": "find . -name test -exec rm {} \\;" }, { "nl_command": "Search the entire file hierarchy for files ending with '~' and print all matches except for those with '/media' in their pathnames.", "bash_code": "find / -name \"*~\" | grep -v \"/media\"" }, { "nl_command": "Create a symbolic link in target directory \"$tmpdir\" for each file under the current directory", "bash_code": "find $PWD -type f -exec ln -st $tmpdir {} +" }, { "nl_command": "find all files with pattern` '*.mp3' and send output into nameoffiletoprintto file", "bash_code": "find / -name *.mp3 -fprint nameoffiletoprintto" }, { "nl_command": "Lists all directories in a current folder.", "bash_code": "ls -d */" }, { "nl_command": "display a long listing of all images with the name \"articles\" in the current folder ( print0 is used to preserve file names with new line in their name )", "bash_code": "find . -iname \"Articles.jpg\" -print0 | xargs -0 ls -l" }, { "nl_command": "Write \"Australia/Adelaide\" to standard output and to \"/etc/timezone\"", "bash_code": "echo \"Australia/Adelaide\" | sudo tee /etc/timezone" }, { "nl_command": "Count the number of regular files with case insensitive name pattern $srchfor under 'teste2' directory tree", "bash_code": "find teste2 -type f -iname \"$srchfor\"|wc -l" }, { "nl_command": "Add group write permission to all files and directories in the current directory including hidden files and excluding \"..\"", "bash_code": "chmod g+w $" }, { "nl_command": "Find all $1 files/directories under current directory and enter into the parent directory of the first one found", "bash_code": "cd $(dirname $(find . -name $1 | sed 1q))" }, { "nl_command": "find all the normal/regular files in the current directory", "bash_code": "find -type f" }, { "nl_command": "find all the directories with the name \"DIRNAME\" in the current folder and force delete them", "bash_code": "find . -type d -name \u201cDIRNAME\u201d -exec rm -rf {} \\;" }, { "nl_command": "Find all files named \"MyCProgam.c\" and calculate each file's md5sum.", "bash_code": "find -iname \"MyCProgram.c\" -exec md5sum {} \\;" }, { "nl_command": "Print amount of space available on the file system containing path to the current working directory.", "bash_code": "df $PWD | awk '/[0-9]%/{print $}'" }, { "nl_command": "display all the regular/normal files in the current folder which are modified after a file", "bash_code": "find . -type f -newer \"$FILE\"" }, { "nl_command": "Get A record for domain $domain", "bash_code": "dig $domain" }, { "nl_command": "Test if files named 'something' were found in Dir/", "bash_code": "[[ ! -z `find 'Dir/' -name 'something'` ]] && echo \"found\" || echo \"not found\"" }, { "nl_command": "search for the directory testdir in the folder /home", "bash_code": "find /home -type d -name testdir" }, { "nl_command": "Give rwx permissions to the user and group of the directory named \"files\" leaving others without any privileges", "bash_code": "find . -type d -name files -exec chmod ug=rwx,o= '{}' \\;" }, { "nl_command": "Create symlinks to all /home/folder1/*.txt files and 'folder2_' directory with the same name in a target directory named '+'", "bash_code": "find /home/folder1/*.txt -type f -exec ln -s {} \"folder2_\" + \\;" }, { "nl_command": "Find all regular files with 755 permission under current directory tree and change their permission to 644", "bash_code": "find . -type f -perm 755 -exec chmod 644 {} \\;" }, { "nl_command": "Create a sorted unique list of new or modified files comparing \"old/\" and \"new/\"", "bash_code": "| sort | uniq" }, { "nl_command": "Returns exit code 1 and terminates shell if 'set -e' was applied.", "bash_code": "a=$" }, { "nl_command": "Find all directories under path_to_dir directory", "bash_code": "find path_to_dir -type d" }, { "nl_command": "Find all files/directories named file in 2 and 3 levels down the current directory", "bash_code": "find -mindepth 2 -maxdepth 3 -name file" }, { "nl_command": "Find all *.htm files under current directory", "bash_code": "find -type f -name \"*.htm\"" }, { "nl_command": "Find all files that belong to group root", "bash_code": "find / -group root" }, { "nl_command": "Find all *.ps files under $STARTDIR", "bash_code": "find $STARTDIR -name '*.ps' -print" }, { "nl_command": "Enables shell option 'cmdhist'.", "bash_code": "shopt -s cmdhist" }, { "nl_command": "Fix permissions for a group of files with given extension", "bash_code": "find /usr/local -name \"*.html\" -type f -exec chmod 644 {} \\;" }, { "nl_command": "Recursively change \"/usr/local\" owner to the current user and group to admin", "bash_code": "sudo chown -R $:admin /usr/local" }, { "nl_command": "Search for \"www.athabasca\" in all files under current directory", "bash_code": "find . -exec grep \"www.athabasca\" '{}' \\; -print" }, { "nl_command": "find the type & description of all the regular/normal files in the home folder", "bash_code": "find /home -type f -print0 | xargs -0 file" }, { "nl_command": "Print the newest *.txt file under current directory with timestamp and path", "bash_code": "find . -name \"*.txt\" -printf \"%T@ %p\\n\" | sort | tail -1" }, { "nl_command": "display all the html files in the current folder excluding search in the paths ./foo, ./bar.", "bash_code": "find . -path \"./foo\" -prune -o -path \"./bar\" -prune -o -type f -name \"*.html\"" }, { "nl_command": "Follow symbolic links for the full path of \"lshw\"", "bash_code": "readlink -f $" }, { "nl_command": "Search the current directory tree for files containing \"string\" in their path names", "bash_code": "find | egrep string" }, { "nl_command": "Save number of processors in system to 'NP' variable", "bash_code": "NP=`cat /proc/cpuinfo | grep processor | wc -l`" }, { "nl_command": "display all directories in the folder \"PROD\" and do not search in the sub directories", "bash_code": "find /PROD -maxdepth 1 -type d" }, { "nl_command": "Change all cron jobs running \"anm.sh\" to be run every 10 minutes instead of 5 minutes.", "bash_code": "crontab -l | sed '/anm\\.sh/s,^\\*/5,*/10,' | crontab -" }, { "nl_command": "Send SIGTERM signal to entire process tree starting from ID 24901 and below.", "bash_code": "kill `pstree -p 24901 | sed 's/(/\\n(/g' | grep '(' | sed 's/(\\).*/\\1/' | tr \"\\n\" \" \"`" }, { "nl_command": "Print the last 10 lines of '/var/log/syslog', printing out any additional data appended to the file", "bash_code": "tail -f /var/log/syslog" }, { "nl_command": "Rename the *.so files at level 2 of the current directory tree prepending their names with \"lib\"", "bash_code": "find . -mindepth 2 -maxdepth 2 -name \"*.so\" -printf \"mv '%h/%f' '%h/lib%f'\\n\" | sh" }, { "nl_command": "Search for \"LOG\" in jsmith's home directory tree", "bash_code": "find ~jsmith -exec grep LOG '{}' /dev/null \\; -print" }, { "nl_command": "Change the user to daisy for directories and subdirectories owned by harry", "bash_code": "find . -type d -user harry -exec chown daisy {} \\;" }, { "nl_command": "Treat each line of \"list-of-entries.txt\" as a value to be put in one cell of the table that \"column\" outputs", "bash_code": "column list-of-entries.txt" }, { "nl_command": "Replace all '\u7f6e\u63db\u524d' with '\u7f6e\u63db\u5f8c' in all regular files under current directory tree and modify them in-place", "bash_code": "sudo find . -type f -exec sed -i 's/\u7f6e\u63db\u524d/\u7f6e\u63db\u5f8c/g' {} \\;" }, { "nl_command": "Print variable \"$opt\" with double quotes deleted", "bash_code": "echo \"$opt\" | tr -d '\"'" }, { "nl_command": "search through only the /usr and /home directories for any file named Chapter1.txt", "bash_code": "find /usr /home -name Chapter1.txt -type f" }, { "nl_command": "Print the average round trip time of 5 pings to \"google.com\"", "bash_code": "ping -q -c 5 google.com | tail -n 1 | cut -f 5 -d '/'" }, { "nl_command": "display all the files in the current folder which end with \".bash\"", "bash_code": "find . -name \"*.bash\"" }, { "nl_command": "Find all directories under $root and replace all newlines with : (colon) in the output", "bash_code": "find $root -type d | tr '\\n' ':'" }, { "nl_command": "Copies all files like '*.txt' under the current directory to the './tmp/' directory.", "bash_code": "find . -type f -name '*.txt' | sed 's/'\"'\"'/\\'\"'\"'/g' | sed 's/.*/\"&\"/' | xargs -I{} cp -v {} ./tmp/" }, { "nl_command": "List all files under current directory matching the regex '.*\\(c\\|h\\|cpp\\)'", "bash_code": "find . -type f -regex '.*\\(c\\|h\\|cpp\\)' -exec ls {} \\;" }, { "nl_command": "find all pdf files in current folder and rename all these files", "bash_code": "find . \\ -execdir sh -c 'mv -v \"$1\" \"$(echo \"$1\" | tr \" \" \"_\" | tr -d \"{},\\!'\\''\" | tr \"A-Z\" \"a-z\" | sed \"s/_-_/_/g\")\"' _ {} \\;" }, { "nl_command": "Search the path given as the $absolute_dir_path variable for regular files", "bash_code": "find \"$absolute_dir_path\" -type f -print0" }, { "nl_command": "Search the regular files of the current directory tree for string \"whatever\"", "bash_code": "find . -type f -exec grep -H whatever {} \\;" }, { "nl_command": "display all mp3 files in the file system which have not been accessed in the last 24 hours", "bash_code": "find / -name \u201c*.mp3\u201d -atime +01 -type f" }, { "nl_command": "List files in the current directory", "bash_code": "find . \\" }, { "nl_command": "Read the raw input of \"/dev/input/mice\" as hexadecimal bytes with 3 bytes per line", "bash_code": "cat /dev/input/mice | od -t x1 -w3" }, { "nl_command": "Print space separated numbers from 1 to 10", "bash_code": "seq 10 | xargs echo" }, { "nl_command": "Change to folder where the oracle binary is.", "bash_code": "cd \"$(dirname $(which oracle))\"" }, { "nl_command": "find all the patch files in current folder and copy them to separate folder patches", "bash_code": "find -name '*.patch' -print0 | xargs -0 -I {} cp {} patches/" }, { "nl_command": "Recursively copies 'SRCFOLDER' to the 'DESTFOLDER/'", "bash_code": "cp -R SRCFOLDER DESTFOLDER/" }, { "nl_command": "Execute \"cd ${REMOTE_PATH}; mkdir -p $i\" on host \"$SERVER\" as user \"$USER\" and connect standard input to \"/dev/null\"", "bash_code": "ssh $USER@$SERVER \"cd ${REMOTE_PATH}; mkdir -p $i\" < /dev/null" }, { "nl_command": "Delete all files not owned by valid users", "bash_code": "find / -nouser | xargs -0 rm" }, { "nl_command": "Interactively create a symbolic link in the current directory for \"$SCRIPT_DIR/$FILE\"", "bash_code": "ln --symbolic --interactive $SCRIPT_DIR/$FILE" }, { "nl_command": "display the long listing of all files in /var/log which were modified 60 days or more ago.", "bash_code": "find /var/log/ -mtime +60 -type f -exec ls -l {} \\;" }, { "nl_command": "find all the files in the current folder which belong to the user root.", "bash_code": "find . -user root -perm -4000 -print" }, { "nl_command": "display all the normal/regular files in the current folder", "bash_code": "find . -type f" }, { "nl_command": "Print IP addresses of the host name", "bash_code": "hostname -I | cut -d' ' -f1" }, { "nl_command": "find all the files that have been modified in the last 12 hours", "bash_code": "find ./ -mtime -0.5" }, { "nl_command": "find all the text files in the current folder and do not search in somedir, bin directories", "bash_code": "find . -name somedir -prune , -name bin -prune -o -name \"*.txt\" -print" }, { "nl_command": "Numerically sort standard input by the second word of each line and output from greatest value to least value", "bash_code": "sort -nrk 2,2" }, { "nl_command": "Make directory \"testExpress\"", "bash_code": "mkdir testExpress" }, { "nl_command": "find all the files in the entire file system which belong to the group \"staff\"", "bash_code": "find / -group staff -print" }, { "nl_command": "Send ping requests to hostname specified by variable \"c\" for 1 second.", "bash_code": "ping -w 1 $c" }, { "nl_command": "Find all directories named 'octave' under current directory tree", "bash_code": "find . -name \"octave\" -type d" }, { "nl_command": "Search the current directory tree for all regular files matching pattern \"*.rb\"", "bash_code": "find . -name \"*.rb\" -type f" }, { "nl_command": "Find all directories in the current one recursively which have the write bit set for \"other\"", "bash_code": "find . -type d -perm -o=w" }, { "nl_command": "Find links to any file that happens to be named `foo.txt'", "bash_code": "find / -lname foo.txt" }, { "nl_command": "display all regular/normal files in the current folder which are accessed in the last 7*24 hours", "bash_code": "find . -type f -atime -7" }, { "nl_command": "create symbolic links in current directory to all files located in directory \"/original\" and have filename extension \".processname\"", "bash_code": "find /original -name '*.processme' -exec echo ln -s '{}' . \\;" }, { "nl_command": "find all the files in the current folder that are modified after the modification date of a file", "bash_code": "find . -newer document -print" }, { "nl_command": "display list of all the hidden files in the folder $HOME/projects/ and save the output to the file foo.txt", "bash_code": "find $HOME/projects/ -name \".*\" -ls > foo.txt" }, { "nl_command": "split file \"your_file\" into pieces per 9 lines", "bash_code": "split -l9 your_file" }, { "nl_command": "Replace all newlines except the last with a comma in \"test.txt\"", "bash_code": "sed -i ':a;N;$!ba;s/\\n/,/g' test.txt" }, { "nl_command": "Split the first 100 lines of \"datafile\" into files with at most 1700 bytes each preserving lines", "bash_code": "sed 100q datafile | split -C 1700 -" }, { "nl_command": "display the content of all the instances of the file \"lilo.conf\" in the file system and discard any errors in encountered during the search and display) and save the output to the file \"lilo.txt\"", "bash_code": "find / -type f -name lilo.conf 2>/dev/null -exec cat {} \\; >lilo.txt" }, { "nl_command": "Check whether \"$path_in_question\" is a mount point", "bash_code": "df $path_in_question | grep \" $path_in_question$\"" }, { "nl_command": "Read a line from standard input into variable \"YESNO\" ignoring backslash escapes and using the prompt \"$(echo $@) ? [y/N] \"", "bash_code": "read -r -p \"$(echo $@) ? [y/N] \" YESNO" }, { "nl_command": "Display the count of regular files for which the owner has read and execute permission under 'home/magie/d2' directory tree", "bash_code": "find home/magie/d2 -type f -perm -u+rx | wc -l" }, { "nl_command": "change the extension of all the text files from .txt to .txt_bak in current folder", "bash_code": "find . -name '*.txt' -exec sh -c 'mv \"$0\" \"${0%.txt}.txt_bak\"' {} \\;" }, { "nl_command": "Find *.txt files in the current directory tree, ignoring paths ./Movies/*, ./Downloads/*, and ./Music/*", "bash_code": "find . -type f -name \"*.txt\" ! -path \"./Movies/*\" ! -path \"./Downloads/*\" ! -path \"./Music/*\"" }, { "nl_command": "Open a local SSH port on 1080 for application-level port forwarding", "bash_code": "ssh -D1080 root@localhost -g" }, { "nl_command": "Replace all '\u7f6e\u63db\u524d' with '\u7f6e\u63db\u5f8c' in all regular files under current directory tree and modify them in-place", "bash_code": "sudo find . -type f -exec sed -i 's/\u7f6e\u63db\u524d/\u7f6e\u63db\u5f8c/g' {} \\;" }, { "nl_command": "Find all *.htm files under current directory", "bash_code": "find -type f -name \"*.htm\"" }, { "nl_command": "Find all files under maximum 1 level down the ./subfolder and ./subfolder/*/ paths", "bash_code": "find ./subfolder ./subfolder/*/ -maxdepth 1 -type f" }, { "nl_command": "Executes 'true'. then makes 'xargs' fail executing 'false' and return 123 exit code.", "bash_code": "true | xargs false" }, { "nl_command": "Search the home directory tree for files matching pattern '*.txt'", "bash_code": "find ~ -name *.txt" }, { "nl_command": "add read,write permissions to all the files in the current folder which have the permission 600", "bash_code": "find . -perm 600 -print | xargs chmod 666" }, { "nl_command": "find all the files in the current folder which are bigger than 9MB", "bash_code": "find . -size +9M" }, { "nl_command": "set alias \"go\" for command 'ssh $ -l pete'", "bash_code": "alias go='ssh $ -l pete'" }, { "nl_command": "Find all btree*.c files under current directory", "bash_code": "find . -type f -name 'btree*.c'" }, { "nl_command": "Show all values of variables whose name or value contains \"VARIABLE_NAME\"", "bash_code": "myVariable=$;" }, { "nl_command": "Find all ES* and FS_* files under current directory", "bash_code": "find . -type f \\" }, { "nl_command": "Search the regular files of the current directory tree for string \"whatever\"", "bash_code": "find . -type f | xargs grep whatever" }, { "nl_command": "display all the hidden directories in the directory \"/dir/to/search/\"", "bash_code": "find /dir/to/search -path '*/.*' -print" }, { "nl_command": "Find files accessed at 23:59", "bash_code": "find . -atime -1 -print" }, { "nl_command": "find all the configuration files in /etc folder along with the last access & modification time", "bash_code": "find /etc -name \"*.conf\" -printf \"%f %a, %t\\n\"" }, { "nl_command": "find all normal/regular files in current folder which end with \"~\" or which begin and end with \"#\" and and and delete them", "bash_code": "find . -maxdepth 1 -type f -name '*~' -delete -or -name '#*#' -delete" }, { "nl_command": "create directory /etc/cron.minute", "bash_code": "mkdir /etc/cron.minute" }, { "nl_command": "Find all files/directories under current directory bypassing file hierarchies in lexicographical order", "bash_code": "find -s" }, { "nl_command": "Find all *.ogg (case insensitive) files/directories under your home directory that are not greater than 20MB in size", "bash_code": "find $HOME -iname '*.ogg' ! -size +20M" }, { "nl_command": "Display the named characters in \"line1\\r\\nline2\"", "bash_code": "echo -e \"line1\\r\\nline2\" | od -a" }, { "nl_command": "Show the list of all files on the system whose names do not end in \".c\"", "bash_code": "find / \\! -name \"*.c\" -print" }, { "nl_command": "Execute script 'truncate.sh' on all regular files in the current directory tree", "bash_code": "find . -type f -exec ./truncate {} \\;" }, { "nl_command": "search for the directory \"config\" in the current folder", "bash_code": "find . -name config -type d" }, { "nl_command": "Print calendar for February, March and April of year 2009 side-by-side", "bash_code": "paste <(cal 2 2009) <(cal 3 2009) <(cal 4 2009)" }, { "nl_command": "Print the list of all files in the current directory except for SVN, CVS, GIT, and binary files", "bash_code": "find . -not \\( -name .svn -prune -o -name .git -prune -o -name CVS -prune \\) -type f -print0 | xargs -0 file -n | grep -v binary | cut -d \":\" -f1" }, { "nl_command": "find all the video files in the folder /home/", "bash_code": "find /home/ -type f -exec file {} + | grep -E \"MPEG v4|EBML|Microsoft ASF|Macromedia Flash Video|WebM|Apple QuickTime movie|AVI\"" }, { "nl_command": "Find files/directories that are bigger than 10000 KB in size uder '/usr/local' directory tree", "bash_code": "find /usr/local -size +10000k" }, { "nl_command": "Display the 5 smallest files in the current directory and its sub-directories.", "bash_code": "find . -type f -exec ls -s {} \\; | sort -n | head -5" }, { "nl_command": "Find all the files whose permissions are 777 in the current directory", "bash_code": "find . -type f -perm 0777 -print" }, { "nl_command": "Search the current directory recursively for regular files with the extension given as variable $extension", "bash_code": "find . -type f -name \"*.$extension\"" }, { "nl_command": "Look for \"filename\" in the current directory and below", "bash_code": "find -name filename" }, { "nl_command": "Display the sizes and filepaths of all files/directories with '.undo' extension under current directory tree", "bash_code": "find -name *.undo -print0 | du -hc --files0-from=-" }, { "nl_command": "Use 'top' to monitor one process.", "bash_code": "top \u2013p $PID" }, { "nl_command": "Find all files named 'Makefile' in the /usr/ports directory tree and count the number of lines in them beginning with USE_RC_SUBR", "bash_code": "find /usr/ports/ -name Makefile -exec grep ^USE_RC_SUBR '{}' '+' | wc -l" }, { "nl_command": "Search for 'stuff' in all *,txt files under current directory", "bash_code": "find . -name \"*.txt\" -print0 | xargs -0 egrep 'stuff'" }, { "nl_command": "set alias \"clean\" for command 'rm -rf \"#\"* \".\"*~ *~ *.bak *.dvi *.aux *.log'", "bash_code": "alias clean='rm -rf \"#\"* \".\"*~ *~ *.bak *.dvi *.aux *.log'" }, { "nl_command": "display all the regular/normal files in current directory", "bash_code": "find . -type f" }, { "nl_command": "find all the regular/normal files in the current directory which do not have the extension comment and and redirect the output to /tmp/list", "bash_code": "find . -type f \\! -name \"*.Z\" \\! -name \".comment\" -print | tee -a /tmp/list" }, { "nl_command": "change owner and group of the file script.sh to user root", "bash_code": "chown root:root script.sh" }, { "nl_command": "Recursively change all permissions under \"theDirectory/\" to 777(read,write,execute for all users)", "bash_code": "sudo chmod -R 777 theDirectory/" }, { "nl_command": "List all the .c files under the current directory and below in a 3 column format", "bash_code": "find . -name \"*.c\" | xargs -n3" }, { "nl_command": "find -name '*.js' -not -path './node_modules/*' -not -path './vendor/*'", "bash_code": "find -name '*.js' -not \\" }, { "nl_command": "prints a number stored among text in $filename", "bash_code": "echo $filename | egrep -o '[[:digit:]]{5}' | head -n1" }, { "nl_command": "Return 0 if file system is mounted on '/full/path'", "bash_code": "df /full/path | grep -q /full/path" }, { "nl_command": "Print the first 5 characters followed by the next 5 characters on a new line for each line in \"input_file\" and split the result into files of at most 2000000 lines each with a filename prefix \"out-prefix-\"", "bash_code": "sed 's/\\(.....\\)\\(.....\\)/\\1\\n\\2/' input_file | split -l 2000000 - out-prefix-" }, { "nl_command": "Search for \"search term\" in a sorted list of all files under current directory", "bash_code": "find . | awk '{FS = \"/\" ; print \"\", NF, $F}' | sort -n | awk '{print $2}' | xargs grep -d skip \"search term\"" }, { "nl_command": "force create hard link between $GIT_DIR/../apresentacao/apresentacao.pdf and $GIT_DIR/../capa/apresentacao.pdf", "bash_code": "ln -f $GIT_DIR/../apresentacao/apresentacao.pdf $GIT_DIR/../capa/apresentacao.pdf" }, { "nl_command": "Print common lines in \"file1\" and \"file2\"", "bash_code": "comm -12 file1 file2" }, { "nl_command": "Find all the Sticky Bit files whose permission are 551", "bash_code": "find / -perm 0551" }, { "nl_command": "Locate all *.txt files in the current directory tree", "bash_code": "find . -name \"*.txt\"" }, { "nl_command": "change user of the direct public_html to user owner and group nobody", "bash_code": "chown owner:nobody public_html" }, { "nl_command": "List all files and directories from the current directory tree", "bash_code": "find . -print | xargs ls" }, { "nl_command": "Show total memory used by processes in MB", "bash_code": "ps -eo size,pid,user,command --sort -size | awk '{ hr=$1/1024 ; printf } { for { printf } print \"\" }' | awk '{total=total + $1} END {print total}'" }, { "nl_command": "Print type of the file system containing path $dir.", "bash_code": "df -T $dir | tail -1 | awk '{print $2;}'" }, { "nl_command": "Find all files/directories with '.txt' extension under '/home' directory tree that are exactly 100KB in size", "bash_code": "find /home -name \"*.txt\" -size 100k" }, { "nl_command": "find all the files in the current folder which have been accessed in the last 60 minutes", "bash_code": "find . -amin -60" }, { "nl_command": "Split \"system.log\" into files of at most 10 MiB in size with a numeric suffix and prefix \"system_split.log\"", "bash_code": "split -b 10M -d system.log system_split.log" }, { "nl_command": "Print the current directory", "bash_code": "find -maxdepth 0" }, { "nl_command": "find directories under the $LOGDIR directory where there has been no modifications within the last 24 hours and compresses the files.", "bash_code": "find $LOGDIR -type d -mtime +0 -exec compress -r {} \\;" }, { "nl_command": "Search all files in the current directory tree whose names end in \"1\" for string \"1\"", "bash_code": "find . -name \"*1\" -print0 |xargs -0 grep \"1\"" }, { "nl_command": "Prints all NS servers of domain google.com.", "bash_code": "dig google.com ns | awk 'p{print $5}/^;; ANSWER SECTION:$/{p=1}/^$/{p=0}'" }, { "nl_command": "Find all aliencoders.[0-9]+ files under /home/jassi/ directory", "bash_code": "find /home/jassi/ -type f -name \"aliencoders.[0-9]+\"" }, { "nl_command": "Find all files/directories with space in their names under /tmp/ directory and rename them by replacing all spaces with _", "bash_code": "find /tmp/ -depth -name \"* *\" -execdir rename 's/ /_/g' \"{}\" \\;" }, { "nl_command": "Compare sorted files 'f1.txt' and 'f2.txt' and print in three columns strings unique for first file, second file, and common ones", "bash_code": "comm <(sort -n f1.txt) <(sort -n f2.txt)" }, { "nl_command": "Mark variables and function which are modified or created for export to the environment of subsequent commands", "bash_code": "set -a" }, { "nl_command": "Infinitely ping every host listed in \"file-of-ips\" with at most 50 processes at once", "bash_code": "cat file-of-ips | xargs -n 1 -I ^ -P 50 ping ^" }, { "nl_command": "Print file system disk space usage in posix and human readable format, format as a table", "bash_code": "df -Ph | column -t" }, { "nl_command": "Set variable 'path' to name of current directory (without the containing directories) converted to lowercase.", "bash_code": "path=$(basename $(pwd) | tr 'A-Z' 'a-z' )" }, { "nl_command": "Delete all .svn files/directories under current directory", "bash_code": "find . -depth -name .svn -exec rm -fr {} \\;" }, { "nl_command": "Prints calendar of $month, $year, and redirects all output to the awk script 'cal.awk', with predefined variable 'day=$day'.", "bash_code": "cal $month $year | awk -v day=$day -f cal.awk" }, { "nl_command": "Find all files/directories named 'foo' in the entire filesystem", "bash_code": "find / -name foo" }, { "nl_command": "Find all files under current directory with their timestamp and paths and print a sorted list", "bash_code": "sort < <" }, { "nl_command": "find all foo.bar files in the entire file system and discard the errors", "bash_code": "find / -name foo.bar -print 2>/dev/null" }, { "nl_command": "Find all directories under ~/code and replace all newlines with : in the output then remove the last :", "bash_code": "find ~/code -type d | tr '\\n' ':' | sed 's/:$//'" }, { "nl_command": "Find all files/directories under $1 which have at least write permission for their owner and set write permission for group for these files/directories", "bash_code": "find \"$1\" -perm -u+w -print0 | xargs chmod g+w" }, { "nl_command": "Recursively removes all files like '*.pyc' in a current folder.", "bash_code": "rm **/*.pyc" }, { "nl_command": "Delete all .pyc files in the current directory tree", "bash_code": "find . -name \"*.pyc\" | xargs rm -rf" }, { "nl_command": "Rename file with inode number 31467125 to new_name.html", "bash_code": "find . -type f -inum 31467125 -exec /bin/mv {} new_name.html \\;" }, { "nl_command": "Create empty files with names matching each word in variable \"correctFilePathAndName\"", "bash_code": "echo -e \"$correctFilePathAndName\" | xargs touch" }, { "nl_command": "change owner and group of the file \"file\" to user \"user\" and group \"group\"", "bash_code": "chown user:group file ..." }, { "nl_command": "search in the current folder for the files that begin with \"myletter\"", "bash_code": "find . -name 'myletter*' -print" }, { "nl_command": "Find all duplicate \".jar\" files in the current directory tree", "bash_code": "find . -type f -printf \"%f\\n\" -name \"*.jar\" | sort -f | uniq -i -d" }, { "nl_command": "Find all files/directories under '/home/exampleuser/' directory tree whose names end with 'conf' and were modified exactly 3 days ago", "bash_code": "find /home/exampleuser/ -name \"*conf\" -mtime 3" }, { "nl_command": "Counts lines in file $file ignoring '//' commented lines, lines with spaces only and empty lines.", "bash_code": "cat $file | sed '/\\/\\//d' | sed '/^\\s*$/d' | wc -l" }, { "nl_command": "Print file name without the last two extensions assuming the file name doesn't contain any other dots.", "bash_code": "echo \"$FILE\" | cut -d'.' --complement -f2-" }, { "nl_command": "List all leaf directories of the current directory tree", "bash_code": "find -depth -type d | while read dir; do [[ ! $prev =~ $dir ]] && echo \"${dir}\" ; prev=\"$dir\"; done" }, { "nl_command": "Find all files in the current directory tree which do not belong to any user", "bash_code": "find . -nouser" }, { "nl_command": "Find links to file path/to/foo.txt", "bash_code": "find -L / -samefile path/to/foo.txt" }, { "nl_command": "find all the cpp files in the current folder", "bash_code": "find . -iname '*.cpp' -print" }, { "nl_command": "Find recursively all Python files in the current directory and search them for the word \u2018import\u2019", "bash_code": "find . -name '*.py' | xargs grep 'import'" }, { "nl_command": "Search for file 'secret.keys' redirecting error messages to /dev/null", "bash_code": "find / -name 'secret.keys' -print 2>/dev/null" }, { "nl_command": "Find all python files (.py files) in $topdir directory tree and search for 'Makefile' in all these folders and display all distinct folders having 'Makefile'", "bash_code": "find \"$topdir\" -name '*.py' -printf '%h\\0' | xargs -0 -I {} find {} -mindepth 1 -maxdepth 1 -name Makefile -printf '%h\\n' | sort -u" }, { "nl_command": "Search the current directory tree for executable files and searchable directories", "bash_code": "find -executable" }, { "nl_command": "Prints day of first Tuesday in a month.", "bash_code": "cal | awk 'NR>2{Sfields=7-NF; if (Sfields == 0 ) {printf \"%02d\\n\",$3;exit}}'" }, { "nl_command": "Execute python script \"test.py\" with \"LD_PRELOAD=./linebufferedstdout.so\" and write the output to console and append to \"test.out\"", "bash_code": "LD_PRELOAD=./linebufferedstdout.so python test.py | tee -a test.out" }, { "nl_command": "Move \"file.txt\" to docker container \"$CONTAINER_ID\" in path \"/var/lib/docker/devicemapper/mnt/$CONTAINER_ID/rootfs/root/file.txt\"", "bash_code": "mv -f file.txt /var/lib/docker/devicemapper/mnt/$CONTAINER_ID/rootfs/root/file.txt" }, { "nl_command": "Prints groups list that current user belongs to.", "bash_code": "groups //take a look at the groups and see" }, { "nl_command": "find all files in the file system having the name \"filename\"", "bash_code": "find / -iname \"filename\"" }, { "nl_command": "Find all 777 permission files and use chmod command to set permissions to 644", "bash_code": "find / -type f -perm 0777 -print -exec chmod 644 {} \\;" }, { "nl_command": "Format output of 'file' content to columns with wide not less than 80 pixels", "bash_code": "cat file | column -c 80" }, { "nl_command": "Delete all files that were modified more than 60 days ago under '/path-to-directory' tree", "bash_code": "find /path-to-directory -mtime +60 -exec rm -f {} \\;" }, { "nl_command": "List all files in the current directory tree except for those in the ./src/emacs directory", "bash_code": "find . -path './src/emacs' -prune -o -print" }, { "nl_command": "Find all .gif and .jpg files in the /var/www directory tree", "bash_code": "find /var/www -name *.gif -o -name *.jpg" }, { "nl_command": "Gets MAC address of 'eth0' network interface.", "bash_code": "x=$ && x=${x#*HWaddr } && echo ${x%% *}" }, { "nl_command": "Search everywhere for a file called `httpd.conf' that is newer than /etc/apache-perl/httpd.conf", "bash_code": "find / -name httpd.conf -newer /etc/apache-perl/httpd.conf" }, { "nl_command": "Prints strings with MAC address configuration of each network interface in system.", "bash_code": "ifconfig | grep HW" }, { "nl_command": "Copy current working directory to clipboard", "bash_code": "pwd | tr -d '\\n' | pbcopy" }, { "nl_command": "Search for 'invalidTemplateName' in all regular files in directories/files taken from the glob pattern './online_admin/*/UTF-8/*' and show the matched lines with the filenames", "bash_code": "find ./online_admin/*/UTF-8/* -type f -exec grep -H \"invalidTemplateName\" {} \\;" }, { "nl_command": "Compare column 3 with column 2 of the next line in \"file\" and format output as a table", "bash_code": "awk 'NR==1 { print; next } { print $0, ($1 == a && $2 == b) ? \"equal\" : \"not_equal\"; a = $1; b = $3 }' file | column -t" }, { "nl_command": "Find files not matching the posix extended regex '.+\\-[0-9]{2,4}x[0-9]{2,4}\\.jpg' in their paths under Folder1 and copy them to Folder2", "bash_code": "find Folder1 -type f -regextype posix-extended \\ -print0 | xargs -0 cp -p --target-directory=Folder2" }, { "nl_command": "Sort content of files 'file1' and 'file2' by second of dot-separated fields.", "bash_code": "cat file1 file2 |sort -t. -k 2.1" }, { "nl_command": "open interactive list of jobs to select from", "bash_code": "fg `jobs | iselect -a | grep -o [0-9]*`" }, { "nl_command": "Copies file 'file.txt' to each top-level directory in the current directory.", "bash_code": "ls -d */ | xargs -iA cp file.txt A" }, { "nl_command": "find & Substitute Only When the Line Matches with the Pattern Using sed", "bash_code": "find . -type f -name \"*.txt\" -exec sed '/\\-/s /\\-.*//g' {} \\;" }, { "nl_command": "Find all 400 permission files under /data directory and print 'Modifying ' appended with file path for each of them", "bash_code": "find /data -type f -perm 400 -exec echo Modifying {} \\;" }, { "nl_command": "Output line number and lines 200000000 through 200000005 from the infinite input of \"y\"", "bash_code": "yes | sed -n '200000000,${=;p};200000005q'" }, { "nl_command": "find all the files in the current folder which have a set uid set", "bash_code": "find . -perm -4000 -print" }, { "nl_command": "Append the contents of \".cwdhist\" file to the current in-memory history list", "bash_code": "history -r .cwdhist" }, { "nl_command": "when using vi-insert keymap bind command \"\\C-v{}\\ei\" to key \"{\"", "bash_code": "bind -m vi-insert '\"{\" \"\\C-v{}\\ei\"'" }, { "nl_command": "Recursively copy directory \"/path/to/data/myappdata\" to \"user@host:/remote/path/to/data/newdirname\"", "bash_code": "rsync -rvv --recursive /path/to/data/myappdata user@host:/remote/path/to/data/newdirname" }, { "nl_command": "Look up for 'myip.opendns.com' in server 'resolver1.opendns.com' and save the terse output in 'IP' variable", "bash_code": "IP=$" }, { "nl_command": "Display the named characters in \"Test\\rTesting\\r\\nTester\\rTested\"", "bash_code": "echo -e \"Test\\rTesting\\r\\nTester\\rTested\" | awk '{ print $0; }' | od -a" }, { "nl_command": "Copy permissions from \"version2/somefile\" to \"version1/somefile\"", "bash_code": "chmod --reference version2/somefile version1/somefile" }, { "nl_command": "Print the list of the current directory's subdirectories", "bash_code": "find -maxdepth 1 -type d" }, { "nl_command": "find all the files ending with \"clj\" in the current folder and search for a pattern", "bash_code": "find . -name '*.clj' -exec grep -r resources {} \\;" }, { "nl_command": "Recursively search for all files whose name contains 'foo', and change the 'foo' in the filenames to 'bar'.", "bash_code": "find -f \\" }, { "nl_command": "list all CSS files (and directories ending with \u201c.css\u201d) under the current directory", "bash_code": "find . -name \"*.css\"" }, { "nl_command": "Prints the day of last Friday in a current month.", "bash_code": "cal | awk '$6{date=$6}END{print date}'" }, { "nl_command": "Remount \"point\" subtree to \"mnt\" as a bind mount", "bash_code": "mount --bind point mnt" }, { "nl_command": "Print bash environment variable array \"fields\" and its values", "bash_code": "set | grep ^fields=\\\\\\|^var=" }, { "nl_command": "Save the first three octets of the host name's IP address to variable \"subnet\"", "bash_code": "subnet=$(hostname -i | cut -d. -f1,2,3)" }, { "nl_command": "Find files in the \"dir\" directory tree whose names are 33 characters in length", "bash_code": "find dir -name '?????????????????????????????????'" }, { "nl_command": "Find the core files and remove them", "bash_code": "find . -name \u201ccore\u201d -exec rm -f {} \\;" }, { "nl_command": "Search the /Path directory tree for files matching pattern \"file_name*\" and containing \"bar\" in their pathnames", "bash_code": "find /Path -name \"file_name*\" | grep \"bar\"" }, { "nl_command": "Mount \"/dev/shm\" using /etc/fstab entry", "bash_code": "mount /dev/shm" }, { "nl_command": "Display a list of files with sizes in decreasing order of size of all the regular files under '/your/dir' directory tree that are bigger than 5 MB in size", "bash_code": "find /your/dir -type f -size +5M -print0 | xargs -0 ls -1Ssh" }, { "nl_command": "Find all directories under and below /root that match pattern \"*linux*\", case insensitive", "bash_code": "find /root -type d -iname \"*linux*\"" }, { "nl_command": "Print yesterday's date information in \"%a %d/%m/%Y\" format", "bash_code": "date -d \"-1 days\" +\"%a %d/%m/%Y\"" }, { "nl_command": "Save the last modified time of file 'file_name' to variable 'STAMP'", "bash_code": "STAMP=`date -r file_name`" }, { "nl_command": "Print a sorted list of the extensions of the regular files from the current directory tree with counts per extension", "bash_code": "find . -type f | sed -e 's/.*\\.//' | sed -e 's/.*\\///' | sort | uniq -c | sort -rn" }, { "nl_command": "List all files in the current directory tree that were last modified more than 60 minutes ago", "bash_code": "find -mmin +60" }, { "nl_command": "Provide a list of all the files edited today to pr, and pipe pr's output to the printer", "bash_code": "find . -type f -mtime -1 -print|xargs pr -n |lp" }, { "nl_command": "search for the file \"foobar.txt\" in the folder \"/home/mywebsite\"", "bash_code": "find /home/mywebsite -type f -name \"foobar.txt\"" }, { "nl_command": "Print the first two bytes of \"my_driver\" in octal", "bash_code": "od --read-bytes=2 my_driver" }, { "nl_command": "Change all cron jobs running \"anm.sh\" to be run every 10 minutes instead of 5 minutes.", "bash_code": "crontab -l | sed '/anm\\.sh/s#\\/5#\\/10#' | crontab -" }, { "nl_command": "List files named \"accepted_hits.bam\" in the current directory tree prefixing their names with \"somecommand\"", "bash_code": "find `pwd` -name \"accepted_hits.bam\" | xargs -i echo somecommand {}" }, { "nl_command": "Find all empty directories in the current one and delete them", "bash_code": "find . -type d -maxdepth 1 -empty -delete" }, { "nl_command": "copy all the regular/normal files from temp folder which have been modified in the last 30*24 hours to /tmp/backup", "bash_code": "find /tmp -type f -mtime -30 -exec cp {} /tmp/backup \\;" }, { "nl_command": "Find files with inode number 199053", "bash_code": "find / -inum 199053" }, { "nl_command": "Output lines 16224 to 16482 of 'file', and stop reading 'file' after line 16482.", "bash_code": "awk 'NR==16224, NR==16482-1; NR==16482 {print; exit}' file" }, { "nl_command": "Remove trailing white spaces from all *.py files under dir directory (ignoring .git path) and keep backups of the originals", "bash_code": "find dir -not -path '.git' -iname '*.py' -print0 | xargs -0 sed --in-place=.bak 's/[[:space:]]*$//'." }, { "nl_command": "search for files which are writable by both their owner and their group", "bash_code": "find . -perm -g+w,u+w" }, { "nl_command": "Search for aaa in all files under current directory and count the number of matches", "bash_code": "find .|xargs perl -p -e 's/ /\\n'|xargs grep aaa|wc -l" }, { "nl_command": "find all directories that names are 'project.images' and display details", "bash_code": "find / -type d -name \"project.images\" -ls" }, { "nl_command": "Find all files under ${searchpath} that match the regex ${string1}.*${string2}.*${string3} in their contents where ${string1} etc.. will be expanded", "bash_code": "find \"${searchpath}\" -type f -print0 | xargs -0 grep -l -E \"${string1}\".*\"${string2}\".*\"${string3}\"" }, { "nl_command": "Find files accessed at 23:59", "bash_code": "find . -atime -1 -print" }, { "nl_command": "Create a symbolic link named \"$1/link\" to the existing full and real path of \"$2\"", "bash_code": "ln -s \"$(readlink -e \"$2\")\" \"$1/link\"" }, { "nl_command": "Create a new RSA key for ssh with no passphrase, store it in ~/.ssh/id_rsa without prompting to overwrite if this file exists, and minimize output from ssh-keygen.", "bash_code": "echo -e 'y\\n'|ssh-keygen -q -t rsa -N \"\" -f ~/.ssh/id_rsa" }, { "nl_command": "Replace spaces in file names with underscores for all files in the current directory tree", "bash_code": "find -name \"* *\" -type f | rename 's/ /_/g'" }, { "nl_command": "Print a colon-separated list of all directories from the ~/code directory tree, except hidden ones and those below them", "bash_code": "find ~/code -type d | sed '/\\/\\\\./d' | tr '\\n' ':' | sed 's/:$//'" }, { "nl_command": "Find all files/directories under /path/to/dir and set directory permission to 0755 and file permission to 0644", "bash_code": "find /path/to/dir -type d -exec chmod 0755 '{}' \\; -o -type f -exec chmod 0644 '{}' \\;" }, { "nl_command": "display all the file in the folder /home/david/ which start with the word \"index\"", "bash_code": "find /home/david -name 'index*'" }, { "nl_command": "Find all .rb files owned by root in the /apps/ folder and below that have been accessed in the last two minutes.", "bash_code": "find /apps/ -user root -type f -amin -2 -name *.rb" }, { "nl_command": "Find x* files/directories under /tmp directory whose status was changed less than 1 day ago", "bash_code": "find /tmp/ -ctime -1 -name x*" }, { "nl_command": "List files in the current directory tree using echo", "bash_code": "find . -exec echo {} ;" }, { "nl_command": "Find all the files whose permissions are 777 under current directory", "bash_code": "find . -type f -perm 0777 -print" }, { "nl_command": "Count non-blank lines in a file 'foo.c'", "bash_code": "sed '/^\\s*$/d' foo.c | wc -l" }, { "nl_command": "create directories mnt and point", "bash_code": "mkdir mnt point" }, { "nl_command": "Delete all empty files and directories in the \"test\" directory tree", "bash_code": "find test -depth -empty -delete" }, { "nl_command": "Search the current directory tree for files whose name is \".note\", case insensitive", "bash_code": "find . -iname '.note' | sort" }, { "nl_command": "Search the file system for regular files whose names are shorter than 25 characters", "bash_code": "find / -type f| egrep -o \"/[^/]{0,24}$\" | cut -c 2-" }, { "nl_command": "search for a word in all the files in the current directory and display the file paths relative to the current directory", "bash_code": "find . -exec grep -l foo {} +" }, { "nl_command": "Print the help message of command \"split\"", "bash_code": "split --help" }, { "nl_command": "Find all files/directories under /myfiles that are 2560 bytes in size", "bash_code": "find /myfiles -size 5" }, { "nl_command": "Gunzip all files matching \"file*.gz\" and answer \"n\" to any prompts", "bash_code": "yes n | gunzip file*.gz" }, { "nl_command": "Remove trailing white spaces from all files under current directory ignoring .git and .svn directories", "bash_code": "find . -not \\ -type f -print0 | xargs -0 sed -i '' -E \"s/[[:space:]]*$//\"" }, { "nl_command": "Find all empty files in home directory", "bash_code": "find ~ -empty" }, { "nl_command": "prints first line of $bigfile", "bash_code": "head -n1 $bigfile" }, { "nl_command": "find all text files in the folder \"FFF\" and find the md5sum for them and save the output to a file", "bash_code": "find FFF -name \"*.txt\" -exec md5sum '{}' \\; > $TMP_ORI" }, { "nl_command": "display all files in the current folder which end with extension \"myfile\" followed by two digits", "bash_code": "find . -regex '.*myfile[0-9][0-9]?'" }, { "nl_command": "Find 10 most recently changed files in the current directory tree", "bash_code": "find . -type f -printf \"%C@ %p\\n\" | sort -rn | head -n 10" }, { "nl_command": "create a gzip of all the files in the current folder excluding the already gzipped files.", "bash_code": "find . \\! -name \"*.gz\" -exec gzip {} \\;" }, { "nl_command": "Recursively finds all files like \"*.log\" and \"*.trc\" in a current folder, modified in a last day, sorts list by modification time and pipes output to pager tool 'less'.", "bash_code": "sudo find . \\ -mtime -1 | sudo xargs ls -ltr --color | less -R" }, { "nl_command": "SSH with trusted X11 forwarding into \"user@remoteToRemote_IP\" from SSH connection \"user@remote_IP\"", "bash_code": "ssh -XY -t user@remote_IP 'ssh -XY -t user@remoteToRemote_IP'" }, { "nl_command": "Remove the last two components of $path", "bash_code": "echo $path | rev | cut -d'/' -f4- | rev" }, { "nl_command": "Print amount of space available on the file system containg path to the current working directory human-readable.", "bash_code": "df -Ph $PWD | tail -1 | awk '{ print $3}'" }, { "nl_command": "Print the list of all files under the current directory and below", "bash_code": "find ." }, { "nl_command": "display all normal/regular files in current folder which have readable permission", "bash_code": "find . -type f -readable" }, { "nl_command": "Take the section of variable \"FILE\" between the last slash and the following dot, if any, and store that section in variable \"NAME\".", "bash_code": "NAME=`basename \"$FILE\" | cut -d'.' -f-1`" }, { "nl_command": "Prints only unique lines of './yourscript.ksh' output.", "bash_code": "./yourscript.ksh | sort | uniq" }, { "nl_command": "delete all the \".doc\" files in the current folder", "bash_code": "find . -name '*.doc' -exec rm \"{}\" \\;" }, { "nl_command": "Reread user's .profile configuration file.", "bash_code": "source ~/.profile" }, { "nl_command": "run a script in 1000 seconds", "bash_code": "./hw | sleep 1000" }, { "nl_command": "Print absolute path of \"YOUR_PATH\"", "bash_code": "readlink -f YOUR_PATH" }, { "nl_command": "Find files larger than 50k", "bash_code": "find . -size +50k" }, { "nl_command": "Force create a symbolic link to \"$f\" in \"~/my-existing-links/\" with name the basename of \"$f\"", "bash_code": "ln -sf \"$f\" \"~/my-existing-links/$(basename $f)\"" }, { "nl_command": "Run `fastqc' on all the fastqc files in the current directory tree", "bash_code": "find . -name \"*.fq\" -print0 | xargs -0 -n 1 fastqc" }, { "nl_command": "Move \"file.txt\" to docker container \"$COUNTAINER_ID\" in path \"/var/lib/docker/aufs/mnt/$CONTAINER_ID/rootfs/root/file.txt\"", "bash_code": "mv -f file.txt /var/lib/docker/aufs/mnt/$CONTAINER_ID/rootfs/root/file.txt" }, { "nl_command": "search all block spacial files called backup from /usr directory downwards and print them .", "bash_code": "find /usr -type b -name backup -print" }, { "nl_command": "Search for all the directories named 'm?' under current directory tree, add the extension \".mbox\" to all, create a 'Messages' directories inside them and move all files with .emlx extension to 'Messages' directory", "bash_code": "find . -name 'm?' -type d -exec mv '{}' '{}.mbox' ';' -exec mkdir '{}.mbox/Messages' ';' -exec sh -c 'mv {}.mbox/*.emlx {}.mbox/Messages' ';'" }, { "nl_command": "Search for 'string-to-find' in all files under current directory tree and show the matched lines with their filenames", "bash_code": "find . -exec grep -H string-to-find {} \\;" }, { "nl_command": "Print concatenated content of all files ending with '.foo' under the current folder", "bash_code": "cat `find . -name '*.foo' -print`" }, { "nl_command": "Find all files with extension .aac in the /home directory tree", "bash_code": "find /home -type f -name '*.aac'" }, { "nl_command": "Find all regular files in the current directory tree, except GIT files", "bash_code": "find . -name .git -prune -o -type f -print" }, { "nl_command": "Prints ten latest modified files within the current directory.", "bash_code": "find . -type f -printf '%T@ %p\\n' | sort -n -r | head -${numl} | cut -f2- -d\" \" | sed -e 's,^\\./,,' | xargs ls -U -l" }, { "nl_command": "Print the IP addresses of the host name", "bash_code": "hostname -I" }, { "nl_command": "Search the current working directory tree for files whose names start with \"fileA_\" or \"fileB_\"", "bash_code": "find . -name 'fileA_*' -o -name 'fileB_*'" }, { "nl_command": "find all the files in the file system that belong to the user www", "bash_code": "find / -user www -print" }, { "nl_command": "Identify CMS version/releases accross all your PHPBB installations", "bash_code": "find /home/*/public_html/ -type f -wholename *includes/constants.php -exec grep -H \"PHPBB_VERSION\" {} \\;" }, { "nl_command": "Execute the first instance of \"parallel\" found in the PATH, passing it all parameters received by the script/function", "bash_code": "`which parallel` \"$@\"" }, { "nl_command": "Recursively changes group ownership of everything within a current folder and having group 'X_GNAME' to 'Y_GNAME'.", "bash_code": "find . -group X_GNAME -exec chgrp Y_GNAME {} +" }, { "nl_command": "Set the 'verbose' shell option causing bash to print shell input lines as they are read", "bash_code": "set -v" }, { "nl_command": "Change symbolic link \"$f\" into a file", "bash_code": "cp --remove-destination $ $f" }, { "nl_command": "Find all files/directories under '/home/user/' directory tree whose status was changed exactly 10 minitues ago", "bash_code": "find /home/user/ -cmin 10 -print" }, { "nl_command": "Find all files in your home directory and below that are larger than 100M.", "bash_code": "find ~ -size +100M" }, { "nl_command": "Extract and print hostname and protocol part from URL like \"http://www.suepearson.co.uk/product/174/71/3816/\".", "bash_code": "echo \"http://www.suepearson.co.uk/product/174/71/3816/\" | cut -d'/' -f1-3" }, { "nl_command": "Find all files/directories named 'FindCommandExamples.txt' under '/root' directory tree", "bash_code": "find /root -name FindCommandExamples.txt" }, { "nl_command": "Parse XML file \"example.xml\" and extract and number all \"key\" tags from the \"config\" section", "bash_code": "xmllint example.xml --xpath \"/config/*/@*\" | sed \"s| key|\\nkey|g\" | nl" }, { "nl_command": "Run the java archive 'start.jar' in a xterm window, immune to SIGHUP sent to it. The xterm is sent to background, so control returns immediately to the prompt on the original terminal screen/window.", "bash_code": "nohup xterm -e java -jar start.jar &" }, { "nl_command": "Assign a name when starting a screen session", "bash_code": "screen -r 'name'" }, { "nl_command": "split processed content of the file inout_file into pieces per 2000000 named as \"out-prefix-NNN\"", "bash_code": "sed 's/\\(.....\\)\\(.....\\)/\\1\\n\\2/' input_file | split -l 2000000 - out-prefix-" }, { "nl_command": "Recursively change owner of all files in \"folder\" to \"user_name\"", "bash_code": "chown -R user_name folder" }, { "nl_command": "display list of all the C files in current folder", "bash_code": "find . -name '*.c' -ls" }, { "nl_command": "Remove empty directories", "bash_code": "find -type d -exec rmdir --ignore-fail-on-non-empty {} + ;" }, { "nl_command": "Print nothing because B.txt is compared with itself.", "bash_code": "comm -2 -3 < <" }, { "nl_command": "Unzip \"some.file.gz\" to standard output", "bash_code": "gunzip < some.file.gz" }, { "nl_command": "Print a listing of the `other' directory", "bash_code": "$ find other -maxdepth 1" }, { "nl_command": "Find all files throughout the entire file hierarchy with the optional constraints of \u043e\u043f\u0446\u0438\u044f_\u043f\u043e\u0438\u0441\u043a\u0430, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 and/or \u043e\u043f\u0446\u0438\u044f_\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f.", "bash_code": "find / [\u043e\u043f\u0446\u0438\u044f_\u043f\u043e\u0438\u0441\u043a\u0430] [\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435] \t[\u043e\u043f\u0446\u0438\u044f_\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f]" }, { "nl_command": "Concatenate all PDF files under current directory into all.pdf", "bash_code": "pdfunite `find . -name \"*.pdf\" | sort` all.pdf" }, { "nl_command": "Remove all files under /home/user/Maildir/.SPAM/cur", "bash_code": "find /home/user/Maildir/.SPAM/cur -type f -exec rm '{}' +" }, { "nl_command": "Execute COMMAND on all files and directories in the current directory tree", "bash_code": "find . -exec COMMAND {} +" }, { "nl_command": "Extract files from archive 'archive.tar'", "bash_code": "cat archive.tar | tar x" }, { "nl_command": "find all file name in curent directory , -exec will file all file output awk used here for print only file name .", "bash_code": "find . -type f -exec ls -lrt {} \\; |awk -F' ' '{print $9}'" }, { "nl_command": "Output the base name of first argument to script or function, that is the part following the last slash.", "bash_code": "echo $" }, { "nl_command": "Archive \"/media/10001/music/\" on host \"server\" to local directory \"/media/incoming/music/\" and skip files that are newer in the destination, delete any files in the destination not in the source, and compress data during transmission", "bash_code": "rsync -avzru --delete-excluded server:/media/10001/music/ /media/Incoming/music/" }, { "nl_command": "find all the files within your home folder accessed more than 100 days ago", "bash_code": "find ~ -atime 100" }, { "nl_command": "Find all directories that have been accessed $FTIME days ago under current directory tree", "bash_code": "find . -type d -atime $FTIME" }, { "nl_command": "Go into the directory whose name is selected in the X window system, ie. double-clicked in a terminal window.", "bash_code": "cd \"$\"" }, { "nl_command": "Find all .php files in the current directory tree", "bash_code": "find . -type f -name \"*.php\"" }, { "nl_command": "get all files in a current directory modified in the last 7 days", "bash_code": "find . -mtime -7 -print0 | xargs -0 tar -cjf /foo/archive.tar.bz2" }, { "nl_command": "Convert all characters in \"$a\" to lower case and save to variable \"b\"", "bash_code": "b=`echo \"$a\" | sed 's/./\\L&/g'`" }, { "nl_command": "find all regular files which have been modified in the last 48 hours in home folder", "bash_code": "find ~ -type f -mtime -2" }, { "nl_command": "search all html files in the current folder and remove all the empty lines", "bash_code": "find ./ -type f -name '*.html' | xargs sed -i '/^$/d" }, { "nl_command": "Find the largest 10 directories under current directory", "bash_code": "find . -type d -print0 | xargs -0 du | sort -n | tail -10 | cut -f2 | xargs -I{} du -sh {}" }, { "nl_command": "Get IP address of your SSH session", "bash_code": "who am i --ips|awk '{print $5}' #ubuntu 14" }, { "nl_command": "Display inputfile all on one line (replace newlines by spaces)", "bash_code": "awk '{printf \"%s \", $0}' inputfile" }, { "nl_command": "Enables shell option 'nocasematch'.", "bash_code": "shopt -s nocasematch" }, { "nl_command": "Remount \"/mnt/mountpoint\" as read only", "bash_code": "mount /mnt/mountpoint -oremount,ro" }, { "nl_command": "find all the \".JPG\" files in current folder and display their count", "bash_code": "find ./ -name '*.JPG' -type f | wc -l" }, { "nl_command": "Delete all files/directories in minimum 2 levels down the root directory", "bash_code": "find root -mindepth 2 -delete" }, { "nl_command": "Creates temporary file in TMPDIR folder or /tmp/ if TMPDIR is not defined, named by template ${tempname}.XXXXXX, and saves path to new file in a TMPPS_PREFIX variable.", "bash_code": "TMPPS_PREFIX=$(mktemp \"${TMPDIR:-/tmp/}${tempname}.XXXXXX\")" }, { "nl_command": "Display the 'bash' manpage, going to the first occurence of \\' sequence of characters.", "bash_code": "man bash | less -Ip \"\\\\\\'\"" }, { "nl_command": "Copies files 'src/prog.js' and 'images/icon.jpg' with fully-defined path to '/tmp/package' directory.", "bash_code": "cp --parents src/prog.js images/icon.jpg /tmp/package" }, { "nl_command": "Compare the contents of \"/bin\" and \"/usr/bin\" line by line", "bash_code": "diff <(ls /bin) <(ls /usr/bin)" }, { "nl_command": "From a script, output the name of the script itself, without containing directories - from a shell, output the name of the shell.", "bash_code": "basename -- $0" }, { "nl_command": "Remove all *.txt files, except robots.txt, under the given directory modified more than 5 minutes ago", "bash_code": "find /home/u20806/public_html -maxdepth 1 -mmin +5 -type f -name \"*.txt\" ! -name \"robots.txt\" -delete" }, { "nl_command": "Search the .VER files from the current directory tree for Perl regular expression \"Model-Manufacturer:.\\n.\"", "bash_code": "find . -name \"*.VER\" -exec grep -P 'Model-Manufacturer:.\\n.' '{}' ';' -print" }, { "nl_command": "Open all files named 'filename' with 'nano' editor in the entire filesystem", "bash_code": "find / -name filename -exec nano '{}' \\;" }, { "nl_command": "Create a named screen session", "bash_code": "screen -S main" }, { "nl_command": "List all files/folders in current directory by separating them with spaces", "bash_code": "ls | tr \"\\n\" \" \"" }, { "nl_command": "looks for all files larger than 10 megabytes (10485760 bytes) within /home", "bash_code": "find /home -type f -size +10485760c -print" }, { "nl_command": "Change owner to \"root\" and group to \"dockerroot\" of \"/var/run/docker.sock\"", "bash_code": "sudo chown root:dockerroot /var/run/docker.sock" }, { "nl_command": "List each file or directory in the current directory prefixed with its filesize in bytes and sorted from smallest to largest", "bash_code": "du -s * | sort -n" }, { "nl_command": "Create a symolic link in \"/usr/local/bin/\" to \"/Applications/Sublime\\ Text.app/Contents/SharedSupport/bin/subl\"", "bash_code": "ln -s /Applications/Sublime\\ Text.app/Contents/SharedSupport/bin/subl /usr/local/bin/" }, { "nl_command": "Remove all .mpg files in the /home/luser directory tree", "bash_code": "find /home/luser -type f -name '*.mpg' -print0 | xargs -0 rm -f" }, { "nl_command": "Write \"foo\" to the real path of the current command's standard output", "bash_code": "echo foo | readlink /proc/self/fd/0" }, { "nl_command": "Display hostname.", "bash_code": "uname -n" }, { "nl_command": "Search directory tree `MyApp.app' for directories whose name is 'Headers' and delete them in an optimized way", "bash_code": "find -d MyApp.app -name Headers -type d -print0 | xargs -0 rm -rf" }, { "nl_command": "Find all files under current directory that were modified in the last 24 hours and also include the files that were modified in less than 1 day ago", "bash_code": "find -mtime +0" }, { "nl_command": "Replace the occurrences of \"HOGE\" with \"MOGA\" once per each line of the files from the current directory tree", "bash_code": "find . -type f -print0 | xargs -0 sed -i -e \"s/HOGE/MOGA/\"" }, { "nl_command": "find all the header files in /usr/include which have been modified in the last 399 days and display the number of lines, number of files, number of characters of all these files", "bash_code": "find usr/include -name '*.h' -mtime -399 | wc" }, { "nl_command": "Resolve symbolic link of path of \"python2.7\"", "bash_code": "readlink $" }, { "nl_command": "Find all regular files under $DIR directory tree whose paths match the regex \".*\\.${TYPES_RE}\" where ${TYPES_RE} expands as a variable", "bash_code": "find ${DIR} -type f -regex \".*\\.${TYPES_RE}\"" }, { "nl_command": "find all the files in the folder \"/u/bill\" which have been accessed in the last 2-6 minutes", "bash_code": "find /u/bill -amin +2 -amin -6" }, { "nl_command": "Recursively finds all files and prints only names of files that contain \"word\" and suppressing error messages .", "bash_code": "find . | xargs grep 'word' -sl" }, { "nl_command": "Find all files/directories named 'my.txt' in the entire filesystem", "bash_code": "find / -name \"my.txt\"" }, { "nl_command": "create symbolic links in current directory to all files located in \"bar1\" directory that are not directory and do not have \".cc\" filename extension", "bash_code": "cd bar1 find . -maxdepth 1 -name '*foo*' -not -name '*.cc' -exec echo ln -s $PWD/{} ../bar2" }, { "nl_command": "find all the \".wma\" files in the folder \"$current_directory\"", "bash_code": "find \"${current_directory}\" -type f -iname \"*.wma\"" }, { "nl_command": "Prints last modified file in a current folder with modification time.", "bash_code": "find . -type f -printf '%TY-%Tm-%Td %TH:%TM: %Tz %p\\n'| sort -n | tail -n1" }, { "nl_command": "Forward port 3307 on localhost to port 3306 on 1.2.3.4 via 'user@gateway' on port 24222", "bash_code": "ssh -f user@gateway -p 24222 -L 3307:1.2.3.4:3306 -N" }, { "nl_command": "Count the number of regular files in the current directory tree", "bash_code": "find . -type f | wc -l" }, { "nl_command": "Find all PHP files under current directory", "bash_code": "find . -type f -name *.php" }, { "nl_command": "find all the zip files in the current folder", "bash_code": "find . -type f -name '*.zip'" }, { "nl_command": "find a specfic video file in the current directory", "bash_code": "find ./ -name \"foo.mp4\" -exec echo {} \\;" }, { "nl_command": "find in $HOME files ending in \"txt\" and do nothing with them, or files ending in \"html\" and list them null separated.", "bash_code": "find $HOME -name \\*txt -o -name \\*html -print0" }, { "nl_command": "Saves file sctipt.sh size in 'size' variable.", "bash_code": "size=`cat script.sh | wc -c`" }, { "nl_command": "Find all hidden files in the current directory", "bash_code": "find . -type f -name \".*\"" }, { "nl_command": "find in the entire file system for the files which have sticky bit.", "bash_code": "find / -perm 0551" }, { "nl_command": "Copy src_dir recursively to dest_dir, but without overwriting existing files.", "bash_code": "cp -nr src_dir dest_dir" }, { "nl_command": "count lines of C or C++ or Obj-C code under the current directory", "bash_code": "find . \\ -print0 | xargs -0 wc" }, { "nl_command": "display all the regular/normal files in current folder", "bash_code": "find . -type f -name \\*" }, { "nl_command": "find files which full path name is /tmp/foo/bar under /tmp/foo directory and print", "bash_code": "find /tmp/foo -path /tmp/foo/bar -print" }, { "nl_command": "List all files named \"filename\" from the current directory tree, ignoring directory \"FOLDER1\"", "bash_code": "find . -name FOLDER1 -prune -o -name filename -print" }, { "nl_command": "find all the text files in the folder /home/calvin which are atleast below 2 levels", "bash_code": "find /home/calvin/ -mindepth 2 -name \u201c*.txt\u201d" }, { "nl_command": "Remove all a.out, *.o, and core files under the current directory", "bash_code": "find . \\ -exec rm {} \\;" }, { "nl_command": "Print all lines of \"seq 1 10\" except the last 3", "bash_code": "seq 1 10 | perl -ne 'push @l, $_; print shift @l if @l > 3'" }, { "nl_command": "Create 6-letter named temporary file in a folder path $file1, and save the path to it in a variable 'tmpfile'", "bash_code": "tmpfile=$(mktemp $(dirname \"$file1\")/XXXXXX)" }, { "nl_command": "Find all *.srt files under directory named 'working' and show the first one found", "bash_code": "find working -type f -name \"*.srt\" | head -1" }, { "nl_command": "recursively change owner and group of the directory and all files into it to user root and group root", "bash_code": "chown -R root:root /var/lib/jenkins" }, { "nl_command": "Replace \"firstWord\" with \"newFirstWord\", \"secondWord\" with \"newSecondWord\", \"thirdWord\" with \"newThirdWord\" in all XML files in the current directory tree", "bash_code": "find -name \"*.xml\" -exec sed -s --in-place=.bak -e 's/firstWord/newFirstWord/g;s/secondWord/newSecondWord/g;s/thirdWord/newThirdWord/g' {} \\;" }, { "nl_command": "Find all files named 'foo' under your home directory and list them with confirmation prompt", "bash_code": "find ~ -type f -name 'foo*' -ok ls -l '{}' ';'" }, { "nl_command": "find all directories in the current directory", "bash_code": "find . -type d" }, { "nl_command": "Find files in the current directory tree whose names are of the form \"cxx_data.txt\" where xx is a number from 40 to 70", "bash_code": "find . -regextype posix-egrep -regex \"./c(([4-6][0-9])|70)_data.txt\"" }, { "nl_command": "find all the files in the current directory which start with t and have been modified between one hour (60 minutes) and 12 hours (720 minutes) ago.", "bash_code": "find . -mmin -720 -mmin +60 -type f -name \"t*\" -exec ls -l '{}' \\;" }, { "nl_command": "Save the day of the year from the time string \"20131220\" to variable 'DATECOMING'", "bash_code": "DATECOMING=$" }, { "nl_command": "Make DNS lookup for hostname stackoverflow.com", "bash_code": "dig stackoverflow.com" }, { "nl_command": "Read a line from standard input into variable \"REPLY\" with prompt \"$*\"", "bash_code": "read -p \"$*\"" }, { "nl_command": "Save the system host name in variable \"HOSTNAME\"", "bash_code": "HOSTNAME=$" }, { "nl_command": "List every symbolic link in every home directory's subdirectory owned by group `staff'", "bash_code": "find `pwd` -group staff -exec find {} -type l -print ;" }, { "nl_command": "Shifts the positional parameters to the left by n.", "bash_code": "shift [n]" }, { "nl_command": "List all regular files matching the name pattern \"$1*\" (where $1 is a positional parameter) under '/usr', '/bin', '/sbin' and '/opt' directory tree", "bash_code": "find /usr /bin /sbin /opt -name \"$1*\" -type f -ls" }, { "nl_command": "Append \"& Bytes\" to the end of every line in \"$TEMPFILE\" and format the result as a table", "bash_code": "sed 's/.*/& Bytes/' \"$TEMPFILE\" | column -t" }, { "nl_command": "Count the number of times that a single \"-----------\\n\" separated record contains both \"A=2\" and \"dummy=2\" and the number of records that do not have \"dummy=2\" in compressed file \"file.gz\"", "bash_code": "zcat file.gz | awk -v RS=\"-----------\\n\" '/A=2[ ,\\n]/ && /dummy=2[ ,\\n]/{count++} !/dummy=2[ ,\\n]/{other++} END{print \"Final counter value=\",count, \"; other=\", other}'" }, { "nl_command": "Count the number of files named 'job.history' under '/data/SpoolIn' directory tree that match 'FAIL' in their contents", "bash_code": "find /data/SpoolIn -name job.history | xargs grep -l FAIL | wc -l" }, { "nl_command": "login as user postgres", "bash_code": "sudo su -l oracle" }, { "nl_command": "display all files in current folder which are bigger than 100KB but are less than 500KB", "bash_code": "find . -size +100k -a -size -500k" }, { "nl_command": "Find all directories under /home/username/public_html/sites/all/themes and set their permission to 750", "bash_code": "find /home/username/public_html/sites/all/themes -type d -exec chmod 750 {} +" }, { "nl_command": "search for all regular files in the current directory which have the extension \"c\" or \"asm\"", "bash_code": "find . -type f \\( -iname \"*.c\" -or -iname \"*.asm\" \\)" }, { "nl_command": "Count files accessed more than a month ago", "bash_code": "find . -atime +30 -exec ls \\; | wc -l" }, { "nl_command": "Search the system for regular files whose names are \"filename\" ignoring the case", "bash_code": "find / -type f -iname \"filename\"" }, { "nl_command": "find all the files in the home folder which are bigger than 2MB and zip them", "bash_code": "find ~ -size +2000000c -regex '.*[^gz]' -exec gzip '{}' ';'" }, { "nl_command": "Print 'bla.txt' if at least one file with such name is present below the current directory.", "bash_code": "ls -alFt `find . -name \"bla.txt\"` | rev | cut -d\" \" -f1 | rev | head -1" }, { "nl_command": "Find files under /etc/apache-perl that are modified more recently than /etc/apache-perl/httpd.conf", "bash_code": "find /etc/apache-perl -newer /etc/apache-perl/httpd.conf" }, { "nl_command": "find all files in the folder \"myfiles\" which are exactly 5 bytes", "bash_code": "find /myfiles -size 5" }, { "nl_command": "forcibly and verbosely create symbolic links in directory \"~/Library/LaunchAgents\" to all files located in /usr/local/opt/mongodb/ and that have filename extension \".plist\"", "bash_code": "ln -sfv /usr/local/opt/mongodb/*.plist ~/Library/LaunchAgents" }, { "nl_command": "Print the first 10 files or directories found in the current directory tree by `find'", "bash_code": "find | head" }, { "nl_command": "Append all *.mp3 files modified within the last 180 days to tar archive `music.tar'", "bash_code": "find . -name -type f '*.mp3' -mtime -180 -print0 | xargs -0 tar rvf music.tar" }, { "nl_command": "Find all directories recursively starting from / and skipping the contents of /proc/, and count them", "bash_code": "find / -path /proc -prune -o -type d | wc -l" }, { "nl_command": "Find and list all regular files", "bash_code": "find . -type f -ls" }, { "nl_command": "Print the average time of 4 ping requests to \"www.stackoverflow.com\"", "bash_code": "ping -c 4 www.stackoverflow.com | tail -1| awk '{print $4}' | cut -d '/' -f 2" }, { "nl_command": "display all the files in the file system which are present in nfs system", "bash_code": "find / -fstype nfs -print" }, { "nl_command": "Search the current directory tree for file `teste.tex'", "bash_code": "find -name teste.tex" }, { "nl_command": "display all the regular files in the current folder that are less than 10KB", "bash_code": "find . -type f -size -10k" }, { "nl_command": "Search the current directory recursively for the largest files", "bash_code": "find . -type f -printf '%20s %p\\n' | sort -n | cut -b22- | tr '\\n' '\\000' | xargs -0 ls -laSr" }, { "nl_command": "Print a 2 byte hexadecimal value, printable character, and octal value of \"$1\"", "bash_code": "echo \"$1\" | od -xcb" }, { "nl_command": "Find all files under /path and below writable by `group' and `other'", "bash_code": "find /path -perm -g+w,o+w" }, { "nl_command": "Find all files matching shell pattern \"foo/bar\" in the foo directory tree", "bash_code": "find foo -path foo/bar -print" }, { "nl_command": "Remove all regular files from the current directory tree whose names do not end with \"ignore1\" or \"ignore2\"", "bash_code": "find . -type f -not -name '*ignore1' -o -not -name '*ignore2' | xargs rm" }, { "nl_command": "Print every two lines in \"file\" on a single line separated by a space", "bash_code": "cat file | paste -d' ' - -" }, { "nl_command": "Find all files named \"test2\" in the current directory tree", "bash_code": "find -name test2" }, { "nl_command": "Make directory \"aaa\"", "bash_code": "mkdir aaa" }, { "nl_command": "Find files in the current directory and its sub-directories that begin with 'f'.", "bash_code": "find . -name f* -print" }, { "nl_command": "Change permissions of all directories in the ~/dir_data directory tree in accordance with mode `a+xr,u+w'", "bash_code": "find ~/dir_data -type d -exec chmod a+xr,u+w {} \\;" }, { "nl_command": "Remount \"/dev/block/mtdblock3\" on \"/system\" with read only permission", "bash_code": "mount -o remount,ro -t yaffs2 /dev/block/mtdblock3 /system" }, { "nl_command": "Count the total number of lines in all \"*.gz\" files in the current directory tree after decompression", "bash_code": "find . -type f -name '*.gz' | xargs zcat | wc -l" }, { "nl_command": "Make directory \"/data/db\"", "bash_code": "sudo mkdir /data/db" }, { "nl_command": "display all regular/normal files in the folder \"dir\" and display the filename along with file size", "bash_code": "find dir -type f -printf \"f %s %p\\n\"" }, { "nl_command": "Recursively print all files and directories in the current directory tree", "bash_code": "tree ." }, { "nl_command": "Search for files/directories which have read and write permission for their owner, and group and only read permission for others", "bash_code": "find . -perm 664" }, { "nl_command": "Search for files/directories with the case insensitive pattern anaconda.* in var/log directory", "bash_code": "find var/log/ -iname anaconda.*" }, { "nl_command": "Find all image.pdf files/directories under ./polkadots with null character as the delimiter", "bash_code": "find ./polkadots -name \"image.pdf\" -print0" }, { "nl_command": "Unzip and extract \"*\\(userAgent=[^=]*\\) [^ =][^ =]*=.*\" from \"input.gz\"", "bash_code": "zcat input.gz | sed -n 's/.*\\(userAgent=[^=]*\\) [^ =][^ =]*=.*/\\1/p'" }, { "nl_command": "display all the hidden files in the folder /home", "bash_code": "find /home -name \".*\"" }, { "nl_command": "Find all regular files in the current directory tree last modified between 1 and 3 days ago and list them using format '%Tc %p\\n'", "bash_code": "find ./ -daystart -mtime -3 -type f ! -mtime -1 -printf '%Tc %p\\n'" }, { "nl_command": "Append \"& Bytes\" to the end of every line in \"$TEMPFILE\" and format the result as a table", "bash_code": "sed 's/.*/& Bytes/' \"$TEMPFILE\" | column -t" }, { "nl_command": "Search the current directory recursively for files with the exact permissions u=rwx,g=rx,o=rx", "bash_code": "find . -perm u=rwx,g=rx,o=rx" }, { "nl_command": "Print mount point of the file system containing $path.", "bash_code": "df \"$path\" | tail -1 | awk '{ print $6 }'" }, { "nl_command": "Backup a directory with a zenity progress bar", "bash_code": "screen -L bash -c '; 7z a \"output.zip\" \"/path/to/input\"'" }, { "nl_command": "Remove \"\\r\" at the end of each line in \"infile\" and display the result as printable characters or backslash escapes", "bash_code": "cat infile | sed 's/\\r$//' | od -c" }, { "nl_command": "Print all files/directories with their sizes under $WHATEVER directory tree", "bash_code": "find $WHATEVER -printf \"%s %p\\n\"" }, { "nl_command": "Find all files in the `sourceDir' directory tree", "bash_code": "find sourceDir -mindepth 1" }, { "nl_command": "List all *.jar files/directories under /usr, /home and /tmp directory", "bash_code": "find /usr /home /tmp -name \"*.jar\"" }, { "nl_command": "Prints day of first Tuesday in a month.", "bash_code": "cal | awk 'NR>2 && NF>4 {printf \"%02d\\n\",$(NF-4);exit}'" }, { "nl_command": "Allocate a pseudo-terminal and execute \"screen -r\" on host \"example.com\"", "bash_code": "ssh -t example.com \"screen -r\"" }, { "nl_command": "Find all *fink* files/directories under current directory", "bash_code": "find . -name \"*fink*\" -print" }, { "nl_command": "Execute \"ls -l\" every 2 seconds and highlight the differences in runs", "bash_code": "watch -d ls -l" }, { "nl_command": "copy all the log files in the current folder which have not been accessed in the last 30*24 hours to the folder old", "bash_code": "find . -type f -mtime +30 -name \"*.log\" -exec cp {} old \\;" }, { "nl_command": "Search the first 300 commands in history containing \"scp\" and ending in \"important\"", "bash_code": "history 300 | grep scp | grep important$" }, { "nl_command": "Search the current directory up to depth level 2 for files and directories", "bash_code": "find . -maxdepth 2" }, { "nl_command": "Print lines unique and common to sorted files \"file1\" and \"file2\"", "bash_code": "comm file1 file2" }, { "nl_command": "Find all files under /path/to/file which are greater than 25600KB", "bash_code": "find /path/to/file -type f -size +51200c 2>/dev/null" }, { "nl_command": "Delete all hidden files under $some_directory", "bash_code": "find \"$some_directory\" -type f -name '.*' | xargs rm" }, { "nl_command": "Find all directories under current directory having DIRNAME in their name", "bash_code": "find . -type d | grep DIRNAME" }, { "nl_command": "Find files/directories that does not have write permssion for group or others", "bash_code": "find /path ! -perm -022" }, { "nl_command": "Find all the files called FindCommandExamples.txt of owner root", "bash_code": "find / -user root -name FindCommandExamples.txt" }, { "nl_command": "Assign permissions 644 to files in the current directory tree", "bash_code": "find . -type f -print0 | xargs -0 chmod 644" }, { "nl_command": "Find List of directories with non-zero sub-folder count:", "bash_code": "find -maxdepth 1 -type d | sort | while read -r dir; do n=$; let n--; if [ $n -gt 0 ]; then printf \"%4d : %s\\n\" $n \"$dir\"; fi; done" }, { "nl_command": "Display differences in \"/tmp/ksh-9725.log\" when compared to \"/tmp/ksh-9781.log\"", "bash_code": "diff /tmp/ksh-{9725,9781}.log | grep ^\\<" }, { "nl_command": "List all files in the current directory tree invoking xargs only once", "bash_code": "find . -type f -print | xargs ls -l" }, { "nl_command": "find files in the current directory with pattern` '*.[ch]' which are contain \u2018thing\u2019 string and print file names which can contain spaces", "bash_code": "find . -name '*.[ch]' -print0 | xargs -r -0 grep -l thing" }, { "nl_command": "Split \"input_file\" into files of at most 100 lines each with prefix \"output_file\"", "bash_code": "split -l 100 input_file output_file" }, { "nl_command": "Assigns MAC address 00:80:48:BA:d1:30 to interface eth0.", "bash_code": "ifconfig eth0 hw ether 00:80:48:BA:d1:30" }, { "nl_command": "Change directory to \"$dir1\" and resolve any symlinks in the resulting path", "bash_code": "cd -P \"$dir1\"" }, { "nl_command": "find all files under the /etc directory and display any IP address patterns in them", "bash_code": "find /etc -exec grep '[0-9][0-9]*[.][0-9][0-9]*[.][0-9][0-9]*[.][0-9][0-9]*' {} \\;" }, { "nl_command": "display a long listing of all the directories in the entire file system", "bash_code": "find / -print0 -type d | xargs -0 ls -al" }, { "nl_command": "Read a line from standard input into variable \"response\" ignoring backslash escapes and using the prompt \"Are you sure? [y/N] \"", "bash_code": "read -r -p \"Are you sure? [y/N] \" response" }, { "nl_command": "Prints top-ten list of most used utilities from history.", "bash_code": "history | awk '{ print $2 }' | sort | uniq -c |sort -rn | head" }, { "nl_command": "search for all the regular/normal mp3 files in the file system and sync them to the folder /mnt/mp3", "bash_code": "find / -iname \"*.mp3\" -type f -print0 | xargs -0 -I '{}' /usr/bin/rsync -avR \"{}\" /mnt/mp3/" }, { "nl_command": "Find all files/directories named 'Desktop' under current directory", "bash_code": "find ./ -name Desktop" }, { "nl_command": "Recursively changes group ownership of everything within a current folder to 'admin'.", "bash_code": "chgrp -R admin *" }, { "nl_command": "Show all lines in file2 that don't contain the first field of any line in file1.", "bash_code": "awk '{print $1}' file2 | comm -1 -3 file1 - | join file2 -" }, { "nl_command": "keep only read access to all the files in a directory.", "bash_code": "find /path/to/dir/ -type f ! -perm 0644 -print0 | xargs -0 chmod 644" }, { "nl_command": "delete all the log files in the current folder", "bash_code": "find ./ -name '*.log' -print0 | xargs -0 rm" }, { "nl_command": "Set permissions to 644 for all regular files under the current directory tree that have permissions 755", "bash_code": "find . -type f -perm 755 -exec chmod 644 {} \\;" }, { "nl_command": "Change every reference to the colour red to green in all CSS files", "bash_code": "find . -name \"*.css\" -exec sed -i -r 's/#(FF0000|F00)\\b/#0F0/' {} \\;" }, { "nl_command": "Search the files in the current directory tree for lines containing string \"vds admin\"", "bash_code": "find . -exec grep -i \"vds admin\" {} \\;" }, { "nl_command": "set alias \"unix\" for command 'echo $'", "bash_code": "alias unix='echo $'" }, { "nl_command": "create directory practice into home directory", "bash_code": "mkdir ~/practice" }, { "nl_command": "Search *.txt files under and below /directory/containing/files for \"pattern_to_search\"", "bash_code": "find /directory/containing/files -type f -name \"*.txt\" -exec grep -H 'pattern_to_search' {} +" }, { "nl_command": "Connect via ssh to \"your.server.example.com\" and recursively copy directory \"/path/to/foo\" on this host to direcotry \"/home/user/Desktop\" on local host, using \"blowfish\" cipher algorithm.", "bash_code": "scp -c blowfish -r user@your.server.example.com:/path/to/foo /home/user/Desktop/" }, { "nl_command": "Print a sorted list of the extensions of the regular files from the current directory tree with counts per extension", "bash_code": "find . -type f | sed -e 's/.*\\.//' | sed -e 's/.*\\///' | sort | uniq -c | sort -rn" }, { "nl_command": "Find all files/directories that belong to the group 'staff' under '/usr' directory tree", "bash_code": "find /usr -group staff" }, { "nl_command": "simulate a full login of user builder", "bash_code": "su -l builder" }, { "nl_command": "Find all regular files under $dir directory tree that are bigger than $size MB in size and print them along with their sizes in decreasing order of size", "bash_code": "find $dir -type f -size +\"$size\"M -printf '%s %p\\n' | sort -rn" }, { "nl_command": "Save absolute path of the script filename in variable \"MY_PATH\"", "bash_code": "MY_PATH=$" }, { "nl_command": "display the count of total number of text files in the folder /home/you which have been modified in the last 60*24 hours", "bash_code": "find /home/you -iname \"*.txt\" -mtime -60 | wc -l" }, { "nl_command": "find all the files in the current folder which have been modified for the ffiles that are at least one week old but less then 30 days old", "bash_code": "find . -mtime +30 -a -mtime -7 -print0" }, { "nl_command": "Removes all empty folders under current path, aged between 'first' and 'last' timestamps.", "bash_code": "find . -newer first -not -newer last -type d -print0 | xargs -0 rmdir" }, { "nl_command": "search in the current folder for the files that begin with \"myletter\"", "bash_code": "find . -name 'myletter*' -print" }, { "nl_command": "Create intermediate directories ~/foo/bar/ as required and directories baz, bif, bang", "bash_code": "mkdir -p ~/foo/bar/baz ~/foo/bar/bif ~/foo/boo/bang" }, { "nl_command": "Read lookup requests from text file '1.txt' and uses them to fetch TXT records.", "bash_code": "dig TXT -f 1.txt" }, { "nl_command": "Search the file hierarchy for files larger than 100000 KB without searching any mounted removable media", "bash_code": "find / -path /media -prune -o -size +200000 -print" }, { "nl_command": "Prints listing of a root folder including hidden files, and saves output to 'output.file'.", "bash_code": "ls -a | tee output.file" }, { "nl_command": "Interpret conf-file in the current shell, making all environment variables in this file available to future sub-processes.", "bash_code": "set -o allexport; source conf-file; set +o allexport" }, { "nl_command": "Find files under /some/path that are not executable", "bash_code": "find /some/path -type f ! -perm -111 -ls" }, { "nl_command": "Print the list of directories that are present in the /mnt/raid directory tree", "bash_code": "find /mnt/raid -type d" }, { "nl_command": "Look for *log files in directories at least three levels down the directory tree", "bash_code": "find / -mindepth 3 -name \"*log\"" }, { "nl_command": "Change the owner to \"root\" and group to \"specialusers\" of \"dir1\"", "bash_code": "chown root:specialusers dir1" }, { "nl_command": "Add executable permission to \"java_ee_sdk-6u2-jdk-linux-x64.sh\"", "bash_code": "sudo chmod +x java_ee_sdk-6u2-jdk-linux-x64.sh" }, { "nl_command": "Pick up a list of variable:value pairs from msgs.config and add them to the current shell or script's environment.", "bash_code": "source <( sed 's/:\\/=\"\\1\"/' msgs.config )" }, { "nl_command": "Find all directories on the system whose size is greater than 50k", "bash_code": "find / -type d -size +50k" }, { "nl_command": "Find all regular files starting from level 3 of directory tree ~/container and move them to the current directory", "bash_code": "find ~/container -mindepth 3 -type f -exec mv {} . \\;" }, { "nl_command": "Will run checksums recursively from the current directory, and give back grouped filenames of all identical checksum results.", "bash_code": "find ./ -type f -print0 | xargs -0 -n1 md5sum | sort -k 1,32 | uniq -w 32 -d --all-repeated=separate | sed -e 's/^[0-9a-f]*\\ *//;'" }, { "nl_command": "Make \"file.sh\" executable", "bash_code": "chmod +x file.sh" }, { "nl_command": "Open all .java files in the current directory tree in the vim editor", "bash_code": "find . -name '*.java' | xargs vim" }, { "nl_command": "Read a line of standard input into variable \"_command\" with the prompt as the current working directory followed by \"$\"", "bash_code": "read -p \"`pwd -P`\\$ \" _command" }, { "nl_command": "Find all 'test' directories in the current directory tree and remove them", "bash_code": "find -type d -a -name test|xargs rm -r" }, { "nl_command": "Gets IP address of 'eth0' network interface.", "bash_code": "ifconfig eth0 | awk '/inet addr/{sub; print $2}'" }, { "nl_command": "find all empty files in home directory", "bash_code": "find ~ -empty" }, { "nl_command": "Find all files under ${searchpath} that match the regex ${string1}.*${string2}.*${string3} in their contents where ${string1} etc.. will be expanded", "bash_code": "find \"${searchpath}\" -type f -print0 | xargs -0 grep -l -E \"${string1}\".*\"${string2}\".*\"${string3}\"" }, { "nl_command": "display all the text files in current folder", "bash_code": "find . -name \"*.txt\"" }, { "nl_command": "force remove all the text files that have not been modified in the last 89 days", "bash_code": "find . -name \"*.txt\" -type f -daystart -mtime +89 | xargs rm -f" }, { "nl_command": "List all files/directories under current directory matching the posix-egrep type regex \".+\\.$\" in their names", "bash_code": "find . -regextype posix-egrep -regex \".+\\.$\" | xargs -n 1 ls" }, { "nl_command": "Find *.html files in the current directory tree that were last modified more than 7 days ago", "bash_code": "find . -mtime +7 -name \"*.html\" -print" }, { "nl_command": "Find all *.cgi files/directories under current directory and change their permission to 755", "bash_code": "find . -name '*.cgi' -print0 | xargs -0 chmod 755" }, { "nl_command": "Create a ssh key and store it in the file ~/.ssh/apache-rsync", "bash_code": "ssh-keygen -f ~/.ssh/apache-rsync" }, { "nl_command": "display all the home folder which end with the extension \"sxw\" and which have been accessed in the last 3*24 hours and which belong to the user bruno", "bash_code": "find /home -type f -name \"*.sxw\" -atime -3 -user bruno" }, { "nl_command": "find all the non compressed files in the current directory and compress them.", "bash_code": "find . \\! -name \"*.Z\" -exec compress -f {} \\;" }, { "nl_command": "find all files in the current folder which have not been modified today and whose file name is of length 1", "bash_code": "find . -name \\? -mtime +0" }, { "nl_command": "find all files in the file system which have been accessed in the last 24 hours", "bash_code": "find / -atime 0" }, { "nl_command": "Search for files/directories which are writable by either their owner or their group", "bash_code": "find . -perm /220" }, { "nl_command": "prints the last non-empty line of a file", "bash_code": "tac $FILE | grep -m 1 '.'" }, { "nl_command": "display all the files in the current folder that are at least one week old but less then 30 days old", "bash_code": "find . -mtime +30 -a -mtime -7 -print0" }, { "nl_command": "List environment variables and their values whose name matches '^\\w*X\\w*'", "bash_code": "set | grep -P '^\\w*X\\w*(?==)'" }, { "nl_command": "Print the lines of file \"strings\" not specified in file \"index\"", "bash_code": "join -v 2 index <" }, { "nl_command": "Saves invoked command 'check_script_call=$' in variable 'check_script_call', preceeding by its number in history.", "bash_code": "check_script_call=$" }, { "nl_command": "Locate world-writable files and directories on the system", "bash_code": "find / -path /proc -prune -o -perm -2 ! -type l -ls" }, { "nl_command": "Prints name of a current shell binary file.", "bash_code": "ls -l /proc/$$/exe | sed 's%.*/%%'" }, { "nl_command": "Make directory \"mybuild\"", "bash_code": "mkdir mybuild" }, { "nl_command": "Change directory to \"$dir1\" and resolve any symlinks in the resulting path", "bash_code": "cd -P \"$dir1\"" }, { "nl_command": "create symbolic links in directory \"/usr/local/symlinks \" to all files located in directiry \"incoming\" and that have been modified earlier then 5 days and owned by user \"nr\"", "bash_code": "find /incoming -mtime -5 -user nr -exec ln -s '{}' /usr/local/symlinks ';'" }, { "nl_command": "Find all files/directories named Root under current directory and copy them to newRoot", "bash_code": "find . -name Root | xargs cp newRoot" }, { "nl_command": "Find all directories in maximum 1 level down the current directory that were modified less than 1 day ago", "bash_code": "find -maxdepth 1 -type d -mtime -1" }, { "nl_command": "search for the folder .dummy and remove it from the folder \"Test folder\"", "bash_code": "find \"Test Folder\" -type d -name '.dummy' -delete" }, { "nl_command": "Sort strings in a file temp.txt.", "bash_code": "sort temp.txt > temp.txt.sort && mv temp.txt.sort temp.txt" }, { "nl_command": "Recursively removes all files and folders named '.svn' in a current folder.", "bash_code": "find . -name .svn | xargs rm -fr" }, { "nl_command": "Find all files under /path and below writable by `group' and `other'", "bash_code": "find /path -perm -022" }, { "nl_command": "Return a list of files newer than file poop", "bash_code": "find . -mnewer poop" }, { "nl_command": "Find all files under current directory that were modified in the last 24 hours", "bash_code": "find -mtime 0" }, { "nl_command": "Recursively finds all *.txt files and prints strings with \"text_pattern\" ignoring text distincts.", "bash_code": "find . -name \"*.txt\" | xargs grep -i \"text_pattern\"" }, { "nl_command": "Creates temporary file and saves path to it in a 'tmpfile' variable.", "bash_code": "tmpfile=$" }, { "nl_command": "Find files modified in last 7 days", "bash_code": "find . -mtime -7 -type f" }, { "nl_command": "Change permissions of all regular files from the current directory tree to 644", "bash_code": "find . -type f -exec chmod 644 {} +" }, { "nl_command": "display all the files in the /usr folder which have the permissions 777", "bash_code": "find /usr -perm 0777 -print" }, { "nl_command": "Set a title of a remote screen session", "bash_code": "screen -S SessionName -p 0 -X title \"remote_0\"" }, { "nl_command": "Change owner to \"root\" and group to \"wheel\" of \"adbind.bash\"", "bash_code": "sudo chown root:wheel adbind.bash" }, { "nl_command": "Set permissions to 700 for directories under var/", "bash_code": "find var/ -type d -exec chmod 700 {} \\;" }, { "nl_command": "find all the files which end with \".deb\" and display their base name (strip the extension)", "bash_code": "find . -name '*.deb' | xargs -n1 basename" }, { "nl_command": "Read line from file descriptor 4 and store received input in 'line' variable", "bash_code": "read -u 4 line" }, { "nl_command": "Print onlt last slash-separated field from $PATH value", "bash_code": "echo \"$PATH\" | rev | cut -d\"/\" -f1 | rev" }, { "nl_command": "run somebashstatement with the filename as argument, for files recursively in /path that match 'pattern'", "bash_code": "find /path -name 'pattern' -exec bash -c 'somebashstatement \"$1\"' -- {} \\;" }, { "nl_command": "replace the word foo to bar in all the regular/normal files in the current folder", "bash_code": "find . -type f -exec sed -i 's/foo/bar/g' {} +" }, { "nl_command": "Silently read a single character from standard input into variable \"key\" without backslash escapes and using the prompt $'Press any key to continue...\\n'", "bash_code": "read -rsp $'Press any key to continue...\\n' -n 1 key" }, { "nl_command": "Prints long listing of directories '/tmp', '/tnt' themselves bordered with '<--' and '--->'.", "bash_code": "ls -ld /tmp /tnt | sed 's/^.*$/<-- & --->/'" }, { "nl_command": "Find and compress all .pl files in the current directory tree", "bash_code": "find . -name \"*.pl\" | xargs tar -zcf pl.tar.gz" }, { "nl_command": "Create new crontab set for user 'test' including $job and only jobs from current crontab of 'test' user that don`t contain $command", "bash_code": "cat <(fgrep -i -v \"$command\" <(crontab -u test -l)) <(echo \"$job\") | crontab -u test -" }, { "nl_command": "Merge files 'text.txt' and 'codes.txt' by outputting any lines whose second field in the first matches the first field in the second.", "bash_code": "join -1 2 -2 1 text.txt codes.txt" }, { "nl_command": "Display the 5 largest files in the current directory and its sub-directories.", "bash_code": "find . -type f -exec ls -s {} \\; | sort -n -r | head -5" }, { "nl_command": "Find all .c and .h files in the current directory tree and search them for \"expr\"", "bash_code": "find -name '*.[ch]' | xargs grep -E 'expr'" }, { "nl_command": "search for text files in the current folder which do not have write access to others", "bash_code": "find . -type f \\( -iname \"*.txt\" ! -perm -o=w \\)" }, { "nl_command": "search for files in the current folder ending with \".au\"", "bash_code": "find -type f -name '*.au'" }, { "nl_command": "Creates alias for network interface 'eth0' with IP address '192.0.2.55' and network mask '255.255.255.255'.", "bash_code": "ifconfig eth0:fakenfs 192.0.2.55 netmask 255.255.255.255" }, { "nl_command": "Print new line separated numbers from \"001\" to \"100\"", "bash_code": "yes | nl -ba | tr ' ' 0 | sed 100q | cut -b 4-6" }, { "nl_command": "Count files in the current path by modification month", "bash_code": "find . -maxdepth 1 -type f -printf '%TY-%Tm\\n' | sort | uniq -c" }, { "nl_command": "Unzip \"path/to/test/file.gz\" to standard output and save all lines matching \"my regex\" to files with a 1000000 limit", "bash_code": "gzip -cd path/to/test/file.gz | awk 'BEGIN{global=1}/my regex/{count+=1;print $0 >\"part\"global\".txt\";if {count=0;global+=1}}'" }, { "nl_command": "Find all 400 permission files under /data directory and change their permission to 755", "bash_code": "find /data -type f -perm 400 -print | xargs chmod 755" }, { "nl_command": "Execute \"du -s path\" every 300 seconds", "bash_code": "watch -n 300 du -s path" }, { "nl_command": "Perform case insensitive search for *.gif files/directories under downloads directory", "bash_code": "find downloads -iname \"*.gif\"" }, { "nl_command": "Find all files under ./lib/app and redirect their sorted list to myFile", "bash_code": "find ./lib/app -type f | sort | tee myFile" }, { "nl_command": "Assign permissions 755 to directories in the current directory tree", "bash_code": "find . -type d -print0 | xargs -0 chmod 755" }, { "nl_command": "Compresses all files in a current folder .", "bash_code": "bzip2 *" }, { "nl_command": "Search for the files/directories that were modified more than an hour ago", "bash_code": "find . -mtime +1" }, { "nl_command": "remove all the files in the present directory which have special characters in their name and do not search in the sub directories of the current folder.", "bash_code": "find . -name '*[+{;\"\\\\=?~()<>&*|$ ]*' -maxdepth 0 -exec rm -f '{}' \\;" }, { "nl_command": "Sets shell option 'globstar'.", "bash_code": "shopt -s globstar" }, { "nl_command": "find all \".flac\" files in current folder starting with \"cmn-\"", "bash_code": "find . -name 'cmn-*.flac'" }, { "nl_command": "Create tar.gz files older than one day logs", "bash_code": "find /home/testuser/log/ -mtime +1 | xargs tar -czvPf /opt/older_log_$.tar.gz" }, { "nl_command": "Suffix all files and folders in the current directory with \"_SUF\"", "bash_code": "ls | xargs -I {} mv {} {}_SUF" }, { "nl_command": "delete all the log files which have not been modified in the last 5 days after user confirmation", "bash_code": "find . \u2014 name \"*.LOG\" \u2014 mtime +5 -ok rm {} \\;" }, { "nl_command": "Find *2011* files and grep for the string 'From: Ralph' in those files", "bash_code": "find . -name '*2011*' -print | xargs -n2 grep 'From: Ralph'" }, { "nl_command": "Set variable \"architecture\" to machine architecture, ie. x86_64", "bash_code": "architecture=\"$\"" }, { "nl_command": "display all files in the current folder which end with extension \"myfile\" followed by one digit or two digits", "bash_code": "find . -regextype sed -regex '.*myfile[0-9]\\{1,2\\}'" }, { "nl_command": "Find all files/directories not with the name 'query_to_avoid' under current directory", "bash_code": "find -not -name \"query_to_avoid\"" }, { "nl_command": "run bash shell as user root", "bash_code": "su -c 'bash --rcfile myfile'" }, { "nl_command": "Find all broken symlinks in maximum 1 level down the $path directory", "bash_code": "find -L $path -maxdepth 1 -type l" }, { "nl_command": "Print percents of the space used on the file system containing path to the current working directory.", "bash_code": "df . -B MB | tail -1 | awk {'print substr($5, 1, length-1)'}" }, { "nl_command": "Find file1 in the level 1 directories and above", "bash_code": "find -maxdepth 2 -name file1" }, { "nl_command": "Move all 10*jpg files under /path to 2010*jpg files under the same directory", "bash_code": "find /path -type f -name \"10*jpg\" | sed 's/.*/mv &/' | sed 's/mv \\(.*\\/\\)\\(.[^/]*\\)/& \\120\\2/' | sh" }, { "nl_command": "change the permissions of al the directories in the current folder", "bash_code": "sudo find . -type d -exec chmod 755 {} +" }, { "nl_command": "Read a line from standard input and save received words sequentially in variables XPID XUSERID XPRIORITY XVIRTUAL XRESIDENT XSHARED XSTATE XCPU XMEM XTIME XCOMMAND", "bash_code": "read XPID XUSERID XPRIORITY XVIRTUAL XRESIDENT XSHARED XSTATE XCPU XMEM XTIME XCOMMAND" }, { "nl_command": "Get the total size of all files under dir1 directory", "bash_code": "find dir1 ! -type d |xargs wc -c |tail -1" }, { "nl_command": "Split \"/usr/bin/gcc\" into 100000 files of about equal size", "bash_code": "split -n 100000 /usr/bin/gcc" }, { "nl_command": "Recursively copy directory or file /something on host \"myServer\" to current directory on local host, connecting as ssh user matching username on local host.", "bash_code": "scp -r myServer:/something" }, { "nl_command": "Remount \"/mnt/mountpoint\" with read and write permission", "bash_code": "mount /mnt/mountpoint -oremount,rw" }, { "nl_command": "List \".java\" files that have the same filename and contents", "bash_code": "md5sum *.java | sort | uniq -d" }, { "nl_command": "find all files in current folder having the name pattern \"some_pattern\" and move them to target_location", "bash_code": "find . -name some_pattern -print0 | xargs -0 -J % mv % target_location" }, { "nl_command": "Prints the Nth line of output from 'ls -1'", "bash_code": "ls -1 | tail -n +N | head -n1" }, { "nl_command": "Finds out what groups a given user has.", "bash_code": "groups user" }, { "nl_command": "Make directories for each unique file path in \"file1\"", "bash_code": "cat file1 |xargs -I {} dirname \"{}\"| sort -u | xargs -I{} mkdir -p \"{}\"" }, { "nl_command": "Find all the files which are modified 50 days back", "bash_code": "find / -mtime 50" }, { "nl_command": "List all files in the current directory tree larger than 1000 kb", "bash_code": "find . -size +1000k" }, { "nl_command": "Search the current directory recursively for regular files last accessed 2 days ago", "bash_code": "find . type -f -atime 2" }, { "nl_command": "Print the boot time in standard date format", "bash_code": "who -b | awk '{$1=\"\"; $2=\"\"; print $0}' | date -f -" }, { "nl_command": "Archive directory \"symdir\" to \"symdir_output\" preserving symbolic links.", "bash_code": "rsync symdir/ symdir_output/ -a --copy-links -v" }, { "nl_command": "Print a colon-separated list of all directories from the $root directory tree", "bash_code": "find $root -type d | tr '\\n' ':'" }, { "nl_command": "Find all files in the current directory tree that were last changed $minutes minutes ago", "bash_code": "find . -cmin $minutes -print" }, { "nl_command": "Print a list of symbolic links reachable from the current directory that do not resolve to accessible files", "bash_code": "find -L. -type l" }, { "nl_command": "Print pathnames of all files in the current directory and below skipping files under SCCS directories", "bash_code": "find . -print -name SCCS -prune" }, { "nl_command": "find all the files that are modified exactly one day ago", "bash_code": "find -daystart -mtime 1" }, { "nl_command": "find all files in the current folder which have not been accessed in the last 7 days or which are bigger than 20KB", "bash_code": "find . -atime +7 -o -size +20480 -print" }, { "nl_command": "display long listing of all the symbolic links in the current folder", "bash_code": "find . -type l -exec ls -l {} \\;" }, { "nl_command": "Copy all .pdf files in the ./work/ directory tree with size bigger then 2 MB and modified more than 5 days ago to the ./backup/ directory", "bash_code": "find ./work/ -type f -name \"*.pdf\" -mtime +5 -size +2M | xargs -r cp -t ./backup/" }, { "nl_command": "Finds pattern text ignoring letter case in all .js files, prints matched strings and name of file with that strings.", "bash_code": "find . -name '*.js' -exec grep -i 'string to search for' {} \\; -print" }, { "nl_command": "Find all .log files in the /var/log directory tree and compress them using bzip2", "bash_code": "find /var/log -name '*.log' | tar cv --files-from=- | bzip2 > log.tar.bz2" }, { "nl_command": "search for \"some_function\" in all the python files in the current directory", "bash_code": "find . -name \\*.py | xargs grep some_function" }, { "nl_command": "Search for regular file foo ignoring case", "bash_code": "find . -iname foo -type f" }, { "nl_command": "display all file in the folder /dir/to/search except \".c\" files", "bash_code": "find /dir/to/search/ \\! -name \"*.c\" print" }, { "nl_command": "Find all files whose names end with \"~\" in the /home/peter directory tree, following symlinks, and delete them", "bash_code": "find -L /home/peter -name *~ -print0 |xargs -0 -r -n1000 rm" }, { "nl_command": "find files under the current directory called \"foo\" or \"bar\"", "bash_code": "find . \\( -name \"foo\" -o -name \"bar\" \\)" }, { "nl_command": "Remove all .txt files in and below the current directory", "bash_code": "find . -name \"*.txt\" -exec rm {} +" }, { "nl_command": "Find all directories under /home/username/public_html/sites/all/modules and set their permission to 750", "bash_code": "find /home/username/public_html/sites/all/modules -type d -exec chmod 750 {} +" }, { "nl_command": "display all the \"C\" files in the current folder", "bash_code": "find . -name \"*.c\"" }, { "nl_command": "change owner of the file my_test_expect.exp to user el", "bash_code": "sudo chown el my_test_expect.exp //make el the owner." }, { "nl_command": "List all files in the /myfiles directory tree", "bash_code": "find /myfiles -exec ls -l {} ;" }, { "nl_command": "Print file type of the executable file of command \"file\"", "bash_code": "file `which file`" }, { "nl_command": "find all the jpg images in folders which are in the path \"/201111/\" and sort them according to name and convert them into the video output.mp4", "bash_code": "find */201111/*20111130* -name \"*.jpg\" -print0 | sort -t '_' -nk2 | xargs -0 cat | ffmpeg -f image2pipe -framerate 30 -vcodec mjpeg -i - -vcodec libx264 -profile:v baseline -level 3.0 -movflags +faststart -crf 19 -pix_fmt yuv420p -r 30 \"output.mp4\"" }, { "nl_command": "Search the current directory tree for regular files whose names match pattern $x", "bash_code": "find . -type f -name $x" }, { "nl_command": "List all files/directories under /data1/Marcel which are greater than 524288 bytes and were modified or accessed more than 1 year ago", "bash_code": "find /data1/Marcel -size +1024 \\( -mtime +365 -o -atime +365 \\) -ls" }, { "nl_command": "Display the biggest file sizes only", "bash_code": "find -type f -exec du -Sh {} + | sort -rh | head -n 5" }, { "nl_command": "Find every file/directory under /var/spool that was modified more than 60 days ago.", "bash_code": "find /var/spool -mtime +60" }, { "nl_command": "Remove all directories called \"test\" from the current directory tree", "bash_code": "find . -name test -type d -exec rm -r {} \\;" }, { "nl_command": "Find all files/directories under '/usr/local' containing 'blast' (case insensitive) in their names", "bash_code": "find /usr/local -iname \"*blast*\"" }, { "nl_command": "Remove regular files whose names match Perl regular expression '\\w+-\\d+x\\d+\\.\\w+$' from the current directory tree", "bash_code": "find -type f | grep -P '\\w+-\\d+x\\d+\\.\\w+$' | xargs rm" }, { "nl_command": "Create intermediate directories \"b and \"c\" as required and directory \"c\"", "bash_code": "mkdir -p a/b/c" }, { "nl_command": "Print output of script 'trap.sh'", "bash_code": "~ $ . trap.sh | cat" }, { "nl_command": "find symbolic link file that name match '*sysdep.c'", "bash_code": "find . -lname '*sysdep.c'" }, { "nl_command": "Saves bytes count of the value of '$each' variable.", "bash_code": "a=$" }, { "nl_command": "Delete all files named \"filename\" in the current directory tree, except those with paths ending in \"/myfolder/filename\"", "bash_code": "find . -name \"filename\" -and -not -path \"*/myfolder/filename\" -delete" }, { "nl_command": "find all the xml files in the current folder except those that are present in the workspace folder and create a tarball of these files", "bash_code": "find . -name \\*.xml | grep -v /workspace/ | tr '\\n' '\\0' | xargs -0 tar -cf xml.tar" }, { "nl_command": "Put the absolute directory path to the current script to MY_DIR variable", "bash_code": "MY_DIR=$(dirname $(readlink -f $0))" }, { "nl_command": "display all the files in the current folder which have not been modified in the last 7 days and which are not in the list \"file.lst\"", "bash_code": "find -mtime +7 -print | grep -Fxvf file.lst" }, { "nl_command": "display all the regular files in the folder \"$(FOLDER)\" which are modified in the last $(RETENTION)*24 hours and excluding hidden files", "bash_code": "find ${FOLDER} -type f ! -name \\\".*\\\" -mtime -${RETENTION}" }, { "nl_command": "Search directory $CURR_DIR for regular files that were changed, accessed, or modified $FTIME days ago", "bash_code": "find ${CURR_DIR} -type f \\ -printf \"./%P\\n\"" }, { "nl_command": "Remove all broken symbolic links in /usr/ports/packages", "bash_code": "find -L /usr/ports/packages -type l -delete" }, { "nl_command": "find Texinfo source files in /usr/local/doc", "bash_code": "find foo -path foo/bar -print" }, { "nl_command": "Print the filenames taken by the glob pattern * with null character as the delimiter", "bash_code": "find * -maxdepth 0 -type d -print0" }, { "nl_command": "sleep for 5 seconds", "bash_code": "sleep 5" }, { "nl_command": "display all files in the current folder which end with extension \"myfile\" followed by one digit or two digits", "bash_code": "find . -\\" }, { "nl_command": "Find all regular files in the current directory tree and count them", "bash_code": "find -type f -printf '.' | wc -c" }, { "nl_command": "Format the 5th, 3rd, and 4th fields of \"...\" as a table", "bash_code": "...| awk '{print $5\"\\t\\t\" $3\"\\t\"$4}'|column -t" }, { "nl_command": "Print sub domains of \"mydomain.com\"", "bash_code": "hostname -a -l mydomain.com | sed -n '/;; ANSWER/{n;N;p;q}'" }, { "nl_command": "Mount \"ext4\" filesystem \"/dev/xvdf\" on \"/vol\"", "bash_code": "sudo mount /dev/xvdf /vol -t ext4" }, { "nl_command": "Counts lines of /dir/file.txt file.", "bash_code": "wc -l /dir/file.txt" }, { "nl_command": "Search for files/directories that are readable for everybody, have at least one write bit set but are not executable for anybody", "bash_code": "find . -perm -444 -perm /222 ! -perm /111" }, { "nl_command": "Prints a random line from file", "bash_code": "head -$() file | tail -1" }, { "nl_command": "Update timestamps of all regular files under /your/dir", "bash_code": "find /your/dir -type f -exec touch {} +" }, { "nl_command": "Delete all regular files named 'FILE-TO-FIND' under current directory tree", "bash_code": "find . -type f -name \"FILE-TO-FIND\" -exec rm -f {} \\;" }, { "nl_command": "Search the current directory and all of its sub-directory for any PDF files being careful to prevent the shell from expanding \"*\" before it's passed to find.", "bash_code": "find . -name \\*.pdf -print" }, { "nl_command": "Print each line in \"set1\" and \"set2\" that does not exist in the other", "bash_code": "sort set1 set2 | uniq" }, { "nl_command": "Compose filepath as folder path where file $f is located, and lowercase filename of $f file, and save it in 'g' variable", "bash_code": "g=`dirname \"$f\"`/`basename \"$f\" | tr '[A-Z]' '[a-z]'`" }, { "nl_command": "Count the number of \"x\" characters in \"filename\"", "bash_code": "sed 's/[^x]//g' filename | tr -d '\\012' | wc -c" }, { "nl_command": "Print every two lines in \"num.txt\" on a single line separated by a space", "bash_code": "paste -d' ' <(sed -n 'p;n' num.txt) <(sed -n 'n;p' num.txt)" }, { "nl_command": "Print yesterday's date", "bash_code": "date -j -v-1d" }, { "nl_command": "Find all *company* files/directories under /root/of/where/files/are directory", "bash_code": "find /root/of/where/files/are -name *company*" }, { "nl_command": "find all files under the /etc directory and display any IP address patterns in them", "bash_code": "find /etc -exec grep '[0-9][0-9]*[.][0-9][0-9]*[.][0-9][0-9]*[.][0-9][0-9]*' {} \\;" }, { "nl_command": "Save the first three octets of the current host's IP address to variable \"local\"", "bash_code": "local=$(hostname -I | awk '{print $2}' | cut -f1,2,3 -d\".\")" }, { "nl_command": "Delete all but the most recent 5 files", "bash_code": "ls -tr | head -n -5 | xargs rm" }, { "nl_command": "set alias \"m\" for command \"mplayer -novideo -loop 0\"", "bash_code": "alias m=\"mplayer -novideo -loop 0\"" }, { "nl_command": "Find all *.jpg (case insensitive) files under current directory", "bash_code": "find . -iname '*.jpg'" }, { "nl_command": "Counts lines in each *.php file sorted by file path.", "bash_code": "find . -name '*.php' -type f | sort | xargs wc -l" }, { "nl_command": "Save list of groups which user $line belongs to and not matching pattern \"_unknown|sciences|everyone|netaccounts\" in 'results' variable", "bash_code": "results=$(groups \"$line\" | tr ' ' '\\n' | egrep -v \"_unknown|sciences|everyone|netaccounts\")" }, { "nl_command": "Answer \"y\" to all \"Are you sure?\" prompts from command \"cp * /tmp\"", "bash_code": "yes | cp * /tmp" }, { "nl_command": "Find all .txt files in the /home/user1 directory tree and copy them to /home/backup", "bash_code": "find /home/user1 -name '*.txt' | xargs cp -av --target-directory=/home/backup/ --parents" }, { "nl_command": "List all the file links", "bash_code": "find . -type l" }, { "nl_command": "Print \"on\" to standard output and to files matching \"/sys/bus/usb/devices/usb*/power/level\"", "bash_code": "echo \"on\" | tee /sys/bus/usb/devices/usb*/power/level" }, { "nl_command": "Save hexadecimal bytes 7 and 8 in binary file \"file.moi\" to variable \"year\"", "bash_code": "year=$(od -t x2 --skip-bytes=6 --read-bytes=2 file.moi | head -1 | awk '{print $2}')" }, { "nl_command": "Archive preserving permissions and ownership files in \"/var/www/\" on host \"user@10.1.1.2\" to local \"/var/www/\"", "bash_code": "sudo rsync -az user@10.1.1.2:/var/www/ /var/www/" }, { "nl_command": "search all the files in the folder \"myfiles\" which have the word \"blue\" in their name", "bash_code": "find /myfiles -name '*blue*'" }, { "nl_command": "Find all the files that were modified exactly one day ago", "bash_code": "find . -mtime 1" }, { "nl_command": "Set permissions to ug=rw,o= for files inside the ./default/files tree", "bash_code": "find ./default/files -type f -exec chmod ug=rw,o= '{}' \\;" }, { "nl_command": "View history using \"vim\" in read only mode", "bash_code": "history | vim -R -" }, { "nl_command": "list symbolic links under the directory \"$directory\"", "bash_code": "find $directory -type l" }, { "nl_command": "Search the system for the file \u201ctestfile.txt\u201d", "bash_code": "find / -name \"testfile.txt\"" }, { "nl_command": "Print the file content of command \"f\"", "bash_code": "cat `which f`" }, { "nl_command": "this find command Substitute space with underscore in the file name replaces space in all the *.mp3 files with _", "bash_code": "find . -type f -iname '*.mp3' -exec rename '/ /_/' {} \\;" }, { "nl_command": "Remove directories in /media/1Tb/videos modified more than 7 days ago", "bash_code": "find /media/1Tb/videos -maxdepth 1 -type d -mtime +7 -exec rm -rf {} \\;" }, { "nl_command": "Search the local subdirectory tree of the current working directory and the /tmp directory tree for directories named mydir", "bash_code": "find local /tmp -name mydir -type d -print" }, { "nl_command": "search for all \"tif\" images in the entire file system", "bash_code": "find / -name '*.tif ' \u2013print" }, { "nl_command": "Find all files/directories under current directory with null character as the delimiter", "bash_code": "find . -print0" }, { "nl_command": "Print '-ok is an action so an implicit -print is not applied' with confirmation from the user for each file or directory found by the name 'file' under current directory tree", "bash_code": "find -name file -ok echo '-ok is an action so an implicit -print is not applied' \\;" }, { "nl_command": "Search the /myfiles directory tree for files last accessed more than 30 days ago", "bash_code": "find /myfiles -atime +30" }, { "nl_command": "Find all files/directories named 'filename' that belong to user 'username' and group 'groupname' in the entire filesystem", "bash_code": "find / -user username -group groupname -name filename" }, { "nl_command": "find all files in the current directory which are bigger than 4MB", "bash_code": "find . -size +4096k -print" }, { "nl_command": "Find broken links using the file command on each symlinks in the system and searching for the keword 'broken' with grep", "bash_code": "find / -type l -print0 | xargs -0 file | grep broken" }, { "nl_command": "Execute the `file' command on all regular files from the current directory tree and save the output as /tmp/filetypes.log", "bash_code": "find . -type f -exec file {} \\; > /tmp/filetypes.log" }, { "nl_command": "Print file names of all files ending with '*.csv' in '/home/ABC/files/' directory", "bash_code": "ls /home/ABC/files/*.csv | rev | cut -d/ -f1 | rev" }, { "nl_command": "set alias \"unsetvar\" for command 'source /your/path/to/the/script/unsetvar'", "bash_code": "alias unsetvar='source /your/path/to/the/script/unsetvar'" }, { "nl_command": "Remove all files whose names end with \"~\" in the /home/peter directory tree", "bash_code": "find /home/peter -name *~ |xargs rm" }, { "nl_command": "Cut off three last symbols from string '1234567890 *'", "bash_code": "echo '1234567890 *' | rev | cut -c 4- | rev" }, { "nl_command": "Archive the entire file system into tarfile.tar.bz2", "bash_code": "find / -print0 | xargs -0 tar cjf tarfile.tar.bz2" }, { "nl_command": "find all the files in the current directory and change the permissions to 775.", "bash_code": "find . -exec chmod 775 {} \\;" }, { "nl_command": "Find all files/directories newer than ttt or owned by user 'wn' in entire file system", "bash_code": "find / \\ -print" }, { "nl_command": "Copy all files and directories in \"/home/\" to \"/newhome\" preserving directory hierarchy and modification time", "bash_code": "find /home/ -maxdepth 1 -print | sudo cpio -pamVd /newhome" }, { "nl_command": "Copy all files ending in \".a\" in directory trees matching \"folder*\" to \"/path/to/dest\" preserving directory hierarchy", "bash_code": "find folder* -name '*.a' -print | cpio -pvd /path/to/dest" }, { "nl_command": "Search for 'It took' in all $srch1* files under current directory and run the sed script 'N;s/\\n/\\2 \\1/' on the output", "bash_code": "find . -iname \"$srch1*\" -exec grep \"It took\" {} \\; -print |sed -r 'N;s/\\n/\\2 \\1/'" }, { "nl_command": "Search the current directory tree recursively for the regular file named \"myfile\" ignoring \"work\" and \"home\" directories", "bash_code": "find . \\( -name work -o -name home \\) -prune -o -name myfile -type f -print" }, { "nl_command": "Find all files in /mydir and replace every occurrences of with in those files invoking sed as few times as possible", "bash_code": "find /mydir -type f -exec sed -i 's///g' {} +" }, { "nl_command": "Find all *.php files under current directory and change their permission to 644", "bash_code": "find . -type f -name '*.php' -exec chmod 644 {} \\;" }, { "nl_command": "Read a line from standard input in an interactive shell into variable \"input\" with prompt \"Do that? [Y,n]\" and suggestion \"Y\"", "bash_code": "read -e -p \"Do that? [Y,n]\" -i Y input" }, { "nl_command": "Set up a local SSH tunnel from port 80 to port 3000", "bash_code": "ssh $USERNAME@localhost -L 80:localhost:3000 -N" }, { "nl_command": "Compare \"fastcgi_params\" and \"fastcgi.conf\" line by line, output 3 lines of unified context, and print the C function the change is in", "bash_code": "diff -up fastcgi_params fastcgi.conf" }, { "nl_command": "List all paths to files or directories under \"/data/\" that start with \"command-\" and end with \"-setup\", sort the result by the version number specified between \"command-\" and \"-setup\" (least to greatest)", "bash_code": "find /data/ -name 'command-*-setup' | sort -t - -V -k 2,2" }, { "nl_command": "Gets MAC address of 'eth0' network interface.", "bash_code": "ifconfig eth0 | head -n1 | tr -s ' ' | cut -d' ' -f5" }, { "nl_command": "create an archive using pbzip2 as a compress program", "bash_code": "tar -I pbzip2 -cf OUTPUT_FILE.tar.bz2 /DIR_TO_ZIP/" }, { "nl_command": "Find all *.txt files under current directory with their timestamps and paths, sort them and print the last entry only", "bash_code": "find . -name \"*.txt\" -printf \"%T+ %p\\n\" | sort | tail -1" }, { "nl_command": "Remove files modified at least five days ago in directory trees /path/to/files*", "bash_code": "find /path/to/files* -mtime +5 -exec rm {} \\;" }, { "nl_command": "Create a symbolc link named \"latest\" to the last modified file or directory in \"target-directory\"", "bash_code": "ln -s target-directory/`ls -rt target-directory | tail -n1` latest" }, { "nl_command": "Find all *Company* files/directories under /root/of/where/files/are directory", "bash_code": "find /root/of/where/files/are -name *Company*" }, { "nl_command": "display the count of regular/normal files in the folder \"/path/to/dir\"", "bash_code": "find /path/to/dir -type f -exec printf %.sX {} + | wc -c" }, { "nl_command": "Recursively copy directory \"/path/to/data/myappdata\" to \"user@host:/remote/path/to/data/newdirname\"", "bash_code": "rsync -rvv --recursive /path/to/data/myappdata user@host:/remote/path/to/data/newdirname" }, { "nl_command": "Display differences between a and b side-by-side", "bash_code": "diff -y a b" }, { "nl_command": "Give all files in the /path/to/base/dir tree read privileges", "bash_code": "find /path/to/base/dir -type f -print0 | xargs -0 chmod 644" }, { "nl_command": "Split \"system.log\" into files of at most 10 MiB in size with a numeric suffix and prefix \"system_split.log\"", "bash_code": "split -b 10M -d system.log system_split.log" }, { "nl_command": "Delete all files/directories named 'FILE-TO-FIND' under current directory tree", "bash_code": "find . -name \"FILE-TO-FIND\" -exec rm -rf {} \\;" }, { "nl_command": "find all the directories in the current folder", "bash_code": "find -type d" }, { "nl_command": "find all the files in the entire filesystem which belong to the group root and display the ten files.", "bash_code": "find / -group root | head" }, { "nl_command": "Get virtual private memory use of process", "bash_code": "top -l 1 -s 0 -stats mem -pid PID" }, { "nl_command": "Write out the entire directory hierarchy from the current directory", "bash_code": "find . -print" }, { "nl_command": "Search the current directory tree for regular files whose names end in \".shtml\" or \".css\"", "bash_code": "find . -type f | egrep '\\.(shtml|css)$'" }, { "nl_command": "sort based on size and display top ten largest normal/regular files in the current folder", "bash_code": "find . -type f -exec ls -s {} \\; | sort -n -r | head -10" }, { "nl_command": "Archive and compress all files in \"data\" directory into \"data.tar.gz\"", "bash_code": "tar -cvf - data/* | gzip > data.tar.gz" }, { "nl_command": "Find all files/directories under .. directory and copy them to ~/foo/bar", "bash_code": "find .. -exec cp -t ~/foo/bar -- {} +" }, { "nl_command": "Print a welcome message with the current user's user name", "bash_code": "echo \"Welcome $(whoami)!\"" }, { "nl_command": "Measure the disk space taken up by all *.txt files in the /path directory tree", "bash_code": "find /path -iname '*.txt' | perl -lane '$sum += -s $_; END {print $sum}'" }, { "nl_command": "find all the xml files in current folder and which are present in the pattern list file \"/tmp/a\"", "bash_code": "find . -name \"*.xml\" -exec grep -HFf /tmp/a {} \\;" }, { "nl_command": "delete recursively, without prompting, any files or directories under the current directory that case insensitively match the filename \".svn\"", "bash_code": "find . -iname .svn -print | xargs rm -rf" }, { "nl_command": "Print each line in \"file1\" and file2\" separated by tabs and \"file3\" separated by a space", "bash_code": "paste -d\" \" file1 file2 | paste -d'|' - file3 | sed 's,|, ,g'" }, { "nl_command": "search files in current folder using name patterns", "bash_code": "find . -name \"$pattern\"" }, { "nl_command": "recursively change owner of the directory ~/.npm to the current user", "bash_code": "sudo chown -R $(whoami) ~/.npm" }, { "nl_command": "Print a list of regular files from directory tree sort_test/ sorted with LC_COLLATE=en_US.utf8", "bash_code": "find sort_test/ -type f | env -i LC_COLLATE=en_US.utf8 sort" }, { "nl_command": "Find all regular files under /home/www and replace every occurrences of 'subdomainA.example.com' with 'subdomainB.example.com' in those files invoking perl as few times as possible and also keep backups with .bak extension.", "bash_code": "find /home/www/ -type f -exec perl -i.bak -pe 's/subdomainA\\.example\\.com/subdomainB.example.com/g' {} +" }, { "nl_command": "Rename all files matching \"access.log..gz\" incrementing .", "bash_code": "find -name 'access.log.*.gz' | sort -Vr | rename 's/(\\d+)/$1+1/ge'" }, { "nl_command": "Print position number of day '9' in fourth line of calendar output for September, 2009.", "bash_code": "cal 09 2009 | awk '{day=\"9\"; if {col=index; print col } }'" }, { "nl_command": "Look for files in the current directory tree to which the group users have full access", "bash_code": "find . -perm -070 -print" }, { "nl_command": "Locate all files \"needle.txt\"", "bash_code": "find . -name \"needle.txt\"" }, { "nl_command": "Search \"mygzfile.gz\" for \"string to be searched\"", "bash_code": "gunzip -c mygzfile.gz | grep \"string to be searched\"" }, { "nl_command": "display all the file in the folder /home/david/ which start with the word \"index\"", "bash_code": "find /home/david -name 'index*'" }, { "nl_command": "Copy directory hierarchy \"dir\" and all its .txt files to \"dir_txt\"", "bash_code": "find dir/ -name '*.txt' | xargs cp -a --target-directory=dir_txt/ --parents" }, { "nl_command": "Page through the contents of file 'file_name', positioning the view at the first occurrence of regular expression 'regex'.", "bash_code": "less -p regex file_name" }, { "nl_command": "create a zip of all the files in the current folder which are bigger than 100Kb and do not go more than 2 levels during search", "bash_code": "find . -maxdepth 2 -size +100000 -exec bzip2 {} \\;" }, { "nl_command": "Find all sample* files/directories under current directory and print 'program {}-out {}' where {} will expand to file paths", "bash_code": "find . -name \"sample*\" | xargs -i echo program {}-out {}" }, { "nl_command": "View history using \"vim\" in read only mode", "bash_code": "history | vim -R -" }, { "nl_command": "List all files in /home/bozo/projects directory tree that were modified exactly one day ago", "bash_code": "find /home/bozo/projects -mtime 1" }, { "nl_command": "Prints week day of a 31 day in a current month.", "bash_code": "cal | awk -v date=31 -v FIELDWIDTHS=\"3 3 3 3 3 3 3 3\" 'NR==2 {split($0,a)} {for (i=1;i<=NF;i++) if ($i==date) print a[i]}'" }, { "nl_command": "Find all directories starting from the current directory", "bash_code": "find . -type d" }, { "nl_command": "Disables shell option 'compat31'.", "bash_code": "shopt -u compat31" }, { "nl_command": "Saves file sctipt.sh size in 'size' variable.", "bash_code": "size=`cat script.sh | wc -c`" }, { "nl_command": "Print the PIDs of the current user's instances of \"firefox\"", "bash_code": "ps -u $(whoami) | grep firefox | awk '{printf $1}'" }, { "nl_command": "display all files ending with \".ext\" in current folder and append the file contents of list.txt and sort them based on name and display only uniq items", "bash_code": "find . -name \\*.ext | cat - list.txt | sort | uniq -u" }, { "nl_command": "find all png files in the current folder", "bash_code": "find . -type f -name '*.png'" }, { "nl_command": "search for the file \"program.c\" in the entire file system and save the errors to the file errors.txt", "bash_code": "find / -name 'program.c' 2>errors.txt" }, { "nl_command": "Find all files/directories under $dir directory tree which have been modified in the last 3 days", "bash_code": "find $dir -mtime -3" }, { "nl_command": "Find all files under current directory with their size and paths, reverse sort them numerically, then print first 4 entries", "bash_code": "find -type f -printf \"%s %p\\n\" | sort -nr | head -n 4" }, { "nl_command": "find all executable files", "bash_code": "find / -executable" }, { "nl_command": "Print 3 newline separated \"y\"s", "bash_code": "yes | head -3" }, { "nl_command": "Unzip all \".gz\" files in the current directory tree excluding files containing \"dvportgroups\", \"nsanity\", \"vcsupport\", \"viclient\", and \"vsantraces\"", "bash_code": "find . -name '*.gz' ! -name '*dvportgroups*' ! -name '*nsanity*' ! -name '*vcsupport*' ! -name '*viclient*' ! -name 'vsantraces*' -exec gunzip -vf {} \\;" }, { "nl_command": "Opens new tmux session.", "bash_code": "tmux" }, { "nl_command": "Search the /home/weedly directory tree for regular files named myfile", "bash_code": "find /home/weedly -name myfile -type f -print" }, { "nl_command": "make a copy of file file1 named file2", "bash_code": "su - jetty cp file1 file2" }, { "nl_command": "Dump \"testscript.sh\" as 2 byte hexadecimale, printable characters, and octal values", "bash_code": "od -xcb testscript.sh" }, { "nl_command": "Connect to \"$USER_AT_HOST\" using connection sharing on \"$SSHSOCKET\" and request the master to exit", "bash_code": "ssh -S \"$SSHSOCKET\" -O exit \"$USER_AT_HOST\"" }, { "nl_command": "find all files in the file system which have not been accessed in the last 2 days", "bash_code": "find / -atime +2" }, { "nl_command": "Find all regular files under /home/www and replace every occurrences of 'subdomainA.example.com' with 'subdomainB.example.com' in those files invoking sed as few times as possible", "bash_code": "find /home/www/ -type f -exec sed -i 's/subdomainA\\.example\\.com/subdomainB.example.com/g' {} +" }, { "nl_command": "Synchronize \"/path/to/dir_a\" with files in \"/path/to/dir_b/\" if the files are newer", "bash_code": "rsync -rtuv /path/to/dir_b/* /path/to/dir_a" }, { "nl_command": "remove all text files from the current folder", "bash_code": "find -name \"*.txt\" | xargs rm" }, { "nl_command": "Filter /path/to/logfile for any lines containing the specified date, paging interactively through the output.", "bash_code": "grep 'Nov 12 2012' /path/to/logfile | less" }, { "nl_command": "Search the current directory tree for all files except SVN ones", "bash_code": "find . | grep -v \\.svn" }, { "nl_command": "Allow all users to execute '$pathToShell\"myShell.sh\"'", "bash_code": "chmod a+x $pathToShell\"myShell.sh\"" }, { "nl_command": "Save the canonical filename of \"$BASH_SOURCE\" in variable \"me\"", "bash_code": "me=$(readlink --canonicalize --no-newline $BASH_SOURCE)" }, { "nl_command": "List the full path of each directory in the current working directory", "bash_code": "tree -dfi -L 1 \"$\"" }, { "nl_command": "Remove all CVS directories in the current directory tree", "bash_code": "find . -type d -name CVS -exec rm -r {} \\;" }, { "nl_command": "Change the owner of all files in the current directory tree excluding those who match \"./var/foo*\" to \"www-data\"", "bash_code": "find . -not -iwholename './var/foo*' -exec chown www-data '{}' \\;" }, { "nl_command": "Find x* files/directories under /tmp directory whose status was changed less than 1 day ago and move them to ~/play", "bash_code": "find /tmp/ -ctime -1 -name \"x*\" | xargs -I '{}' mv '{}' ~/play/" }, { "nl_command": "list all javascipts file which whole name does not contain \"directory\"", "bash_code": "find . -name '*.js' -and -not -path directory" }, { "nl_command": "List all *.txt files/directories under /etc", "bash_code": "find /etc -name \"*.txt\" | xargs -I {} ls -l {}" }, { "nl_command": "Find and delete all .zip files in the current directory tree", "bash_code": "find . -depth -name '*.zip' -exec rm {} \\;" }, { "nl_command": "list regular file which file name end with '*.c' or '*.sh' in current directory", "bash_code": "find . -type f \\" }, { "nl_command": "show the disk use of all the regular/normal files in the file system which are bigger than 100MB", "bash_code": "find / -type f -size +100M | xargs du -sh" }, { "nl_command": "Continuously convert \"20131202\" into \"2013 12 02\" and print the result", "bash_code": "yes a=\\\"20131202\\\" | sed -e :a -e 's/...\\([0-9]\\{4\\}\\)\\([0-9]\\{2\\}\\)\\([0-9]\\{2\\}\\)./\\1 \\2 \\3/'" }, { "nl_command": "Print only common file names in sorted listings of directory 'dir1' and 'dir2'", "bash_code": "comm -1 -2 <(ls /dir1 | sort) <(ls /dir2 | sort)" }, { "nl_command": "Make directories and parents as needed for each unique second \"&\" delimited field with \" \", \",\", and \":\" removed in \"filetypes.txt\"", "bash_code": "mkdir -p `cut -f2 -d\"&\" filetypes.txt | sed 's/[ ,:]//g' | sort -u`" }, { "nl_command": "Find files/directories under current directory that matches the regex /path/to/something[^/]*$ in their paths", "bash_code": "find . | grep -qi /path/to/something[^/]*$" }, { "nl_command": "Find file `foo.bar' and delete it", "bash_code": "find /home -name foo.bar -type f -exec rm -f \"{}\" ';'" }, { "nl_command": "Print the list of non-hidden directories in the current directory", "bash_code": "find -type d -maxdepth 1 ! -name \".*\" -printf \"%f\\n\"" }, { "nl_command": "find all the files with the extension .xml and print them in a single line and check for the validity of a command by giving the file as input", "bash_code": "find . -name *.xml -print0 | xargs -n 1 -0 invalid_command" }, { "nl_command": "Search /usr, /home, /tmp for *.jar files", "bash_code": "find /usr /home /tmp -name \"*.jar\"" }, { "nl_command": "Save the system host name into variable \"HOST\"", "bash_code": "HOST=$(hostname)" }, { "nl_command": "Find all files that have been modified in the last seven days.", "bash_code": "find . -mtime -7 -type f" }, { "nl_command": "Mount partition with label \"WHITE\" on \"/mnt/WHITE\" with read and write permission and have it accessible by user and group \"test\"", "bash_code": "mount -L WHITE /mnt/WHITE -o rw,uid=test,gid=test" }, { "nl_command": "find all the html files in the current folder which have been modified excatly 7 days before", "bash_code": "find . -mtime 7 -name \"*.html\" -print" }, { "nl_command": "find all directories that names are 'apt' and display details", "bash_code": "find / -type d -name \"apt\" -ls" }, { "nl_command": "Remove all *.bak and *.backup files that were accessed last time more than 30 days ago", "bash_code": "find . \\( -name '*.bak' -o -name *.backup \\) -type f -atime +30 -exec rm '{}' ';'" }, { "nl_command": "Find all files/directories matching the regex pattern \".*\\\\.rb$\" under current directory", "bash_code": "find . -regex \".*\\\\.rb$\"" }, { "nl_command": "Run \"./configure\" with a new environment variable CC set to the full path of the command 'cc'", "bash_code": "CC=$ ./configure" }, { "nl_command": "Display all lines containing \"IP_MROUTE\" in the current kernel's compile-time config file.", "bash_code": "cat /boot/config-`uname -r` | grep IP_MROUTE" }, { "nl_command": "Remove all .txt files from the /full/path/dir directory tree", "bash_code": "find /full/path/dir -name '*.txt' -exec /bin/rm {} \\;" }, { "nl_command": "Prints Kb size of all top-level files and folders in a current folder in descending order.", "bash_code": "du -ks * | sort -n -r" }, { "nl_command": "Print the common third whitespace separated fields in \"file1\" and \"file2\"", "bash_code": "comm -12 <(awk '{print $3}' file1 | sort -u) <(awk '{print $3}' file2 | sort -u)" }, { "nl_command": "Search directory /path/to/check/ for regular files", "bash_code": "find /path/to/check/* -maxdepth 0 -type f" }, { "nl_command": "Save the contents of \"file\" in the clipboard", "bash_code": "cat file | xclip" }, { "nl_command": "Print \"$somedir is empty\" if $somedir is empty", "bash_code": "find \"$somedir\" -maxdepth 0 -empty -exec echo {} is empty. \\;" }, { "nl_command": "Add a line number to every line in \"long-file\"", "bash_code": "nl -ba long-file \\" }, { "nl_command": "convert all the normal files in the current folder from dos format to unix format and save the output to a file", "bash_code": "find . -type f -exec dos2unix {} {} \\;" }, { "nl_command": "Parse \"file.json\" to print JSON \"title\" entries whose \"price\" are less than 10", "bash_code": "cat file.json | python -c \"import sys, json, jsonpath; print '\\n'.join(jsonpath.jsonpath(json.load, 'store.book[?].title'))\"" }, { "nl_command": "recursively change owner of the directory /usr/local to the current user", "bash_code": "sudo chown -R `whoami` /usr/local" }, { "nl_command": "List all directories in maximum 1 level down the current directory", "bash_code": "find . -maxdepth 1 -type d -exec ls -dlrt {} \\;" }, { "nl_command": "Add \"prefix\" to every non-blank line in \"file.txt\"", "bash_code": "nl -s prefix file.txt | cut -c7-" }, { "nl_command": "Create intermediate directories \"x\" and \"p\" as required and create \"q\"", "bash_code": "mkdir -p x/p/q" }, { "nl_command": "Check that the master SSH control socket \"my-ctrl-socket\" to \"jm@sampledomain.com\" is running", "bash_code": "ssh -S my-ctrl-socket -O check jm@sampledomain.com" }, { "nl_command": "Find all regular files under current directory", "bash_code": "find . -depth -type f -print" }, { "nl_command": "Print the drive and mount point of the last mounted drive", "bash_code": "mount | tail -1 | sed 's/^.* on \\ ]*)$/\\1/'" }, { "nl_command": "Remove all empty regular files under the current directory and below", "bash_code": "find ./ -type f -size 0c -print | xargs rm" }, { "nl_command": "Save a space separated list of process ids of currently running jobs to variable 'bgxjobs'", "bash_code": "bgxjobs=\" $(jobs -pr | tr '\\n' ' ')\"" }, { "nl_command": "display all the \".mov\" files in the current folder", "bash_code": "find . -name \"*.mov\"" }, { "nl_command": "display all the text files in the home folder ( case insensitive search )", "bash_code": "find /home -iname \"*.txt\"" }, { "nl_command": "Find all files you have modified in the last two days", "bash_code": "find ~ -type f -mtime -2" }, { "nl_command": "Get domain name with 'google' from address $IP", "bash_code": "dig -x $IP | grep PTR | cut -d ' ' -f 2 | grep google | cut -f 5" }, { "nl_command": "Find all files/directories under current directory tree that belong to the group 'compta'", "bash_code": "find -group compta" }, { "nl_command": "Gets a job with defined number back to the foreground.", "bash_code": "fg 1" }, { "nl_command": "Send a single ping request with a TTL of 1 to \"192.168.1.1\"", "bash_code": "ping -c 1 -t 1 192.168.1.1" }, { "nl_command": "Count the number of .gz files in directory tree /home/user1/data1/2012/mainDir", "bash_code": "find /home/user1/data1/2012/mainDir -name '*.gz' | wc -l" }, { "nl_command": "Print lines 10000 to 10010 from input \"seq 1 100000\"", "bash_code": "seq 1 100000 | tail -n +10000 | head -n 10" }, { "nl_command": "Search the /path/to/directory tree for regular files modified 61 days ago and then remove them", "bash_code": "find /path/to/directory -type f -mtime 61 -exec rm -f {} \\;" }, { "nl_command": "Shifts all positional arguments but last one, keeping it in $1 variable.", "bash_code": "shift `expr $# - 1`" }, { "nl_command": "Print current UTC date in ISO format with precision to seconds", "bash_code": "date -u -Iseconds" }, { "nl_command": "Find and print detailed information about all regular files in your home directory and below that have only the group permission set", "bash_code": "find . -perm g=r -type f -exec ls -l {} \\;" }, { "nl_command": "Print all lines from file 'report.txt' containing any-cased 'error' pattern", "bash_code": "cat report.txt | grep -i error" }, { "nl_command": "Print the empty files/directories among empty1, empty2 and not_empty", "bash_code": "find empty1 empty2 not_empty -prune -empty" }, { "nl_command": "Send 5 pings to broadcast address \"10.10.0.255\" and print the unique IPs who responded", "bash_code": "ping -c 5 -b 10.11.255.255 | sed -n 's/.* \\.*/\\1/p' | sort | uniq" }, { "nl_command": "convert epoch second timestamp to date", "bash_code": "date -d @1278999698 +'%Y-%m-%d %H:%M:%S'" }, { "nl_command": "display all the files in the file system which belong to no group", "bash_code": "find / -nogroup staff -print" }, { "nl_command": "Find all the files without permission 777 under current directory and show a few lines of output from the beginning", "bash_code": "find . -type f ! -perm 777 | head" }, { "nl_command": "Saves state of shell option 'nullglob' in an 'old_nullglob' variable.", "bash_code": "local old_nullglob=$" }, { "nl_command": "Search appended data in \"logfile.log\" for \"something\" with a timeout of 3 seconds", "bash_code": "read -t 3 variable < <" }, { "nl_command": "find files under the current directory ending in \"txt\" and list them, or ending in \"html\" but do nothing.", "bash_code": "find . -name '*.txt' -print -o -name '*.html'" }, { "nl_command": "Save the first line of \"foo.txt\" to variable \"bar\"", "bash_code": "bar=$" }, { "nl_command": "change owner of the files into directory dir_to_start except directory dir_to_exclude to user owner", "bash_code": "find dir_to_start -name dir_to_exclude -prune -o -print0 | xargs -0 chown owner" }, { "nl_command": "List directories in the current working directory and remove the trailing \"/\"", "bash_code": "ls -d */|sed 's|[/]||g'" }, { "nl_command": "Copy a whole directory tree skipping files residing on other files systems to destination_dir", "bash_code": "find ./ -mount -depth -print | cpio -pdm /destination_dir" }, { "nl_command": "Print all file/directory paths under current directory", "bash_code": "find -print0 | while IFS= read -rd $'\\0' f ; do echo \"[$f]\" ; done" }, { "nl_command": "find all the regular files in the current folder which start with a \"some text\"", "bash_code": "find . -type f -name '*some text*'" }, { "nl_command": "Find all .sh files in or below the current directory and move them to folder ~/back.scripts", "bash_code": "find . -name \"*.sh\" -print0 | xargs -0 -I file mv file ~/back.scripts" }, { "nl_command": "Recursively change the owner of all files in \"upload_directory\" to \"nobody\"", "bash_code": "chown -R nobody upload_directory" }, { "nl_command": "Save the first line of \"$j\" into variable \"k\" in ksh", "bash_code": "echo $j | read k" }, { "nl_command": "Find .rmv files in the current directory recursively", "bash_code": "find . -name *.rmv" }, { "nl_command": "Copy *.mp3 files to /tmp/MusicFiles", "bash_code": "find . -type f -name \"*.mp3\" -exec cp {} /tmp/MusicFiles \\;" }, { "nl_command": "Remove trailing whitespaces in .txt files from the current directory tree", "bash_code": "find . -type f -name \"*.txt\" -exec sh -c 'for i;do sed 's/[[:space:]]*$//' \"$i\">/tmp/.$$ && mv /tmp/.$$ \"$i\";done' arg0 {} +" }, { "nl_command": "Search the Movies folder in the user's home directory for files larger than 1024 megabytes in size.", "bash_code": "find ~/Movies/ -size +1024M" }, { "nl_command": "find CSS files, omitting results containing \"CVS\"", "bash_code": "find . \\! -path \"*CVS*\" -type f -name \"*.css\"" }, { "nl_command": "Create a report of the contents of a USB drive mounted at find /path/to/drive", "bash_code": "find /path/to/drive -type f -exec file -b '{}' \\; -printf '%s\\n' | awk -F , 'NR%2 {i=$1} NR%2==0 {a[i]+=$1} END {for printf}' | sort -nr" }, { "nl_command": "Forcibly create symbolic links in target directory \"~/staging\" for all files located in directory \"~/mirror\"", "bash_code": "ln --force --target-directory=~/staging ~/mirror/*" }, { "nl_command": "split file abc.txt into pieces per 1500000000 bytes named as \"abc.NNN\"", "bash_code": "split --bytes=1500000000 abc.txt abc" }, { "nl_command": "display all normal/regular files in a folder", "bash_code": "find /home/the_peasant -type f" }, { "nl_command": "Save the current time formatted according to the format string \"%Y-%m-%d %H:%M:%S\" to the variable 'CDATE'", "bash_code": "CDATE=$" }, { "nl_command": "display all the files having the word \"searched phrasse\" in their name in the current folder excluding those from the paths \"/tmp/\" and \"./var/log\"", "bash_code": "find . -type f -name \"*searched phrasse*\" ! -path \"./tmp/*\" ! -path \"./var/log/*\"" }, { "nl_command": "Recursively finds all \"file_pattern_name\" files and folders and prints strings with \"pattern\", searching through found folders recursively.", "bash_code": "find ./ -name \"file_pattern_name\" -exec grep -r \"pattern\" {} \\;" }, { "nl_command": "Find all files/directories following symlinks under /path/to/dir/* paths and print the timestamp in YmdHMS format along with their paths", "bash_code": "find -L /path/to/dir/* -printf \"%TY%Tm%Td%TH%TM%TS|%p\\n\"" }, { "nl_command": "Recursively finds all '*.pdf' files in a current folder and removes them.", "bash_code": "find . -name \"*.pdf\" -print0 | xargs -0 rm" }, { "nl_command": "forcibly create a symbolic link named \"linkname\" to file \"new_destination\"", "bash_code": "ln -sf new_destination linkname" }, { "nl_command": "Find all files/directories that start with 'screen' (case insensitive) in their names under user's home directory tree", "bash_code": "find ~ -iname \"screen*\"" }, { "nl_command": "display all files in the current folder along with their last access timestamps", "bash_code": "find . -printf \"%h/%f : dernier acc\u00e8s le %Ac\\n\"" }, { "nl_command": "Removes first and last parts of path 'test/90_2a5/Windows' and prints the result.", "bash_code": "echo 'test/90_2a5/Windows' | xargs dirname | xargs basename" }, { "nl_command": "Search the file system for regular files whose pathnames are shorter than 25 characters", "bash_code": "find / -type f|awk -F'/' '{print $NF}'| awk 'length < 25'" }, { "nl_command": "Find all *.htm files under current directory and change their names by appending 3 levels of parent directory names at the beginning and modifying the actual name to dd-nnn format", "bash_code": "eval \"`find -type f -name \"*.htm\" |awk -F/ '{print \"cp \" $0 \" \" $2 \"-\" $3 \"-\" $4 \"-\" substr \";\" }'`\"" }, { "nl_command": "Find regular files under and below /path that match pattern \"???-???_[a-zA-Z]*_[0-9]*_*.???\"", "bash_code": "find /path -type f -name \"???-???_[a-zA-Z]*_[0-9]*_*.???\"" }, { "nl_command": "Save the physical current working directory to variable \"END_ABS\"", "bash_code": "END_ABS=`pwd -P`" }, { "nl_command": "display all the text files and pdf files in the current folder", "bash_code": "find . \\" }, { "nl_command": "Find files/directories under current directory without descending into it", "bash_code": "find -maxdepth 0" }, { "nl_command": "Find all files and directories under current directory", "bash_code": "find ." }, { "nl_command": "Edit current user's cron job list with editor specified by EDITOR environment variable, or default /usr/bin/editor if EDITOR is not set.", "bash_code": "crontab -e" }, { "nl_command": "Find all Makefile's in the current directory tree and look for line 235 in each of them", "bash_code": "find -type f -name \"Makefile\" -exec awk 'FNR==235 {print FILENAME; print}' {} +" }, { "nl_command": "Find in the current direcoty whose suffix is .tmp , find will not serach recursively limit of find is 2 subdirectory .", "bash_code": "find . -maxdepth 2 -name '*.tmp'" }, { "nl_command": "Delete all empty files in the current directory tree", "bash_code": "find . -type f -empty -delete" }, { "nl_command": "Finds recursion-related options of a 'grep' utility.", "bash_code": "grep --help |grep recursive" }, { "nl_command": "Find all files under maximum 1 level down the ./subfolder and ./subfolder/*/ paths", "bash_code": "find ./subfolder ./subfolder/*/ -maxdepth 1 -type f" }, { "nl_command": "View line 500 to line 1000 in gzipped file \"bigfile.z\"", "bash_code": "zcat bigfile.z | sed -ne '500,1000 p'" }, { "nl_command": "List non-hidden regular files in the current directory tree that were last modified more than 500 days ago", "bash_code": "find . -type f -not -name '.*' -mtime +500 -exec ls {} \\;" }, { "nl_command": "Find all files/directories with '.js' extension under current directory tree excluding paths that contain the directory './directory'", "bash_code": "find -name \"*.js\" -not -path \"./directory/*\"" }, { "nl_command": "Find all HTML files starting with letter 'a' in the current directory and below ignoring the case", "bash_code": "find . -iname a\\*.html" }, { "nl_command": "Print the contents of \"${SPOOL_FILE}\" file to the console and append to \"${LOG_FILE}\" file", "bash_code": "cat ${SPOOL_FILE} | tee -a ${LOG_FILE}" }, { "nl_command": "Remount \"/system\" as read only", "bash_code": "mount -o remount,ro /system" }, { "nl_command": "Recursively removes all files like '._*' from current folder.", "bash_code": "find . -name \"._*\" -print0 | xargs -0 rm -rf" }, { "nl_command": "Replace \"_\" with newlines in \"Testing\\r_Tested\" and display the named characters", "bash_code": "echo -e \"Testing\\r_Tested\" | awk -v RS=\"_\" '{ print $0; }' | od -a" }, { "nl_command": "Print each line in \"file\", \"file2\", and \"file3\" and replace any tabs with spaces", "bash_code": "paste file file2 file3 | sed 's/\\t/ /'" }, { "nl_command": "Find how many files are in a path", "bash_code": "find . -type f -exec basename {} \\; | wc -l" }, { "nl_command": "Find all files/directories with '.c' or '.h' extension under current directory tree and search for the regex expanded by the variable $i and show the output by paging through one screenful at a time", "bash_code": "find . -name '*.[ch]' -exec grep $i {} | less" }, { "nl_command": "Find all directories starting from YOUR_STARTING_DIRECTORY that contain the string \"99966\" in their names", "bash_code": "find YOUR_STARTING_DIRECTORY -type d -name \"*99966*\" -print" }, { "nl_command": "Find all *.log files under path/ that do not contain \"string that should not occur\"", "bash_code": "find path/ -name '*.log' -print0 | xargs -r0 grep -L \"string that should not occur\"" }, { "nl_command": "beginning at the end of the file, prints lines matching /2012/ and exits after first non-matching line", "bash_code": "tail -n `tac biglogfile | grep -vnm1 2012 | sed 's/:.*//' | xargs expr -1 +` biglogfile" }, { "nl_command": "Counts lines in each of *.php files in a current folder and subfolders and prints total count.", "bash_code": "find . -name '*.php' | awk '{gsub(\" \",\"\\\\ \", $0);print $0}' |xargs wc -l" }, { "nl_command": "find all the regular/normal files in the current folder and replace everything expect the extension of the file and display unique file extensions", "bash_code": "find . -type f | sed -e 's#.*\\(\\.[a-zA-Z]*\\)$#\\1#' | sort | uniq" }, { "nl_command": "Prints list of top-level subfolders in a current folder, sorted by number of contained files.", "bash_code": "find . -maxdepth 1 -type d -print0 | xargs -0 -I {} sh -c 'echo -e $ {}' | sort -n" }, { "nl_command": "Print the file sizes for all files under current directory", "bash_code": "find . -type f -printf '%p %s\\n' | perl -n -a -e '$sum+=$S[1]; print \"$sum\\n\"'" }, { "nl_command": "Execute \"script.awk\" on \"file\" and format the output as a table", "bash_code": "awk -f script.awk file{,} | column -t" }, { "nl_command": "Search directory /tmp/foo for files containing \"/tmp/foo/bar\" in their full names", "bash_code": "find /tmp/foo -path /tmp/foo/bar -print" }, { "nl_command": "Save the percentage of packets lost of the 5 packets sent to \"$host\" in variable \"packet_loss\"", "bash_code": "packet_loss=$(ping -c 5 -q $host | grep -oP '\\d+')" }, { "nl_command": "Print percents of the space used on the file system containing path to the current working directory.", "bash_code": "df . -B MB | tail -1 | awk {'print substr($5, 1, length($5)-1)'}" }, { "nl_command": "find all the files in the folder /path/to/dir which have been modified after a specific date (Feb 07)", "bash_code": "find /path/to/dir -newermt \u201cFeb 07\u201d" }, { "nl_command": "Filters only directories from long file listing of the current directory.", "bash_code": "ls -l | grep \"^d\"" }, { "nl_command": "Prints calendars of July, 2009 and July, 2010 side-by-side.", "bash_code": "paste <(cal 6 2009) <(cal 6 2010)" }, { "nl_command": "Find all directories under /path/to/base/dir and change their permission to 755", "bash_code": "chmod 755 $(find /path/to/base/dir -type d)" }, { "nl_command": "Add directory \"$HOME/Pictures\" to the directory stack", "bash_code": "pushd \"$HOME/Pictures\"" }, { "nl_command": "list regular file which file name is NOT end with '.html' in current directory in current directory", "bash_code": "find . -type f -not -name \"*.html\"" }, { "nl_command": "Find recursively all files matching pattern 'file??' in the xargstest/ directory and print a sorted list of them", "bash_code": "find xargstest/ -name 'file??' | sort" }, { "nl_command": "find files in $HOME ending in \"txt\" or \"html\" and case insensitive search for the word \"vpn\"", "bash_code": "find $HOME \\( -name \\*txt -o -name \\*html \\) -print0 | xargs -0 grep -li vpn" }, { "nl_command": "Replace each new line in \"INPUT.txt\" with \":\"", "bash_code": "paste -sd: INPUT.txt" }, { "nl_command": "List absolute path of files in the current directory", "bash_code": "ls -1 | xargs readlink -f" }, { "nl_command": "find all files in current folder which are exactly 300MB", "bash_code": "find . -size 300M" }, { "nl_command": "Infinitely write \"1\" with line numbers to the console and \"/tmp/to\"", "bash_code": "yes 1 | nl | tee /tmp/to" }, { "nl_command": "Find all files/directories owned by user 'michel' under current directory", "bash_code": "find -user michel" }, { "nl_command": "Sets shell options 'extglob' and 'nullglob'.", "bash_code": "shopt -s nullglob extglob" }, { "nl_command": "Copy all files in \"/mail\" to \"/home/username\" preserving the directory hierarchy and modification times", "bash_code": "find /mail -type f | cpio -pvdmB /home/username" }, { "nl_command": "Print linker search path using gcc formatted on new lines", "bash_code": "gcc -print-search-dirs | sed '/^lib/b 1;d;:1;s,/[^/.][^/]*/\\.\\./,/,;t 1;s,:[^=]*=,:;,;s,;,; ,g' | tr \\; \\\\012" }, { "nl_command": "Recursively copy local file/directory \"/copy/from/path\" to remote location \"/copy/to/path\" on host \"server\", connecting as ssh user \"user\" and using identity key file \"/path/to/your/.pemkey\" instead of the default in ~/.ssh/", "bash_code": "scp -i /path/to/your/.pemkey -r /copy/from/path user@server:/copy/to/path" }, { "nl_command": "Show all lines in file2 that don't contain the first field of any line in file1.", "bash_code": "awk '{print $1}' file2 | comm -1 -3 file1 - | join file2 -" }, { "nl_command": "find all the text files in the home directory", "bash_code": "find ~/ -name '*.txt'" }, { "nl_command": "Replace \"foo\" with \"bar\" in all files in the current directory tree except hidden ones", "bash_code": "find . -type f -not -name \u201c.*\u201d -print | xargs sed -i \u2018s/foo/bar/g\u2019" }, { "nl_command": "find all the files which have size 0 bytes in temp folder", "bash_code": "find /tmp -type f -empty" }, { "nl_command": "Print the list of regular files from the current directory tree that were modified less than 2 days ago", "bash_code": "find . -type f -mtime -2 -exec echo {} +" }, { "nl_command": "Find files that were accessed in less than a day ago", "bash_code": "find / -atime -1" }, { "nl_command": "Find all the files without permission 777 under current directory and show a few lines of output from the beginning", "bash_code": "find . -type f ! -perm 777 | head" }, { "nl_command": "recursively change owner of the directory /tmp to the current user", "bash_code": "sudo chown -R $USER ~/tmp" }, { "nl_command": "Find all .php files starting from the root directory and ignoring /media", "bash_code": "find / -name \"*.php\" -print -o -path '/media' -prune" }, { "nl_command": "Print the number of lines in file.txt.", "bash_code": "wc -l file.txt | cut -f1 -d\" \"" }, { "nl_command": "Search all files and directories either of the directory /home/oracle and /home/databse which contain the \"zip\" anywhere in the files or directory name .", "bash_code": "find /home/oracle /home/database -name '*zip*'" }, { "nl_command": "find and delete all the files in the entire file system whose size is greater than 100MB.", "bash_code": "find / -size +100M -exec rm -rf {} \\;" }, { "nl_command": "Find all *.pdf.marker files under ${INPUT_LOCATION} and move them to ${OUTPUT_LOCATION} also move any *.pdf files with the same name under current directory to ${OUTPUT_LOCATION}", "bash_code": "find ${INPUT_LOCATION}/ -name \"*.pdf.marker\" | xargs -I file mv file $(basename file .marker) ${OUTPUT_LOCATION}/." }, { "nl_command": "Delete recursively empty files named 'bad'", "bash_code": "find . -name bad -empty -delete" }, { "nl_command": "Report all C language source code files under the current directory", "bash_code": "find . -name \\*.c -print" }, { "nl_command": "Change permission to 000 of all directories named '.texturedata' under '/path/to/look/in/' directory tree", "bash_code": "find /path/to/look/in/ -type d -name '.texturedata' -exec chmod 000 {} \\; -prune" }, { "nl_command": "Print file information of the executable file of command \"g++\"", "bash_code": "ls `which g++` -al" }, { "nl_command": "Print the current working directory prepended by \"pwd: \"", "bash_code": "echo pwd: `pwd`" }, { "nl_command": "Print /some/dir/ if it's empty", "bash_code": "find /some/dir/ -maxdepth 0 -empty" }, { "nl_command": "find all the links in somedirectory and print them in a single line", "bash_code": "find \"somedir\" -type l -print0" }, { "nl_command": "file all the Sticky Bit set files whose permission are 551", "bash_code": "find / -perm 1551" }, { "nl_command": "Calculate the md5 sum of \"exampleString\"", "bash_code": "echo -n 'exampleString' | md5sum" }, { "nl_command": "Calculate the md5 sum of the output of \"du -csxb /path\" and compare it against the md5 sum saved in \"file\"", "bash_code": "du -csxb /path | md5sum -c file" }, { "nl_command": "search for all the regular/normal files in the /etc folder which have been modified in the last 24 hours", "bash_code": "find /etc/ -type f -mtime -1" }, { "nl_command": "Delete interactively all the files/directories with inode number 782263 under current directory tree", "bash_code": "find . -inum 782263 -exec rm -i {} \\;" }, { "nl_command": "Print all distinct characters in input \"He likes cats, really?\"", "bash_code": "echo \"He likes cats, really?\" | fold -w1 | sort -u" }, { "nl_command": "search for all text files in the folder /home", "bash_code": "find /home -name *.txt" }, { "nl_command": "Delete all files with indoe number $inum under current directory tree", "bash_code": "find . -inum $inum -exec rm {} \\;" }, { "nl_command": "delete all the files ending with \"~\" in current folder", "bash_code": "find -name '*~' -delete" }, { "nl_command": "Remove all regular files found in and below /path", "bash_code": "find /path -type f -print | xargs rm" }, { "nl_command": "display all the regular/normal files in current folder which have been modified exactly 60 minutes before", "bash_code": "find . -mmin 60 -type f" }, { "nl_command": "Extract protocol and host name from URL.", "bash_code": "echo \"$url\" | cut -d'/' -f1-3" }, { "nl_command": "Print groups of all users logged in", "bash_code": "groups $(who | cut -d' ' -f 1)" }, { "nl_command": "find all files in the current folder which are bigger than 10MB and less than 50 MB", "bash_code": "find . -size +10M -size -50M -print" }, { "nl_command": "Find all file names in the current directory tree that begin with \"headdump\" and write them to file `delete.txt'", "bash_code": "find . -name headdump* >delete.txt" }, { "nl_command": "Print first field from semicolon-seprated line $string.", "bash_code": "echo $string | cut -d';' -f1" }, { "nl_command": "Find all files in the current directory tree named 'FILES.EXT'", "bash_code": "find . -name \"FILES.EXT\"" }, { "nl_command": "Lists all files in a '/home/dreftymac/' folder and subfolders without recursion.", "bash_code": "ls /home/dreftymac/*" }, { "nl_command": "Installs packages 'mysql' and 'mysql-server'.", "bash_code": "yum install mysql mysql-server" }, { "nl_command": "display all the c files and the header files in the path /some/dir and do not search in sub directories", "bash_code": "find /some/dir -maxdepth 1 \\ -print" }, { "nl_command": "Find all .php files in all directory trees matching pattern `/srv/www/*/htdocs/system/application/' and search those files for string \"debug (\"", "bash_code": "find /srv/www/*/htdocs/system/application/ -name \"*.php\" -print0 | xargs -0 grep -H \"debug (\"" }, { "nl_command": "search for the file \"name_to_find\" in the home folder", "bash_code": "find ~ -name \"name_to_find\"" }, { "nl_command": "Create hard links of all files and directories matching \"test/icecream/cupcake/*\" or \"test/mtndew/livewire/*\" in \"test-keep\" preserving directory hierarchy", "bash_code": "find test -path 'test/icecream/cupcake/*' -o -path 'test/mtndew/livewire/*' | cpio -padluv test-keep" }, { "nl_command": "find the file with the name \"file\" in the entire file system", "bash_code": "find / -name file" }, { "nl_command": "show all the regular files in current folder", "bash_code": "find . -type f -print0" }, { "nl_command": "display all the tex files in the current folder", "bash_code": "find . -name \"*.tex\"" }, { "nl_command": "Print the last 10 commands in history", "bash_code": "history | tail -n 10" }, { "nl_command": "Replace all occurrences of word \"foo\" with \"bar\" in *.c and *.h files from the current directory tree", "bash_code": "find -name '*.[ch]' -exec sed -i 's/\\/bar/g' {} +" }, { "nl_command": "Save the first two letters of the system host name to variable \"DC\"", "bash_code": "DC=`hostname | cut -b1,2`" }, { "nl_command": "Join comma-separated information in 4 files - files must be sorted.", "bash_code": "join -t, test.1 test.2 | join -t, - test.3 | join -t, - test.4" }, { "nl_command": "Use \"$BYTES\" amount of RAM for \"$SECONDS\" seconds with no output", "bash_code": "cat < < | grep n" }, { "nl_command": "find the file \"httpd.log\" in the folder /home/web-server/ ( case insensitive search )", "bash_code": "find /home/web-server/ -type f -iname httpd.log" }, { "nl_command": "Create a variable FOO_BACKWARDS containing \"oof\".", "bash_code": "export FOO_BACKWARDS=$" }, { "nl_command": "Replace all instances of \"STRING_TO_REPLACE\" with \"STRING_TO_REPLACE_IT\" in \"index.html\"", "bash_code": "sed -i 's/STRING_TO_REPLACE/STRING_TO_REPLACE_IT/g' index.html" }, { "nl_command": "find the depth of all the files in current folder and display the depth and file name", "bash_code": "find folder1/ -depth -type f -printf \"%d\\t%p\\n\"" }, { "nl_command": "Read a line from standard input into variable \"password\" without echoing the input and using the prompt \"Password: \"", "bash_code": "read -s -p \"Password: \" password" }, { "nl_command": "Show all variables whose name or value contains \"PATH\", sorted in reverse alphabetical order.", "bash_code": "env | uniq | sort -r | grep PATH" }, { "nl_command": "List all variables whose name or value contains X.", "bash_code": "env | grep \".*X.*\"" }, { "nl_command": "Updates all installed software.", "bash_code": "yum update" }, { "nl_command": "Left justify number each non-blank line in \"log.txt\" as input to \"sed ...\"", "bash_code": "nl -n ln log.txt | sed ..." }, { "nl_command": "Print the names of the directories from the paths expanded by the glob pattern /path/to/directory/*", "bash_code": "find /path/to/directory/* -maxdepth 0 -type d -exec basename -a {} +" }, { "nl_command": "Find directories starting from /TBD that were modified more than 1 day ago", "bash_code": "find /TBD -mtime +1 -type d" }, { "nl_command": "Find all *.java files under current directory", "bash_code": "find . -name \"*.java\"" }, { "nl_command": "Print full path of command \"gradle\"", "bash_code": "which gradle" }, { "nl_command": "Write every two lines in \"infile\" on a single line separated by a comma", "bash_code": "cat infile | paste -sd ',\\n'" }, { "nl_command": "Enables shell options 'nullglob' and 'dotglob'.", "bash_code": "shopt -s nullglob dotglob" }, { "nl_command": "Ping all hosts in file \"ips\" twice", "bash_code": "cat ips | xargs -n1 ping -c 2" }, { "nl_command": "Find all *.c files under and below the current directory that contain \"wait_event_interruptible\"", "bash_code": "find . -name \\*.c -exec grep wait_event_interruptible {} /dev/null \\;" }, { "nl_command": "create a cpio archive of the entire contents the current directory while preserving the permissions, times, and ownership of every file and sub-directory", "bash_code": "find . -depth -print | cpio -o -O /target/directory" }, { "nl_command": "Find files on the system that are bigger than 20 megabytes", "bash_code": "find / -type f -size +20M -exec ls -lh {} \\; | awk '{ print $NF \": \" $5 }'" }, { "nl_command": "Find all files/directories named 'file1' under current directory tree", "bash_code": "find . -name file1 -print" }, { "nl_command": "copy all the log files in the current folder which have not been accessed in the last 30*24 hours to the folder old", "bash_code": "find . -type f -mtime +30 -name \"*.log\" -exec cp {} old \\;" }, { "nl_command": "list regular files under the current directory", "bash_code": "find . -type f" }, { "nl_command": "Print pathnames of all files in the current directory and below skipping directories named SCCS and files in them", "bash_code": "find . -name SCCS -prune -o -print" }, { "nl_command": "Compare files in \"/tmp/dir1\" and \"/tmp/dir2\", treat absent files as empty and all files as text, and print 3 lines of unified context", "bash_code": "diff -Naur dir1/ dir2" }, { "nl_command": "Print the last file extension from standard input", "bash_code": "sed 's/^/./' | rev | cut -d. -f1 | rev" }, { "nl_command": "Copies all files under the current directory like any-cased '*foobar*' to the '~/foo/bar' directory.", "bash_code": "find . -iname \"*foobar*\" -exec cp \"{}\" ~/foo/bar \\;" }, { "nl_command": "Assign the alias rmc to a find command that deletes all core dump files in the currenty directory and below.", "bash_code": "alias rmc=\"find . -iname core -exec rm {} \\;\"" }, { "nl_command": "Prints calendar of February, 1900.", "bash_code": "cal 2 1900" }, { "nl_command": "delete all the files which start with \"Tes\" in the current folder", "bash_code": "find . -type f -name \"Tes*\" -exec rm {} \\;" }, { "nl_command": "Gets IP address of 'eth0' network interface.", "bash_code": "ifconfig eth0 | awk '/inet addr/{sub(/[^0-9]*/,\"\"); print $1}'" }, { "nl_command": "create a symbolic link named \"/usr/lib/jvm/default-java\" to file \"/usr/lib/jvm/java-7-oracle\"", "bash_code": "sudo ln -s /usr/lib/jvm/java-7-oracle /usr/lib/jvm/default-java" }, { "nl_command": "Display only first and second dot-separated numbers of kernel version, ie. 4.4", "bash_code": "uname -r | cut -d. -f1-2" }, { "nl_command": "Calculate the sum of all the numbers from -5 to 10", "bash_code": "seq -5 10 | xargs printf \"- - %s\" | xargs | bc" }, { "nl_command": "List all *.txt files/directories under current directory ensuring white space safety", "bash_code": "find . -name '*.txt' -print0|xargs -0 -n 1 echo" }, { "nl_command": "Find files and directories that are at least seven levels of nesting in the directory /usr/src excluding CVS directory", "bash_code": "find /usr/src -name CVS -prune -o -depth +6 -print" }, { "nl_command": "display all shell scripts in current folder", "bash_code": "find . -name \"*.sh\"" }, { "nl_command": "find all class files or sh script files in the current folder", "bash_code": "find . -type f \\( -name \"*.class\" -o -name \"*.sh\" \\)" }, { "nl_command": "Find links to file path/to/foo.txt", "bash_code": "find -L / -samefile path/to/foo.txt" }, { "nl_command": "Find all regular files that reside in the current directory tree and were last modified 1 day ago", "bash_code": "find . -type f -mtime 0" }, { "nl_command": "Create intermediate directories \"full\", \"path\" as required and directory \"to\"", "bash_code": "mkdir -p `dirname /full/path/to/file.txt`" }, { "nl_command": "find regular files whose filename is \"your_pattern\" and display the total size of the files in human readable format.", "bash_code": "find . -type f -name \"your_pattern\" -exec du -ch {} + 2>/dev/null | grep total$." }, { "nl_command": "Exchanges the top two directories in the dirs stack.", "bash_code": "pushd" }, { "nl_command": "Display system information: kernel name, hostname, kernel release and version, machine architecture, processor type, hardware platform, and operating system type.", "bash_code": "uname -a" }, { "nl_command": "Create tar archive \"dirall.tar\" and copy all files from directory tree /tmp/a1 to it", "bash_code": "find /tmp/a1 -exec tar -rvf dirall.tar {} \\;" }, { "nl_command": "Delete all files named \"filename\" in the current directory tree, except the one with path ./path/to/filename", "bash_code": "find . -name \"filename\" -and -not -path \"./path/to/filename\" -delete" }, { "nl_command": "find all files in current folder which are bigger than 1 MB and move them to another folder", "bash_code": "find . -size +1M -print0 | xargs -0 -I '{}' mv '{}' files" }, { "nl_command": "Find all files which begin with 'a' or 'b' from current directory downwards and print them.", "bash_code": "find . -name [ab]* -print" }, { "nl_command": "Lists available updates for installed packages.", "bash_code": "yum check-update | awk 'p; /Updated packages/ {p=1}'" }, { "nl_command": "Recursively removes all files like '*.pyc' in a current folder.", "bash_code": "find . -name '*.pyc' -print0 | xargs -0 rm" }, { "nl_command": "Set 444 permission to all regular files under current directory", "bash_code": "find . -type f -print | xargs chmod 444" }, { "nl_command": "Remove all \"core\" files that were last changed more than 4 days ago from the current directory tree", "bash_code": "find . -name core -ctime +4 -exec /bin/rm -f {} \\;" }, { "nl_command": "List the last entry of the numerically sorted list of all files and folders under \"/foldername\"", "bash_code": "find /foldername | sort -n | tail -1" }, { "nl_command": "Find all the regular files under $DIR directory tree which have been modified before the file $a excluding the file $a and delete them", "bash_code": "find \"$DIR\" -type f \\! -newer \"$a\" \\! -samefile \"$a\" -delete" }, { "nl_command": "Find all empty files in your home directory and its sub-directories.", "bash_code": "find ~ -empty" }, { "nl_command": "Find files on the system that are bigger than 20 megabytes and show the sorted list of their filenames", "bash_code": "find / -type f -size +20M -exec ls -lh {} \\; 2> /dev/null | awk '{ print $NF \": \" $5 }' | sort -nk 2,2" }, { "nl_command": "Execute \"ls -l data.temp\" every 2 seconds", "bash_code": "watch ls -l data.temp" }, { "nl_command": "Find all files/directories in entire file system that are owned by \"syslog\" user", "bash_code": "find / -user syslog" }, { "nl_command": "search for files that are readable for everybody, have at least on write bit set but are not executable for anybody", "bash_code": "find . -perm -444 -perm /222 ! -perm /111" }, { "nl_command": "Create intermediate directories \"tmp\" as required and directories real_dir1 and real_dir2", "bash_code": "mkdir -p tmp/real_dir1 tmp/real_dir2" }, { "nl_command": "Create an empty file called \"emptyfile.c\"", "bash_code": "cp /dev/null emptyfile.c" }, { "nl_command": "Find all regular files under $dir", "bash_code": "find $dir -type f" }, { "nl_command": "Find all directories under /path/to/dir and change their permission to 755", "bash_code": "find /path/to/dir -type d -exec chmod 755 {} +" }, { "nl_command": "find all the links that have been modified on a specific day and copy them to another directory", "bash_code": "find . -type l -daystart -mtime $date_dif -exec copy_it.sh $verbose -s {} -t $to_dir \\;" }, { "nl_command": "Search the current directory recursively for regular files last accessed more than 2 minutes ago", "bash_code": "find . type -f -amin +2" }, { "nl_command": "Move all files and directories in the current directory to \"/tmp/blah/\"", "bash_code": "find . -depth=1 -exec mv {} /tmp/blah/ \\;" }, { "nl_command": "Check all .txt files whose names may contain spaces whether they contain \"needle\"", "bash_code": "find . -type f -iname \"*.txt\" -print0 | xargs -0 grep \"needle\"" }, { "nl_command": "Returns 0 if user $1 belongs to group $2.", "bash_code": "groups $1 | grep -q \"\\b$2\\b\"" }, { "nl_command": "Removes all files but 5 newest ones from current folder.", "bash_code": "ls -tp | grep -v '/$' | tail -n +6 | xargs -I {} rm -- {}" }, { "nl_command": "Removes all empty folders under '/path/to/the/folder' path.", "bash_code": "find /path/to/the/folder -depth -type d -print0 | xargs -0 rmdir" }, { "nl_command": "Calculate md5 sum of empty string", "bash_code": "echo -n | md5sum" }, { "nl_command": "Check md5sum of directory /path against the checksum saved in file 'file'", "bash_code": "du -csxb /path | md5sum -c file" }, { "nl_command": "Find the first file/directory named 'something' under current directory and quit", "bash_code": "find . -name something -print -quit" }, { "nl_command": "change the owner and group of all the directories in the current folder and /home/admin/data/ to admin & admin", "bash_code": "find . /home/admin/data/ -type d -exec chown admin.admin {} \\;" }, { "nl_command": "find from / a file called 'toBeSearched.file', redirecting error messages to the output and filtering any lines containing the text \"Permission denied\"", "bash_code": "find /. -name 'toBeSearched.file' 2>&1 | grep -v 'Permission denied'" }, { "nl_command": "Find files modified between 6 and 9 minutes ago", "bash_code": "find . -mmin +5 -mmin -10" }, { "nl_command": "Prints names of all configured software repositories.", "bash_code": "yum repolist | tail -n +3 | grep -v 'repolist:' | cut -f1 -d' '" }, { "nl_command": "Compress all files in directory \"$PATH_TO_LOGS\" that were last modified more than \"$SOME_NUMBER_OF_DAYS\" days ago", "bash_code": "find $PATH_TO_LOGS -maxdepth 1 -mtime +$SOME_NUMBER_OF_DAYS -exec gzip -N {} \\;" }, { "nl_command": "Print variable \"$module\" in formatted columns with at most 80 characters per line", "bash_code": "echo $modules | column -t | fold | column -t" }, { "nl_command": "Search the *.txt files from the current directory tree for \"string\"", "bash_code": "find . -name \"*.txt\" -print0 | xargs -0 egrep 'string'" }, { "nl_command": "Search the /home/www directory tree for regular files", "bash_code": "find /home/www -type f" }, { "nl_command": "run command \"dnf install glibc.i686\" as user root", "bash_code": "su -c dnf install glibc.i686" }, { "nl_command": "Find and delete the file with inode number 1316256", "bash_code": "find ./ -inum 1316256 -delete" }, { "nl_command": "find all files in the file system whose size is bigger than 3GB", "bash_code": "find / -size +3G" }, { "nl_command": "Search the /dir directory tree for files whose names match regular expression '2015.*(album|picture)'", "bash_code": "find /dir|egrep '2015.*(album|picture)'" }, { "nl_command": "Updates all packages in system answering 'yes' on all questions.", "bash_code": "yum -y update" }, { "nl_command": "Find *.pl files/directories under /users/tom", "bash_code": "find /users/tom -name \"*.pl\"" }, { "nl_command": "Print a list of all duplicate case insensitive file paths in the current directory tree", "bash_code": "find . | sort -f | uniq -i -d" }, { "nl_command": "Find all regular files under /home/www and replace every occurrences of 'subdomainA' with 'subdomainB' in those files (may produce 'agument too long' error)", "bash_code": "sed -i '' -e 's/subdomainA/subdomainB/g' $(find /home/www/ -type f)" }, { "nl_command": "List *.txt files residing in the current directory tree", "bash_code": "find . -name *.txt -exec ls {} ;\\" }, { "nl_command": "Prints top-ten biggest top-level folders within a 'var' folder.", "bash_code": "sudo du -hDaxd1 /var | sort -h | tail -n10" }, { "nl_command": "Output the base name of first argument to script or function, that is the part following the last slash.", "bash_code": "echo $(basename \"$1\")" }, { "nl_command": "Print the sizes and names of all TXT files from the current directory tree", "bash_code": "find . -iname \"*.txt\" -exec du -b {} +" }, { "nl_command": "Print package information the command \"ldconfig\" belongs to in rpm", "bash_code": "rpm -qfi `which ldconfig`" }, { "nl_command": "Find suspicious PHP files", "bash_code": "find . -type f -name \"*.php\" -exec grep --with-filename \"eval(\\|exec(\\|base64_decode(\" {} \\;" }, { "nl_command": "Set permissions for directories in `foldername' and its subdirectories to 755", "bash_code": "find foldername -type d -exec chmod 755 {} \";\"" }, { "nl_command": "Filters only directories from long file listing of the current directory", "bash_code": "ls -l --color=always \"$@\" | grep --color=never '^d'" }, { "nl_command": "Delete files under $LOCATION that match $REQUIRED_FILES in their names and were modified more than 1 day ago", "bash_code": "find $LOCATION -name $REQUIRED_FILES -type f -mtime +1 -delete" }, { "nl_command": "forcible create a symbolic link named \"/etc/file.conf\" to file \"/etc/configuration/file.conf\"", "bash_code": "ln -fs /etc/configuration/file.conf /etc/file.conf" }, { "nl_command": "Listen on port 1234 on root@123.123.123.123 and forward it to port 22 on localhost", "bash_code": "ssh -fNR 1234:localhost:22 root@123.123.123.123" }, { "nl_command": "Go into the first directory whose name contains 1670", "bash_code": "cd $(ls -d */ | grep 1670)" }, { "nl_command": "search for all C, C++, Header, JavaScript files in the folder /opt/chromium/src and exclude the search in the path \"/.svn\" and save the output list to CSRC.LST", "bash_code": "find /opt/chromium/src -wholename '*/.svn' -prune -o -type f -regex \".*\\.\\\" -print > CSRC.LST" }, { "nl_command": "Recursively compress every file in the current directory tree and keep the original file", "bash_code": "gzip -kr ." }, { "nl_command": "Find all files/directories in entire file system less than 50 bytes", "bash_code": "find / -size -50c" }, { "nl_command": "Read a line from standard input into variable \"REPLY\" with prompt \"Press [Enter] key to release lock...\"", "bash_code": "read -p \"Press [Enter] key to release lock...\"" }, { "nl_command": "Read a line from standard input into variable \"REPLY\" with prompt \"> $line (Press Enter to continue)\"", "bash_code": "read -p \"> $line (Press Enter to continue)\"" }, { "nl_command": "Delete all regular files that start with 'sess_' in their names, are at least 1 level deep and were modified more than $gc_maxlifetime minutes ago under $save_path directory tree", "bash_code": "find -O3 \"$save_path\" -depth -mindepth 1 -name 'sess_*' -ignore_readdir_race -type f -cmin \"+$gc_maxlifetime\" -delete" }, { "nl_command": "run a somebashstatement with the filename as argument, inside a for loop that iterates over a number of filenames found recursively in /path that match 'pattern'", "bash_code": "find /path -name 'pattern' -exec bash -c 'for file; do somebashstatement \"$file\"; done' -- {} +" }, { "nl_command": "Merge each line of standard input into a single comma separated line", "bash_code": "paste -s -d\",\"" }, { "nl_command": "Prints long listing of top ten most memory using processes in a system.", "bash_code": "ps -e -orss=,args= | sort -nr | head" }, { "nl_command": "Delete all directories under '.cache/chromium/Default/Cache' directory tree that are at least 1 level deep and are bigger than 100 MB in size", "bash_code": "find .cache/chromium/Default/Cache/ -mindepth 1 -type d -size +100M -delete" }, { "nl_command": "search for the files in the current folder which begin with the word \"kt\" followed by a digit", "bash_code": "find . -name 'kt[0-9] '" }, { "nl_command": "Find the top 5 small files", "bash_code": "find . -type f -exec ls -s {} \\; | sort -n | head -5" }, { "nl_command": "find all the pdf files in the current directory and display only the directory name in which the pdf file is present", "bash_code": "find . -type f -name '*.pdf' |sed 's#\\(.*\\)/.*#\\1#' |sort -u" }, { "nl_command": "Find all regular .html files in the /var/www directory tree", "bash_code": "find /var/www -type f -name \"*.html\"" }, { "nl_command": "find .gif files in /var/www and below that were last changed between 90 and 180 days ago", "bash_code": "find /var/www -name *.gif -ctime +90 -ctime -180" }, { "nl_command": "Change to folder where the oracle binary is.", "bash_code": "cd \"$(dirname \"$(which oracle)\")\"" }, { "nl_command": "Uncompress file \"dbdump.sql.gz\" through standard input and pass to \"mysql\"", "bash_code": "cat dbdump.sql.gz | gzip -cd | mysql" }, { "nl_command": "Convert the content of variable 'CLEAN' to small letters", "bash_code": "CLEAN=`echo -n $CLEAN | tr A-Z a-z`" }, { "nl_command": "display all the files in the current folder which start with either \"fileA_\" or \"fileB_\"", "bash_code": "find . -name 'fileA_*' -o -name 'fileB_*'" }, { "nl_command": "find files in the users home directory and for each one, ask the user to confirm to delete the file.", "bash_code": "find $HOME/. -name *.txt -ok rm {} \\;" }, { "nl_command": "Copy all files matching \"*failed.ipynb\" in the current directory tree to \"./fails\" preserving the directory hierarchy", "bash_code": "find . -name \"*failed.ipynb\" | cpio -pd ./fails" }, { "nl_command": "Search the home directory tree for files last modified more than a year ago", "bash_code": "find $HOME -mtime +365" }, { "nl_command": "Split the contents of all \".txt\" excluding the first 1000 lines into files of at most 1000 lines each", "bash_code": "cat *.txt | tail -n +1001 | split --lines=1000" }, { "nl_command": "Print $d if $d is an empty directory", "bash_code": "find \"$d\" -prune -empty -type d" }, { "nl_command": "Get the total sizes of all files under current directory", "bash_code": "find . -type f -printf '%p %s\\n' | perl -ane '$sum+=$F[1];END{print \"$sum\\n\"}'" }, { "nl_command": "display all the html files in the current folder excluding search in the paths ./foo, ./bar.", "bash_code": "find . -path \"./foo\" -prune -o -path \"./bar\" -prune -o -type f -name \"*.html\"" }, { "nl_command": "Find all *.xml.bz2 files under current directory", "bash_code": "find . | grep \".xml.bz2$\"" }, { "nl_command": "change the group to \"new_group\" and permissions to 770 for all the files in the current folder", "bash_code": "find . -name \"*\" \\( -exec chgrp -v new_group {} \\; -o -exec chmod -v 770 {} \\; \\)" }, { "nl_command": "display all the directories in the current folder excluding those that have the name \"node_modules\"", "bash_code": "find . ! -name \"node_modules\" -type d" }, { "nl_command": "Shows state of 'extglob' shell option.", "bash_code": "shopt -o extglob" }, { "nl_command": "Remove the last file extension from standard input", "bash_code": "sed 's/^/./' | rev | cut -d. -f2- | rev | cut -c2-" }, { "nl_command": "Rename all files under current directory by formatting the filenames with the sed scripts '\\''s/^-\\s*/\\L\\1\\E-\\2/'\\'', '\\''s/ /_/g'\\'' and '\\''s/_-/-/g'\\''", "bash_code": "find ./ -type f -exec bash -c 'mv \"$1\" \"$(echo \"$1\" | sed -re '\\''s/^-\\s*/\\L\\1\\E-\\2/'\\'' -e '\\''s/ /_/g'\\'' -e '\\''s/_-/-/g'\\'')\"' - {} \\;" }, { "nl_command": "Print the sizes of all files from the current directory tree", "bash_code": "find . -iname '*.jpg' -type f -printf +%b" }, { "nl_command": "find all the files that have been modified exactly 1 day ago", "bash_code": "find -mtime 1" }, { "nl_command": "display all the regular/normal files in current folder", "bash_code": "find . -type f -name \\*" }, { "nl_command": "Print the list of all regular files from the current directory tree that contain \"confirm\", case insensitive", "bash_code": "find . -type f -exec grep -il confirm {} \\;" }, { "nl_command": "Find all broken symlinks in maximum 1 level down the $path directory", "bash_code": "find -L $path -maxdepth 1 -type l" }, { "nl_command": "List file information of the full path of command \"c++\"", "bash_code": "ls -ald `which c++`" }, { "nl_command": "Use awk command 'FNR==NR { array[$1,$2]=$8; next } ($1,$2) in array { print $0 \";\" array[$1,$2] }' on compressed files \"input1.vcf.gz\" and \"input2.vcf.gz\"", "bash_code": "gzip -dc input1.vcf.gz input2.vcf.gz | awk 'FNR==NR { array[$1,$2]=$8; next } ($1,$2) in array { print $0 \";\" array[$1,$2] }'" }, { "nl_command": "List the names of all file.ext files/directories under present working directory", "bash_code": "find `pwd` -name \"file.ext\" -printf \"%f\\n\"" }, { "nl_command": "Find all files called \"file1.txt\" that reside under and below /home/wsuNID/", "bash_code": "find /home/wsuNID/ -name file1.txt" } ]