nl_command
stringlengths 14
387
| bash_code
stringlengths 0
532
|
---|---|
Recursively add ".jpg" to all files in the current directory tree | find . -type f -exec mv '{}' '{}'.jpg \; |
Verbosely compresses all files on fifth and sixth depth level keeping original files in place. | bzip2 -kv */*/*/*/*/* |
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 | find . -name "filename_regex"|grep -v '.svn' -v '.pdv'|xargs grep -i 'your search string' |
Set permissions to 2770 for all directories in the current directory tree | find . -type d -exec chmod 2770 {} + |
Find all python files under current directory tree, save the list to 'output.txt' and search for 'something' in those files | find . -name '*.py' | tee output.txt | xargs grep 'something' |
Searches through the htdocs and cgi-bin directories for files that end with the extension .cgi. When these files are found, their permission is changed to mode 755 (rwxr-xr-x). | find htdocs cgi-bin -name "*.cgi" -type f -exec chmod 755 {} \; |
Remove all *.doc files from the current directory tree | find . -name '*.doc' -exec rm "{}" \; |
find all the files in the current folder which have been modified in the last 60 minutes | find . -mmin -60 |
Check if current system is running in 64-bit addressing. | uname -m | grep '64' |
Change the owner of all files in the directory tree "dir_to_start" excluding file "file_to_exclude" to "owner" | find dir_to_start -not -name "file_to_exclude" -print0 | xargs -0 chown owner |
Changes group ownership of 'target_directory' to 'target_group'. | chgrp target_group target_directory |
Variable PID contains a process ID, check if this process exists - resulting exit status from this command will be zero if it does and current user has permission to send it signals. | kill -0 $PID |
Find all *.tar.gz files/directories under /directory/whatever which were modified more than $DAYS ago | find /directory/whatever -name '*.tar.gz' -mtime +$DAYS |
Remove all files 'a.out' and *.o in the home directory tree that were accessed more than 7 days ago | find $HOME \( -name a.out -o -name '*.o' \) -atime +7 -exec rm {} \; |
Print all unique file paths under "dir1" compared to "dir2" | comm -23 < < | sed 's/^\//dir1/' |
Find all directories under /path/to/dir and archive them into files with .tar.gz extension | find /path/to/dir -mindepth 1 -maxdepth 1 -type d -execdir sudo tar -zcpvf {}.tar.gz {} \; |
Compress all ".txt" files in the current directory tree with gzip | find . -type f -name "*.txt" -exec gzip {} \; |
Find all 755 permission regular files under current directory tree | find . -type f -perm 755 |
Find files in the current directory tree whose size is greater than 24000 bytes | find . -size +24000c |
Change permissions of ".git/hooks/prepare-commit-msg" to 777 | sudo chmod 777 .git/hooks/prepare-commit-msg |
Change directory to the download directory specified in the current user's user-dirs.dirs file | cd "$" |
Finds total lines count of all *.php files in a current folder and subfolders. | | wc -l |
Find all files named "MyCProgam.c" (ignoring the case) and calculate each file's md5sum. | find -iname "MyCProgram.c" -exec md5sum {} \; |
Find all *shp* directories under current directory and move their contents to ../shp_all/ | mv $(find . -name "*shp*" -printf "%h\n" | uniq)/* ../shp_all/ |
Print the base name of the current working directory | basename $ |
display the list of all the files in the current directory which have been accssed in the last 500 days exluding hidden files | find . -type f \( ! -iname ".*" \) -mtime +500 -exec ls {} \; |
display a long listing of all the files in the current folder | find . — type f -exec ls -1 {} \; |
Saves calendar of $month, $year in the 'cal' variable. | cal=$(echo $(cal "$month" "$year")) |
get info about "lbzip2\|plzip\|pigz" from tar command | tar --help | grep "lbzip2\|plzip\|pigz" |
Archive a file named '{}' residing in current directory into '{}.tar.gz' and save it inside /var/www/ | find /var/www/* -type d -print | tar -zcpvf {}.tar.gz -C /var/www/ --files-from - {} \; |
Determine DISPLAY variable for the session when logged in via SSH | who am i | awk '{print $5}' | sed 's/[]//g' | cut -f1 -d "." | sed 's/-/./g' |
List all files matching regular expression '*foo*' in a human-readable form | find . -name '*foo*' -exec ls -lah {} \; |
Save first IP address of domain 'google.com' in 'address' variable | address=$ |
Set permissions of all directories under "/opt/lampp/htdocs" to 755 | find /opt/lampp/htdocs -type d -exec chmod 755 {} \; |
display all the files in the folder /mp3-collection which are bigger than 10MB or which start with the name "Metallica" | find /mp3-collection -name 'Metallica*' -or -size +10000k |
Find all files/directories with space in their names under current directory and rename them by replacing all spaces with _ | find . -depth -name "* *" -execdir rename "s/ /_/g" "{}" \; |
Creates temporary folder within a $mnt_dir folder and saves path to it in a 'rsync_src' variable. | rsync_src=`mktemp -d -p $mnt_dir` |
Clean up all zombie processes by sending SIGTERM signal to their parent process, which requests them to terminate. | kill $(ps -A -ostat,ppid | awk '/[zZ]/{print $2}') |
search for all the files which have not been modified in the last 6 months (180 days) in current folder and display the total disk usage of them in MB | find ~/tmp -type f -mtime 0 -exec du -ks {} \; | cut -f1 | awk '{total=total+$1}END{print total/1024}' |
Report only total size of file systems in terabytes. | df -m | awk '{ SUM += $2} END { print SUM/1024/1024"TB" }' |
List (in long list format with inode number) the file under the current directory that has the oldest modification time | find . -type f -ls | sort +7 | head -1 |
Find all files/directories that are newer than 'ttt' by modification time or owned by the user 'wnj' in the entire filesystem | find / \( -newer ttt -or -user wnj \) -print |
display all the files in the current folder which are in the path "./sr*sc" | find . -path './sr*sc' |
Mathematically sum all numbers in "numbers.txt" | cat numbers.txt | php -r "echo array_sum(explode(PHP_EOL, stream_get_contents));" |
Find recursively all files in /path that end in "txt" and copy them to /tmp/ | find /path -type f -name "*txt" -printf "cp '%p' '/tmp/test_%f'\n" | bash |
Find movies over a gigabyte in size | find ~/Movies/ -size +1024M |
Rename $file file, preserving only part of name before '-' symbol, and appending '.pkg' suffix to the end | mv $file $(echo $file | rev | cut -f2- -d- | rev).pkg |
Print 10 space separated "x"s with at most 4 per line | yes x | head -10 | awk 'BEGIN { RS = "%%%%%%%" } { split; for (i=1; i<length; i+=4) print a[i], a[i+1], a[i+2], a[i+3] }' |
Search for files specifying the minimum depth of the search | find -mindepth num -name query |
Delete all empty directories in minimum 2 levels down the root directory | find root -mindepth 2 -type d -empty -delete |
display the file name and creation month of top 11 files in the entire file system | find / -type f -printf "\n%Ab %p" | head -n 11 |
Find all directories under /path/to/base/dir and change their permission to 755 | find /path/to/base/dir -type d -print0 | xargs -0 chmod 755 |
find all the files that have been modified in the last 2 day | find -daystart -mitime -1 |
Print files created/modified in the last day | find /directory -newermt $ -type f -print |
Find all files/directories in level $i down the current directory with all positional parameters appended with the find command | find -mindepth $i -maxdepth $i "$@" |
Print out every command that is executed in the script | set -x |
Search the current directory tree for symbolic links named "link1" | find . -type l -name link1 |
Print a count of all unique entries in "ips.txt" with the most frequent results at the top | sort ips.txt | uniq -c | sort -bgr |
Find all Executable files | find / -perm /a=x |
Find all regular files under $somedir directory and print each of their paths after a string literal 'Found unexpected file ' | find "$somedir" -type f -exec echo Found unexpected file {} \; |
Recursively copy directory "/path/to/data/myappdata" to "user@host:/remote/path/to/data/myappdata" | rsync -rvv /path/to/data/myappdata user@host:/remote/path/to/data/myappdata |
Remove duplicate lines in "file_name" and print the output on stdout | awk '{print}' file_name | sort -t$'\t' -k2,2 | uniq --skip-fields 1 | sort -k1,1 -t$'\t' | cut -f2 -d$'\t' |
Find all files/directories under '/usr/share/data' directory tree that match the posix extended regex ".*/20140624.*" in their paths and save the list to '/home/user/txt-files/data-as-of-20140624.txt' | find /usr/share/data -regextype posix-extended -regex ".*/20140624.*" -fprint /home/user/txt-files/data-as-of-20140624.txt |
Recursively removes all files like '*.r*' in current folder and removes folders with such files if they become empty. | find ./ -type f -name '*.r*' -delete -printf "%h\0" | xargs -0 rmdir |
Find all *gz files under asia and emea directory | find asia emea -type f -name "*gz" |
Set the environment variable "DISPLAY" to the system host name followed by ":0 skype" | DISPLAY=`hostname`:0 skype |
Find all links pointing to /path/to/foo.txt | find . -lname /path/to/foo.txt |
find all files in the file system which belong to the group users and having the word "filename" in their name. | find / -group users -iname "filename" |
display files ending with ".ext" in current folder excluding those that are present in the list list.txt | find -type f -name '*.ext' | grep -vFf list.txt |
Print a dump of the plain hex data in "$VAR1" as printable characters | echo -ne "$VAR1" | xxd -r -p | od -c |
Find all SGID set files | find / -perm /g=s |
Find all *conf* files recursively under current directory | find . -name *conf* |
Find symbolic links in lpi104-6 and research/lpi104-6 to files whose pathnames end in "file1" | find lpi104-6 research/lpi104-6 -lname "*file1" |
list all files under .performance_test directory except .performance_test/prune_me directory | find ".performance_test" -not -path ".performance_test/prune_me*" -exec bash -c 'echo "$0"' {} \; |
Find all directories under current directory tree that were modified $FTIME days ago | find . -type d -mtime $FTIME |
find all the normal/regular files in the folder main-directory | find main-directory -type f |
Print line, word and byte counts for each .php files in current directory tree and also show the total counts | wc `find | grep .php$` |
Find all files/directories named file in minimum 4 levels down the current directory | find -mindepth 4 -name file |
Search the /path tree for all executables | find /path -perm /ugo+x |
Find all .rb and .yml files in the /some/path directory tree and replace "some_phrase" with "replacement_phrase" in them | find /some/path -name "*rb" -o -name "*yml" | xargs grep -sl "some_phrase" | xargs sed -i -e 's/some_phrase/replacement_phrase/g' |
find all files under the /etc directory and display IP address patterns in them | find /etc -type f -exec cat '{}' \; | tr -c '.[:digit:]' '\n' \ | grep '^[^.][^.]*\.[^.][^.]*\.[^.][^.]*\.[^.][^.]*$' |
Find all files/directories under '/etc' directory tree that are greater than 5MB and print their sizes and names | find /etc -size +5M -exec ls -sh {} + |
Split "mybigfile.txt" into files of at most 200000 lines each | split -l 200000 mybigfile.txt |
Search the files from the current directory tree for "chrome" | find . -exec grep chrome {} + |
Find all hidden directories starting from the current directory | find . -type d -name ".*" |
Find all files/directories under /home/baumerf/public_html/ that were modified less than 60 minutes ago excluding *.log files/directories | find /home/baumerf/public_html/ -mmin -60 -not -name \*.log |
extract an archive stripping the first component | tar --strip-components 1 -xvf my_directory.tar.gz |
Find the 5 largest regular files in the Downloads folder of tecmint's home directory. | find /home/tecmint/Downloads/ -type f -exec du -Sh {} + | sort -rh | head -n 5 |
find all the reglar files which ahve been changed in the last 5 minutes and do not search in the sub directories. | find /home/pankaj -maxdepth 1 -cmin -5 -type f |
Find all files/directoires that were modified more than 3 days ago under $dir directory tree | find $dir -mtime +3 |
Show all files in /etc that are owned by root have been modified within the last minute | find /etc/ -user root -mtime 1 |
Execute "ls -l" every 0.5 seconds | watch -n 0.5 ls -l |
Recursively finds strings with"text string to search” in any file within the 'directory-path', following symlinks, and prints found strings with file names. | grep -r -H "text string to search” directory-path |
Cut all remote paths from HTTP URLs received from standard input keeping only the protocol identifier, host name, and trailing slash, of the form http://example.com/ | sed -n 's;\.*;\1;p' |
Move all directories in the current directory tree that have been modified in the last day to "/path/to/target-dir" | find . -type d -mtime -0 -print0 | xargs -0 mv -t /path/to/target-dir |
Find all files/directories under /path directory that were modified more than 30 minutes ago | find /path -mtime +30m |
Report file system containing path to /dir/inner_dir/ disk usage in kilobytes. | df -k /dir/inner_dir/ |
Find all files under and below the current working directory with the word California in the file , and count the number of lines in the output | find . -type f -exec grep -i California {} \; -print | wc -l |
find all the files in the current folder (handles files which contain newlines or only spaces in their names) | find . -print0 | xargs -0 -l -i echo "{}"; |
Forcefully remove files *~important-file | rm -rf *~important-file |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.