nl_command
stringlengths 14
387
| bash_code
stringlengths 0
532
|
---|---|
search for the folder .dummy in the entire directory structure of "test folder" and remove it. | find -depth "Test Folder" -type d -name .dummy -exec rm -rf \{\} \; |
Find files/directories named 'file.txt' in the path '/usr/lib/important/' | find / -path /usr/lib/important/*/file.txt |
Split "input.txt" into files of at most 10 bytes each with prefix "/tmp/split-file" | split -b 10 input.txt /tmp/split-file |
Merge already sorted files in the current directory ending in ".$suffix" | sort -m *.$suffix |
cope *.mp3 files to /tmp/MusicFiles | find . -type f -name "*.mp3" -exec cp {} /tmp/MusicFiles \; |
Find all the files on the system that have been accessed within the last hour | find / -amin -60 |
Gets IP addresses of all active network interfaces on host. | ifconfig | grep 'inet' | grep -v '127.0.0.1' | awk '{print $2}' | sed 's/addr://' |
Recursively copies '$1' directory to '$2' directory. | cp -r $1 $2 |
Recursively removes all files in a 'path' folder but 'EXPR' files. | find [path] -type f -not -name 'EXPR' | xargs rm |
Sort the lines of the file 'temp.txt' and change it in-place | sort temp.txt -o temp.txt |
find files in a directory and exit the command if the syntax is correct or display invalid command if the syntax is wrong. | find … -exec sh -c 'trap "echo \$?" EXIT; invalid_command "$0"' {} \; |
Find all directories under maximum 1 level down the /parent directory and set their permission to 700 recursively | find /parent -maxdepth 1 -type d -print0 | xargs -0 chmod -R 700 |
Find all directories in /path/to/dir/ without going into sub-directories | find /path/to/dir/ -mindepth 1 -maxdepth 1 -type d |
Change permissions for all PHP files under the current directory tree to 755 and print the number of files changed | find . -name "*.php" -exec chmod 755 {} \; -exec /bin/echo {} \; | wc -l |
Search through the /usr directory for all files that begin with the letters Chapter, followed by anything else. | find /usr -name "Chapter*" -type f |
search for all regular/normal files in the current folder and display the number of lines in the file | find . -type f -print0 | xargs -0L1 wc -l |
Print which files differ between "dir1/" and "dir2/" | diff --brief -r dir1/ dir2/ |
Dump "FILENAME" as 2 byte wide hexadecimal numbers | od -tx2 FILENAME |
Find smallest file in the current directory with find commad | find . -type f -printf "%s\t%p\n" | sort -n |head -1 |
Find all files and directories in the current directory recursively that contain spaces in their names | find . -name '* *' |
Create symlinks to all /home/folder2/*.txt files with the same name in current directory | find /home/folder2/*.txt -type f -exec ln -s {} \; |
Format the filename and modification time of files starting with t as a table | stat -c 'File: %n Modified: %y' t* | column -t |
Find all files under current directory and print them by removing the leading ./ in their paths | find . -type f -exec bash -c 'f="{}"; echo "${f:2}"' \; |
find all the files in the current folder which are smaller than 9MB | find . -size -9k |
Split standard input into files of at most 3400000 lines each | split -l 3400000 |
Find all files/directories under current directory with 'FooBar' in their paths and copy them to ~/foo/bar | find . | grep "FooBar" | |
Rename all *.PNG files/directories to *48.png files/directories under current directory | find . -name '*.PNG' -exec bash -c 'git mv {} $/$48.png' \; |
Displays process tree of 'pppd' process. | pstree -p `pgrep pppd` |
Set variable OUTPUT to full process info of process currently taking the most CPU time. | OUTPUT=`top -b -n 1 | tail -n +8 | head -n 1` |
Write the output of "input_prog" to standard output and error on console and as input to command "my_editor" | input_prog 2>&1 | tee /dev/tty | my_editor |
Find all PHP files under current directory that contain only one line | find . -type f -name '*.php' -exec grep -Hcm2 $ {} + | sed -n '/:1$/{s///;p}' |
Find all empty files in the current directory and delete them | find . -maxdepth 1 -type f -empty -delete |
display all normal/regular files in a folder | find teste1 -type f |
find all js files which path does not contain ./node_modules/* nor './vendor/*" | find -name '*.js' -not -path './node_modules/*' -not -path './vendor/*' |
Find all files under current directory matching the regex '.*\(\\?\|mod_jk\.log\)\.[0-9]+' in their paths | find -type f -regex '.*\(\\?\|mod_jk\.log\)\.[0-9]+' |
Remove all *.log files from the current directory tree | find ./ -name '*.log' | xargs rm |
find all the symbolic links in the current folder that are broken | find . -xtype l |
List each unique character in "file" prefixed by number of occurrences and sorted from most frequent to least frequent | grep -o . filename | sort | uniq -c | sort -nr |
Find all .sh files in or below the current directory and move them to folder ~/back.scripts | find . -name "*.sh" -print0 | xargs -0 -I {} mv {} ~/back.scripts |
find all the files that were modified yesterday in the current directory. | find . -daystart -ctime 0 -type f |
find all the html files in the current folder and search for a pattern in these files | find . | grep html$ | xargs grep <string-to-find> |
Change directory to the download directory specified in the current user's user-dirs.dirs file | cd "$" |
List characters from standard input showing backslash escapes for non-displayables | od -cvAnone -w1 |
Find all files/directories named 'имя_файла' in the entire filesystem | find / -name "имя_файла" |
Print all file/directory names with white space safety under the /proc directory | find /proc -print0 | xargs -0 |
Remove all the versioned-but-empty directories from a Subversion checkout under current directory | find . -name .svn -type d | while read ss; do dir=$; test $ == 3 && echo "svn rm \"$dir\""; done |
Find regular files in the current directory that are writable by at least somebody | find -maxdepth 1 -type f -perm /222 |
Wrap each line in "longline" to a maximum of 30 characters | fold -w30 longline |
Make a copy of file.txt in all directories in current directory - names may not contain spaces. | ls -d */ | xargs -iA cp file.txt A |
Use "/var/log/wtmp" and print IPs and search for "^msw.*127.0.0.1" | who --ips /var/log/wtmp | grep '^msw.*127.0.0.1' |
find all files in home folder which have been modified exactly 1 day before | find ~ -mtime 1 -daystart |
Save number of lines in '/some/big/file' to 'LINES' variable | LINES=$ |
Find all files with the name "MyProgram.c" in the current directory and all of it's sub-directories. | find -name "MyCProgram.c" |
Get the total size in bytes of all files in the current directory tree | find . -type f | xargs stat --format=%s | awk '{s+=$1} END {print s}' |
Changes group ownership of 'logdir' to 'loggroup'. | chgrp loggroup logdir |
Recursively finds files like 'example.com', ignoring case differences, and filters out files with 'beta' in path. | find -iname example.com | grep -v beta |
Recursively copy "dir_a" to "dir_b" and delete any new files in "dir_b" | rsync -u -r --delete dir_a dir_b |
find the count of text files that are present in the current working directory. | find . -maxdepth 1 -name \*.txt -print0 | grep -cz . |
Execute awk command '{ ...}' on compressed file "FILE" | zcat FILE | awk '{ ...}' |
Find all files/directories with '.txt' extension under '/home' directory tree that are greater than 100KB in size | find /home -name "*.txt" -size +100k |
remove all core files in the file system | find / -name "*.core" | xargs rm |
create an archive excluding files matching patterns listed in /path/to/exclude.txt | tar -czf backup.tar.gz -X /path/to/exclude.txt /path/to/backup |
Find all hard links to file1 under /home directory | find /home -xdev -samefile file1 |
Set shell option 'dotglob'. | shopt -s dotglob |
Forcibly removes files '/tmp/stored_exception', '/tmp/stored_exception_line', '/tmp/stored_exception_source' | rm -f /tmp/stored_exception /tmp/stored_exception_line /tmp/stored_exception_source |
Pushes current folder to the directory stack. | pushd $ |
Replace the first occurrence of "string1" on each line with "string2" in all regular files in the current directory tree | find ./ -type f -exec sed -i 's/string1/string2/' {} \; |
set alias "mkcd" for command "_{ mkdir -pv $1; cd $1; }; _" | alias mkcd='_{ mkdir -pv $1; cd $1; }; _' |
Recursively change ownership of "/usr/local" to the current user | sudo chown -R `whoami` /usr/local |
sleep for 10 seconds | sleep `10` |
Find the "param1" string in regular files under and below /var | find /var -type f | xargs grep "param1" |
change the permission of all the files in the current directory to 664 and change the permission of all the directories in the current folder to 775. | find . \( -type f -exec sudo chmod 664 "{}" \; \) , \( -type d -exec sudo chmod 775 "{}" \; \) |
Open all .java files in the current directory tree in the vim editor | find . -name '*.java' -exec vim {} + |
Display the file size of file '/data/sflow_log' in bytes | du -sb /data/sflow_log | cut -f1 |
Search the current directory tree for file "a.txt" | find . -name "a.txt" -print |
Search for files with "sitesearch" in their names and "demo" in their path names | find . -iname '*sitesearch*' | grep demo |
Print numbers from 1 to 10 with 2 values per line | seq 10 | paste -sd" \n" - |
Search the current directory tree for files whose names end in "rb" or "js" | find . -name "*js" -o -name "*rb" |
Change permissions to 700 for directories at the current level and deeper | find . -mindepth 1 -type d | xargs chmod 700 |
Creates temporary folder in a $temp_dir folder with name pattern defined by $template, and stores path to created folder in 'my_temp' variable. | $ my_temp_dir=$ |
Find all the files in the current directory recursively whose permissions are 644 and show the first 10 of them | find . -perm 0644 | head |
Find the files in the current directory that match pattern '*.ISOLATE.*.txt' and move them to folder ./ISOLATE | find . -name '*.ISOLATE.*.txt' -maxdepth 1 -print0 | xargs -0 -IFILE mv FILE ./ISOLATE |
Copy loadable kernel module "mymodule.ko" to the drivers in modules directory matchig current kernel. | sudo cp mymodule.ko /lib/modules/$/kernel/drivers/ |
change the permissions of all the regular files in the folder root_dir to 444 | find root_dir -type f -exec chmod 444 {} \; |
Remove all vmware-*.log files under current directory | find . -name vmware-*.log -delete |
Compresses all '*.xml' files under current directory with 'bzip2' utility. | find -name \*.xml -print0 | xargs -0 -n 1 -P 3 bzip2 |
Find all xml files under current directory and archive them to .bz2 archives | find . | grep ".xml$" | parallel bzip2 |
Identify CMS version/releases accross all your Drupal websites | find /var/www/vhosts/*/httpdocs/ -type f -iwholename "*/modules/system/system.info" -exec grep -H "version = \"" {} \; |
Removes all top-level *.pdf files in a current folder. | rm -f *.pdf |
Calculate the md5 sum of the md5 sum of all the files sorted under "$path" | find "$path" -type f -print0 | sort -z | xargs -r0 md5sum | md5sum |
Prints sizes of all top-level folders in a current folder with human-readable format and descending order. | du -h --max-depth=1 . | sort -n -r |
find all the png files in current folder which are present in the pattern list file "search.txt" | find . -name '*.png' | grep -f < |
Prints full process tree with id number of each process. | pstree -p |
files all files which expect directories and display count of them | find /usr/share \! -type d wc -l |
Verbosely compresses all files on sixth and seventh depth level keeping original files in place. | bzip2 -kv */*/*/*/*/*/* |
create directory /data/db | sudo mkdir /data/db |
Search for first match of the regex 're' in all *.coffee files under current directory | find . -name '*.coffee' -exec awk '/re/ {print;exit}' {} \; |
Print the first two bytes of "my_driver" in octal | od --read-bytes=2 my_driver |
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 -n California {} \; -print | wc -l |
display all html files in current folder | find -name "*.htm" -print |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.