nl_command
stringlengths 14
387
| bash_code
stringlengths 0
532
|
---|---|
Find all files beneath the current directory that end with the extension .java and contain the characters String ignoring case. Print the name of the file where a match is found. | find . -type f -name "*.java" -exec grep -il string {} \; |
Print the full path directory name of each "file.ext" found under the current directory | find . -name "file.ext" -execdir pwd ';' |
Concatenate all files under the current directory and below that contain "test" in their names | find . -iname '*test*' -exec cat {} \; |
Recursively lists all *.py and *.html files in a current folder. | ls **/*.py **/*.html |
Move all files in "/path/subfolder" to "/path" without clobbering any destination files | find /path/subfolder -maxdepth 1 -type f -name '*' -exec mv -n {} /path \; |
Find all regular files under '/home/john' directory tree that start with 'landof' in their names | find /home/john -name "landof*" -type f -print |
Force the group stickiness for directories under /var/www | find /var/www -type d -print0 | xargs -0 chmod g+s |
create backup of all the text files present in the current folder | find -name "*.txt" cp {} {}.bkup \; |
display all the text files in the current folder except readme files | find . -type f -name "*.txt" ! -name README.txt -print |
Find all first occurrences of directories named '.texturedata' under '/path/to/look/in' directory tree | find /path/to/look/in/ -type d -name '.texturedata' -prune |
List all cron jobs for current user. | crontab -l |
Print unique lines of sorted file "a" compared with sorted file "b" | comm -23 a b |
Save Maven project version to variable "version" | version=$ |
Search the current directory tree for .rb files ignoring .vendor directories | find . -name .vendor -prune -o -name '*.rb' -print |
Find all .gz archives in the /path/to/dir directory tree | find /path/to/dir -name "*.gz" -type f |
Forward port 8000 bound on localhost to port 22 in 'clusternode' via 'user@bridge' | ssh -L localhost:8000:clusternode:22 user@bridge |
Enables shell option 'failglob'. | shopt -s failglob |
Find all empty files under /tmp and below | find /tmp -type f -empty |
Print last four bytes of string '0a.00.1 usb controller some text device 4dc9' | echo 0a.00.1 usb controller some text device 4dc9 | rev | cut -b1-4 | rev |
Save hexadecimal byte 10 in binary file "file.moi" to variable "day" | day=$ |
Find all files/directories under '/usr/local/games' directory tree that contain the string 'xpilot' in their names | find /usr/local/games -name "*xpilot*" |
List .conf files residing in the /etc/nginx/ directory tree | find /etc/nginx -name '*.conf' -exec echo {} ; |
Search the current user's home directory and its sub-directories for any files accessed after alldata.tar was last accessed and add them to that same tar archive. | find ~/ -newer alldata.tar -exec tar uvf alldata.tar {} \; |
Find all regular files in the current directory and search them for "example" | find -maxdepth 1 -type f | xargs grep -F 'example' |
Replace all newlines from standard input except the last with spaces | sed -e ':a' -e 'N' -e '$!ba' -e 's/\n/ /g' |
find all the jpg images in the folder /path/to/files which have been modified after after the file "timestamp" and convert them into pdf. | find /path/to/files -iname '*.jpg' -newer timestamp -exec mogrify -format pdf {} +; touch timestamp |
view the manual page of find | man find |
Changes group ownership of /sys/class/gpio/export and /sys/class/gpio/unexport to 'gpio'. | sudo chgrp gpio /sys/class/gpio/export /sys/class/gpio/unexport |
set a crontab to create or update the timestamp of "washere1" in the current directory every minute. | echo "* * * * * touch $/washere1" | crontab |
find all the files in the home folder which are empty (Size 0 bytes) | find ~ -empty |
Print unique lines of sorted file "A.txt" compared to sorted file "B.txt" | comm -2 -3 < < |
Show the explanation of find's debugging options | find -D help |
display all html files in current folder | find -name "*.htm" -print |
Change the ownership of all files in the current directory tree from root to www-data | find -user root -exec chown www-data {} \; |
Find all file.ext files/directories under /home/kibab directory and print . for each of them | find /home/kibab -name file.ext -exec echo . ';' |
Find regular files named 'findme.txt' under '/usr' and '/home' directory tree | find /usr /home -name findme.txt -type f -print |
Display the sizes and filepaths of all files/directories sorted in ascending order of size | du -a --max-depth=1 | sort -n |
Finds all the log* files recursively in /myDir that are more than 7 days older and compresses them. | find /myDir -name "log*" -ctime +7 -exec bzip2 -zv {} \; |
Copy the entire contents of the current directory preserving ownership, permissions, and times | find . | cpio -pdumv /path/to/destination/dir |
find case-insentive example.com file, and whole dose not contain beta | find -iname example.com | grep -v beta |
Remove all vmware-*.log files/directories under current directory | find . -name vmware-*.log | xargs -i rm -rf {} |
Locate all *.csv files under the current directory tree | find . -name "*.csv" |
Print bash environment variable array "fields" and its values | set | grep ^fields=\\\|^var= |
Display the entire contents of 'file', replacing only the very first instance of "old" with "new". | grep -E -m 1 -n 'old' file | sed 's/:.*$//' - | sed 's/$/s\/old\/new\//' - | sed -f - file |
Gets IP address of first listed network interface in system. | ifconfig | grep 'inet addr:' | grep -v 127.0.0.1 | head -n1 | cut -f2 -d: | cut -f1 -d ' ' |
Change permissions to 644 for all regular files under the /path/to/dir/ tree | find /path/to/dir/ -type f -print0 | xargs -0 chmod 644 |
Print file type of the executable file of command "foo" | file $ |
Search the current directory tree for file `teste.tex' | find -name teste.tex |
Find all *.sql files in maximum 1 level down the current directory, process it with sed and then send the output to a mysql command | find -maxdepth 1 -name '*.sql' -exec sed -e 's/ , );/1,1);/g' '{}' + | mysql -D ootp |
Remove all files under /home/user/Maildir/.SPAM/cur | find /home/user/Maildir/.SPAM/cur -type f -exec rm -f '{}' '+' |
Prints full path of a 'cat.wav' file in a current folder. | ls $PWD/cat.wav |
Recursively change ownership of "/usr/local/lib/node_modules" to the current user | sudo chown -R `whoami` /usr/local/lib/node_modules |
Read a line from standard input into variable "password" without echoing the input | read -s password |
Save system information appended with the current date in 'filename' variable | filename="$$" |
For each line of the sorted output of both file1 and file2, print lines whose first field of file2 does not appear as first field of file1. | join -v1 <(sort file1) <(sort file2) |
split listing of the current directory into pieces per 500 lines named "outputXYZNNN" | ls | split -l 500 - outputXYZ. |
Find all files under $root_dir | find $root_dir -type f |
Find all *1234.56789* files/directories under current directory | find . -name '*1234.56789*' |
find files in the current directory and sub-directories, whose content was updated within the last hour | find . -mmin -60 |
Find all directories in maximum 2 levels down the /tmp/test directory | find /tmp/test/ -maxdepth 2 -mindepth 1 -type d |
Compress $file file using gzip | gzip "$file" |
search for the word hello in all the text files in the temp folder and delete them | find /tmp -type f -name β*.txt*β | sed -e βs/.*/\β&\β/β |xargs -n 1 grep -l hello|sed -e βs/.*/\β&\β/β|xargs -n 1 rm -f |
Delete all 1US* files under current directory | find . -iname "1US*" -exec rm {} \; |
List file information of the full path of command "c++" | ls -ald `which c++` |
Remove everything in a current folder without prompting. | find -mindepth 1 -maxdepth 1 -print0 | xargs -0 rm -rf |
dispaly all the empty regular/normal files in the current folder | find . -type f -empty |
get all the files that have been modified within the last 30 days | find . -mtime -30 -print |
Move all files that contain "Subject: \[SPAM\]" to "your_file" | grep -L -r 'Subject: \[SPAM\]' . | while read f; do mv "$f" out; done |
Counts all business days in a current month. | cal -h | cut -c 4-17 | tail -n +3 | wc -w |
Search the current directory tree for files whose name is ".note", case insensitive | find . -iname '.note' | sort -r |
display all files in current directory and save the output to a file | find . > files_and_folders |
Find files with 002 permission in entire file system with the null character as the delimiter | find / -type f -perm -002 -print0 |
Change directory to the directory containing the "oracle" executable | cd "$(dirname $)" |
Find all $1 files/directories under current directory and enter into the parent directory of the first one found | cd $ |
remove all the core files from /usr folder which have not been accessed in the last 7*24 hours | find /usr -name core -atime +7 -exec rm "{}" \; |
list all regular files under the directory "$directory" | find $directory -type f -name '*' |
Make "bar" executable | chmod +x bar |
Recursively changes group ownership on every file in the ${WP_ROOT}/wp-content directory to ${WS_GROUP} group. | find ${WP_ROOT}/wp-content -exec chgrp ${WS_GROUP} {} \; |
search for the files "foo.txt" in the current folder | find . -name foo.txt |
Find all directories named CVS, and deletes them and their contents. | find . -type d -name CVS -exec rm -r {} \; |
Find all files/directories under current directory with 'foobar' in their names and copy them to ~/foo/bar | find . -iname "*foobar*" -exec cp "{}" ~/foo/bar \; |
Search the current directory tree for files AAA and BBB | find . \ -print |
Search the /root directory recursively for the regular file named "myfile" ignoring /root/work/ | find /root/ -path '/root/work' -prune -o -name myfile -type f -print |
Print the names of the directories from the paths expanded by the glob pattern /path/to/directory/* | find /path/to/directory/* -maxdepth 0 -type d -printf '%f\n' |
Save a space separated list of process ids of currently running jobs to variable 'bgxjobs' | bgxjobs=" $" |
Search the current directory tree for all regular non-hidden files except *.o | find ./ -type f -name "*" -not -name "*.o" |
Recursively removes all files like '*.pyc' in a current folder. | find . -name '*.pyc' -print0 | xargs -0 rm |
Move all files that contain "Subject: \[SPAM\]" to "DIR" | grep -L -Z -r 'Subject: \[SPAM\]' . | xargs -0 -I{} mv {} DIR |
Print each line in "file", "file2", and "file3" and replace any tabs with spaces | paste file file2 file3 | sed 's/\t/ /' |
Perform a default Plesk configuration | find /var/www/vhosts/*/httpdocs -type f -iwholename β*/wp-includes/version.phpβ -exec grep -H β\$wp_version =β {} \; |
Set permissions to ug=rw,o= for files under the $d directory tree | find $d -type f -exec chmod ug=rw,o= '{}' \; |
List unique MD5 digests of all files in the current directory ending in .txt | md5sum *.txt | cut -d ' ' -f 1 | sort -u |
Make a list of all files in the current directory tree, except *.png and *.class, and view it in the vim editor | find . | grep -v "\.png$" | grep -v "\.class$" | vim - |
Find files in the current directory and below that are newer than /bin/sh | find . -newer /bin/sh |
Print all files/directories under ... directory by terminating their paths with a null character | find ... -print0 |
Unsets all environment variables. | unset $ |
Finds all folders that contain 'ssh' file and have 'bin' in path. | find / -name ssh|grep bin|xargs dirname |
search for files that are readable for everybody, have at least on write bit set but are not executable for anybody | find . -perm -a+r -perm /a+w ! -perm /a+x |
Find all executables in the current directory tree | find ./ -executable |
Prints long listing of content in a root folder, including hidden files, with human-readable sizes, and stores output to '/root/test.out' file. | echo 'ls -hal /root/ > /root/test.out' | sudo bash |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.