nl_command
stringlengths 14
387
| bash_code
stringlengths 0
532
|
---|---|
Find all files in current directory and search for 'searchName' in those files | find ./ -name "*" | xargs grep "searchName" |
Find all files named 'file' in 1 level down the current directory whose status were changed more than 1 hour ago | find . -maxdepth 1 -cmin +60 -name file |
Print shared object dependencies of command "YOURAPPNAME" | ldd $ |
Find all php files under current directory and delete empty lines from the beginning in those files | find ./ -name "*.php" -type f | xargs sed -i '/./,$!d' 2>&1 |
Print summary of new/missing files, and which files differ between dir1 and dir2. | diff -q dir1 dir2 |
Find all test2.h files under current directory | sudo find . -name test2.h |
find all the backup files in the current folder and delete them | find . -type f -name “FILE-TO-FIND” -delete; |
Search the files residing in the current directory tree whose names contain "bills" for "put" | find . -name '*bills*' -exec grep put {} \; |
Print each line in "file1" and file2" separated by a space | paste -d'¤' file1 file2 | sed 's,¤, ,g' |
find the type of all the regular/normal files in the current folder | find . -type f -exec file {} \+; |
Search case insensitively for 'facebook', 'xing', 'linkedin', ''googleplus' in file 'access-log.txt', extract the matched part, sort them and print them by sorting them in asending order of the number of repeated lines | grep -ioh "facebook\|xing\|linkedin\|googleplus" access-log.txt | sort | uniq -c | sort -n |
search for all pdf files in the folder "/home/pdf" which have been accessed in the last 60*24 hours | find /home/you -iname "*.pdf" -atime -60 -type -f |
Change permission to 755 of all files/directories under current directory tree that have 777 permission | find -perm 777 | xargs -I@ sudo chmod 755 '@' |
Make directory "alpha_real" | mkdir alpha_real |
recursively finds all files newer than a date | find . -type f -newermt "$(date '+%Y-%m-%d %H:%M:%S' -d @1494500000)" |
Find all the files which were modified more than 50 days but less than 100 days ago | find / -mtime +50 -mtime -100 |
SSH with trusted X11 forwarding into "user@remoteToRemote_IP" from SSH connection "user@remote_IP" | ssh -XY -t user@remote_IP 'ssh -XY -t user@remoteToRemote_IP' |
find all the files in the current folder which are smaller than 9MB | find . -size -9k |
Copy all regular files from the current directory tree to /tmp/ | find . -type f -exec sh -c 'cp "$@" /tmp' {} + |
remove all the core files in the temp file after user confirmation | find /tmp -name core -type f -print0 | xargs -0 /bin/rm -i |
Rename file "edited_blah.tmp" to "/etc/blah" | sudo mv edited_blah.tmp /etc/blah |
Find all files under and below /dir that were changed or created less than 60 minutes ago | find /dir -cmin -60 |
Locate all `readme.txt' files under the home directory | find ~ -name readme.txt |
Find and remove the .rhosts file in the /home directory tree | find /home -name .rhosts -print0 | xargs -0 rm |
Print 'file' content, formatting output as 29-symbol wide column | cat file | fold -w29 |
Find all .less files in the current directory tree | find . -name *.less |
Print the files under current directory twice per line | find . -type f -exec echo {} {} \; |
Print all matching commands in $PATH for command "python" | which -a python |
Removes all files but 5 newest ones from current folder. | ls -tp | grep -v '/$' | tail -n +6 | xargs -I {} rm -- {} |
Find all *.rb (regular) files under current directory ensuring white space safety and print at most two file names/paths per line | find . -name "*.rb" -type f -print0 | xargs -0 -n 2 echo |
Rename all "thumbs" directories to "thumb" in the current directory tree | find . -type d | awk -F'/' '{print NF, $0}' | sort -k 1 -n -r | awk '{print $2}' | sed 'p;s/\thumbs/\1thumb/' | xargs -n2 mv |
Merge lines whose first comma-separated field in file 'in1' also appears as a first comma-separated in file 'in2' - both files must be sorted, and the output format of each line will be: first field of in1, second field of in2, and third field of in2. | join -t, -o 1.1,1.2,2.3 in1 in2 |
Find all regular .abc files under and below /the/path and rename them prefixing their names with "version_1" | find /the/path -type f -name '*.abc' -execdir rename 's/\.\/\.abc$/version1_$1.abc/' {} \; |
Count files accessed more than a month ago | find . -atime +30 -exec ls \; | wc -l |
Find all .sh files in the current directory tree and remove them | find . -name "*.sh" -print0 | xargs -0 rm -rf |
Copy all regular files from the current directory tree to directory `TARGET' | find . -type f -exec cp -t TARGET {} \+ |
Find all files that belong to group developer | find /home -group developer |
List directories in the current working directory and remove the trailing "/" | ls -1p | grep '/$' | sed 's/\/$//' |
Run the sh "for" construct in a subshell - the subshell is immune to SIGHUP signals sent to it, and the output is redirected to "output.txt". | nohup sh -c 'for i in mydir/*.fasta; do ./myscript.sh "$i"; done >output.txt' & |
Remove all files from the current directory tree whose names do not match regular expression "excluded files criteria" | find . | grep -v "excluded files criteria" | xargs rm |
Search all files from the /tmp directory tree for the string "search string" | find /tmp -type f -exec grep 'search string' '{}' /dev/null \+ |
Calculate md5 checksum of the list of all files/dirs in /path recursively including dot files and excluding the patterns 'run', 'sys', 'tmp' and 'proc', then check the checksum against the checksum saved in /tmp/file | ls -alR -I dev -I run -I sys -I tmp -I proc /path | md5sum -c /tmp/file |
Search the system for the regular file 'myfile' ignoring permission denied errors | find / -name myfile -type f -print 2> /dev/null |
Print list of all user names who are logged in | who | awk '{ print $1 }' |
search for a cpp directory in current folder and display all its files | find . -type d -name "cpp" -exec find {} -type f \; |
Find all directories under current directory and make them read, write, and executable for owner & group and remove read-write-execute permission for other | find . -type d -name files -exec chmod ug+rwx,o-rwx {} \; |
Delete all contents form the files that contain the case insensitive regex 'stringtofind' in maximum 1 level down the / directory excluding other partitions | find / -maxdepth 1 -xdev -type f -exec grep -i "stringtofind" -l {} \; -exec sed -i '/./d' {} \; |
Create intermediate directories foo and bar as required and directory foo/bar/baz | mkdir -p foo/bar/baz |
Find files/directories that does not have write permssion for group or others | find /path ! -perm -022 |
Print "new.txt" with line numbers prepended and line 2 or any line containing "2" deleted | cat new.txt | nl | sed "/2/d" |
Find all directories under the current directory that is on the same filesystem, execute "/tmp/count_em_$$" with the directory as an argument, sort the result numerically from least value to greatest value | find . -mount -type d -print0 | xargs -0 -n1 /tmp/count_em_$$ | sort -n |
Make all regular files in the current directory tree world-readable | find . -type f -print0 | xargs -0 chmod go+r |
Find all 777 permission directories and use chmod command to set permissions to 755 | find . -type d -perm 777 -print -exec chmod 755 {} \; |
List all files in entire file system that belong to the user wnj or modified later than the ttt file | find / \ -print |
Find *.html files in the current directory tree that were modified less than 7 days ago | find . -mtime -7 -name "*.html" -print |
Look for directory `Cookbook' | find -name Cookbook -type d |
Find all files in the current directory tree except .html, ignoring .svn directories | find . \ -prune -o -print0 |
List the unique file extensions of all files under the current directory | find . -type f | grep -o -E '\.[^\.]+$' | sort -u |
find all text files in current folder and trim the extra spaces in all lines in these files | find . -iname '*.txt' -type f -exec sed -i '' 's/[[:space:]]\{1,\}$//' {} \+ |
Find all duplicate ".jar" files in the current directory tree | find . -type f -printf "%f\n" -name "*.jar" | sort -f | uniq -i -d |
Print which files differ in "folder1" and "folder2" excluding "node_modules" recursively, output in two columns, and paginate the output | diff -rqyl folder1 folder2 --exclude=node_modules |
Find all files/directories named 'test' under current directory tree | find . -name test |
find all the files which start with the name "Metallica" in the folder "/mp3-collection" and which are bigger than 10MB | find /mp3-collection -name 'Metallica*' -and -size +10000k |
set alias "c1" for command "awk '{print \$1}'" | alias c1="awk '{print \$1}'" |
find all regular file and create jw-htmlfiles.tar | find . -type f -name "*html" | xargs tar cvf jw-htmlfiles.tar - |
Search for files/directories which are writable by somebody | find . -perm /222 |
Find all files/directories named 'myfile' under your home directory | find ~ -name myfile |
Make directories "bravo_dir" and "alpha_dir" | mkdir bravo_dir alpha_dir |
Print file information of the executable file of command "g++" | ls `which g++` -al |
Print yesterday's date information in "%a %d/%m/%Y" format | date -d "-1 days" +"%a %d/%m/%Y" |
Find all files/directories that start with 'screen' in their names under user's home directory tree and show them by paging through one screenful at a time | find ~ -iname "screen*" | more |
Search the current directory recursively for files with the exact permissions u=rwx,g=rx,o=rx | find . -perm a=rwx,g-w,o-w |
Count the number of directories under directory '/directory/' non-recursively | find /directory/ -maxdepth 1 -type d -print| wc -l |
display all the files in the current folder which have been accessed in the last 60 minutes | find . -amin -60 |
Search /tmp/ for files smaller than 100 bytes | find /tmp -size -100c |
Print unique lines of sorted file "file1" when compared with the list of first space separated fields of all sorted strings of file "file2" | cut -d' ' -f1 file2 | comm -13 - file1 |
Find regular files under / that contain "string" and clear out their contents, including newlines | find / -maxdepth 1 -xdev -type f|xargs grep -l 'string'| xargs perl -pi -e 's/.*\n//g' |
Filters out all comment lines from /etc/launchd.conf and pipes the output to launchctl. | egrep -v '^\s*#' /etc/launchd.conf | launchctl |
Discard the first letter from every line in $line and calculate the md5 sum of the remaining | echo $line | cut -c2- | md5sum |
Find all files named "filename" in the current directory tree, not descending into "FOLDER1" directories | find . '(' -name FOLDER1 -prune -o -name filename ')' -print |
Print out all files with their paths that have identical content and the same filename in different cases | find * -type f | xargs md5sum | sort | uniq -Dw32 | awk -F'[ /]' '{ print $NF }' | sort -f | uniq -Di |
Make directories "foo/bar/baz" as needed and do not cause an error if it exists | mkdir -p foo/bar/baz |
Display operating system type, ie. GNU/Linux | uname -o |
Make directories to "x/p/q" as needed | mkdir -p x/p/q |
find all the perl files in the current folder, print0 is used to handle files with new lines in their names or only spaces | find . -type f -name "*.pl" -print0 |
Find regular files in the current directory tree that have executable bits set for the user and group but not for the other | find -L . -type f -perm -u=x,g=x \! -perm -o=x |
Move each of the 'm?' directories in current directory 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 | find . -name 'm?' -type d -exec mv '{}' '{}.mbox' ';' -exec mkdir '{}.mbox/Messages' ';' -exec sh -c 'mv {}.mbox/*.emlx {}.mbox/Messages' ';' |
Find all xml files under current directory | find . -name '*.xml' |
display all the c files and the header files in the path /some/dir and do not search in sub directories | find /some/dir -maxdepth 1 \( -name '*.c' -o -name '*.h' \) -print |
Set the shell prompt to "host:pwd>" | PS1=`hostname`':\W> ' |
find all the files in the current directory with the name "wagoneer" which are in the current device. | find . -xdev -name "wagoneer*" -print |
Remove trailing whitespaces in .txt files from the current directory tree | find . -type f -name '*.txt' -exec sed --in-place 's/[[:space:]]\+$//' {} \+ |
search files in the folder /home which have been modified after /tmp/after and before /tmp/before | find /home/ -type f -newer /tmp/after -not -newer /tmp/before |
Remove all empty files in /tmp/ and below | find /tmp -type f -empty -print | xargs rm -f |
Remove all *bak files under current directory with confirmation prompt | find . -name '*bak' -exec rm -i {} \; |
Recursively change the owner and group of "~/.ssh/" to "dev_user" | chown "dev_user"."dev_user" -R ~/.ssh/ |
Find files ending in "config" | find . -path '*/*config' |
Find all files in "/home/" which contain "string1", "string2" or the host name in its filename | find /home/ -type f -regextype posix-extended -regex ".*(string1|string2|$).*" |
Search all PDFs from the current directory tree for "keyword", ignoring the case | find . -iname '*.pdf' -exec pdfgrep -i keyword {} + |
search for files having python in filename | find / -iname '*python*' |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.