nl_command
stringlengths 14
387
| bash_code
stringlengths 0
532
|
---|---|
Remove the .jpg files from the current directory whose names match regular expression ".+-[0-9]+x[0-9]+\.jpg" | find . -type f -regex ".+-[0-9]+x[0-9]+\.jpg" -exec rm -rf {} \; |
Search the current directory tree for *bash* files | find . -name "*bash*" |
Search the current directory recursively for regular files last modified less than 2 days ago | find . type -f -mtime -2 |
Search the directory given as variable $backuppath recursively for files that were last modified less than 10 days ago and save the list of them to file.list | find "${backuppath}" -mtime -10 > file.list |
Remove all files that contain the word GUI in entire file system | find / -type f -print0 | xargs -0 grep -liwZ GUI | xargs -0 rm -f |
Find files owned by the "shadow" group | find / -group shadow |
Find all your text files and page through them | find . -name "*.txt" -print | less |
List all files/directories under current directory with 'FooBar' in their paths ensuring white space safety | find . -print0 | grep --null 'FooBar' | xargs -0 |
create a backup of all the files in the home folder on a partition and save the log to a file | find /home -depth -print | cpio -ov -0 /dev/rmt0 | tee -a tape.log |
find all files in current folder which are bigger than 1MB | find ./ -size +1000k |
Find all SUID files in entire file system | find / -perm +u=s |
Removes all empty folders under current folder. | find . -type d -exec rmdir {}\; |
Recursively finds strings with"text string to search” in files under 'directory-path', regarding provided options '[option]'. | grep [option] "text string to search” directory-path |
Execute command "$cmd_str" on host "$SERVER" as user "$USER" | ssh "$USER@$SERVER" "$cmd_str" |
create directories a b c d e | mkdir a b c d e |
find all the files in the current folder | find . -print0 | xargs -0 -l -i echo "{}"; |
Split standard input into files of at most 3400000 lines each | split -l 3400000 |
Silently read a line from standard input into variable "REPLY" without backslash escapes and using the prompt $'Press enter to continue...\n' | read -rsp $'Press enter to continue...\n' |
Remove all files from the current directory tree whose names end in "~" | find -iname '*~' | xargs rm |
Set the 'xtrace' shell option | set -x |
Find files in the current directory tree whose names begin with "file" and whose size is 0, and remove them | find . -name 'file*' -size 0 -print0 | xargs -0 rm |
Look for all files managed by git in the current repository whose name or file type description contains the word "ASCII", display the number of lines contained in each match. | git ls-files | xargs file | grep "ASCII" | cut -d : -f 1 | xargs wc -l |
Remove all files that are not newer than Jul 01 by modification time | find /file/path ! -newermt "Jul 01" -type f -print0 | xargs -0 rm |
Prints long listing of the current directory and top-level directories within, sorted from oldest to newest, with appended indicators. | $ ls -Fltr * |
Delete everything in the current directory | find -mindepth 1 -maxdepth 1 -print0 | xargs -0 rm -rf |
Find all files under /var/www directory and set their permission to 644 | sudo find /var/www -type f -print0 | xargs -0 chmod 644 |
Rename file ~/junk/cart1 to ~/junk/A | find ~/junk -name 'cart1' -exec mv {} ~/junk/A \; |
Search the current directory tree for regular files whose names end with "keep.${SUFFIX}", where $SUFFIX is a shell variable | find . -type f -name "*keep.${SUFFIX}" |
Find all directories under current directory and set their permission to 775 | find -type d | xargs chmod 775 |
Unzip "bigfile.txt.gz" to standard output, search for patterns in "patterns.txt", and list the unique matches | gunzip -c bigfile.txt.gz | grep -f patterns.txt | sort | uniq -c |
list symbolic links under the directory "$directory" using contents of the $IFS variable between output of each one | find $directory -type l -printf "%p$IFS" |
Search for 'Processed Files' in all $srch* files under current directory | find . -iname "$srch*" -exec grep "Processed Files" {} \; -print |
List *.pl directories in the current directory tree | find . -name "*.pl" -exec ls -ld {} \; |
Find files/directories under current directory and write them to a file as null terminated strings. | find -fprint0 |
display all the files in the folder "/Users/Me/Desktop" which have read permission to them | find /Users/Me/Desktop -readable |
Print the mount point of the last mounted drive | mount | tail -1 | sed -e "s/^[^/]*\ type .*$/\1/g" |
Find all files/directories with '.js' extension under current directory tree without descending into and ignoring './directory' completely | find . -not \ -name \*.js |
Print argument "$1" "$number" times | yes $1 | head -$number |
Execute "ls -l" every 2 seconds | watch 'ls -l' |
List the current directory recursively ignoring the "dir1" subdirectory | find . -path ./dir1\* -o -print |
List all files and folders in the current working directory | ls `pwd`/* |
Find file `Chapter1' on the system | find / -name Chapter1 -type f -print |
Delete all hidden files under $some_directory | find "$some_directory" -type f -name '.*' -exec rm '{}' \; |
display all scala files in the directory "src/main" | find . -type f -path "*src/main/*\.scala" |
Creates temporary folder and saves path to it in 'td' variable. | td=$ |
Processes all files recursively in /var/spool/cron/tabs folder and filters out all strings with '#'. | grep -v "#" -R /var/spool/cron/tabs |
find all the files in the folder .home/calvin which have been modified in th last 45 minutes | find /home/calvin/ -mmin -45 |
Find every file/directory under the directory /home owned by the user joe | find /home -user joe |
Print the file system "file/goes/here" is on | df -P file/goes/here | tail -1 | cut -d' ' -f 1 |
display a long listing of all the files in the current folder which are bigger than 10KB | find . -size +10k -exec ls -lh {} \+ |
Find all build* directories under /var/www/html/ and print all but first 5 appending with the string 'rf ' | find /var/www/html/ -type d -name "build*" | sort | tail -n +5 | xargs -I % echo -rf % |
display long listing of all normal/regular files in the current directory which have been modified in the last 2 days. | find . -mtime -2 -type f -name "t*" -exec ls -l '{}' \; |
Mount "/windows" using /etc/fstab entry | mount /windows |
Find all regular files under /home/www and replace every occurrences of 'subdomainA.example.com' with 'subdomainB.example.com' in those files | find /home/www -type f -print0 | xargs -0 sed -i 's/subdomainA\.example\.com/subdomainB.example.com/g' |
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 |
Show the mv commands that would rename the *.so files in the current directory tree prepending their names with "lib" | find . -name "*.so" -printf "mv '%h/%f' '%h/lib%f'\n" | less -S |
display all the files in the current folder | find . -print |
Change the group of all directories (except those with a '.') under current directory tree to a group with the same name as the directory name | find . -type d | sed -e 's/\.\///g' -e 's/\./avoid/g' | grep -v avoid | awk '{print $1"\t"$1}' | xargs chgrp |
recursively change owner and group of the directory and group of the directory and all files into it to user and group dev_user | chown "dev_user"."dev_user" -R ~/.ssh/ |
Remove characters in columns 34 through 39 in the output of "finger" | finger | colrm 34 39 |
display all the html files in the folder /var/www | find /var/www -type f -name "*.html" |
Execute COMMAND for all files and directories under the current directory tree | find . -print0 | xargs -0 COMMAND |
Find all directories under mydir | find mydir -type d |
Copy "src/prog.js" and "images/icon.jpg" to "/tmp/package" keeping relative path names | rsync -R src/prog.js images/icon.jpg /tmp/package |
Add the .abc suffix to the names of all *.txt regular files in the current directory tree | find . -type f -iname '*.txt' -print0 | xargs -0 mv {} {}.abc |
find all readme files in a folder | find /usr/share/doc -name README |
Search the *.pdf files from directory tree PDFs/ for text "perry sound", ignoring the case | find PDFs/ -name '*.pdf' -exec sh -c 'pdftotext "{}" - | grep -C 2 -i --with-filename --label="{}" --color "perry sound"' \; |
Find all files named 'new' under current directory tree and display their contents | find . -name new -print -exec cat {} \; |
Set the setup connection timeout to 3 seconds for connecting to "user@ip" via ssh | ssh -o ConnectTimeout=3 user@ip |
List the last entry of the numerically sorted list of all files and folders under "/foldername" | find /foldername | sort -n | tail -1 |
Print which files differ between "folder1" and "folder2" treating all files as text | diff -arq folder1 folder2 |
display all files in the directory "dir" which have been accessed in the last 60 minutes | find /dir -amin -60 |
Set permissions for files in `foldername' and its subdirectories to 644 | find foldername -type f -exec chmod 644 {} ";" |
find all the perl files in /var/www | find /var/www/ -type f -name "*.pl" -print |
Create directory dir2 | mkdir dir2 |
Find all files/directores under /etc and run the file command on each of them | find /etc -print0 | xargs -0 file |
search for directories in the folder "test" which end with 5 digits using regular expressions | find ./test -regextype posix-egrep -type d -regex '.*/[0-9]{5}$' |
Find .cpp files that differs in subdirectories PATH1 and PATH2. | diff -rqx "*.a" -x "*.o" -x "*.d" ./PATH1 ./PATH2 | grep "\.cpp " | grep "^Files" |
Print your/dir if it's empty | find "your/dir" -prune -empty |
Delete line 2 in numbered file "file" and renumber | grep -v '^2 ' file | cut -d' ' -f2- | nl -w1 -s' ' |
Recursively finds all bzip2 compressed files in a current folder and decompresses them. | find ./ -iname "*.bz2" -exec bzip2 -d {} \; |
change owner and group of the file uid_demo to user and group root | sudo chown root:root uid_demo |
Print the 6th field from the paths specified by ~/bin/FilesDvorak/.* files/directories | find ~/bin/FilesDvorak/.* -maxdepth 0 | awk -F"/" '{ print $6 }' |
Find all files under current directory without descending into .snapshot directory that were modified in last 24 hours with null character as the delimiter | find . -name .snapshot -prune -o \ |
Counts the number of lines in each file in a git repository. | git ls-files | xargs -d '\n' wc -l |
Find all .sh files in the current directory tree and remove them | find . -name "*.sh"| xargs rm -rf |
Find every directory under "0001" and make new directories replacing "0001" with "0002" at the beginning of their names. | find 0001 -type d | sed 's/^0001/0002/g' | xargs mkdir |
List level 2 subdirectories of the current directory | find . -mindepth 2 -maxdepth 2 -type d -printf '%M %u %g %p\n' |
Prints the Nth line of output from 'ls -1' | ls -1 | tail -n +N | head -n1 |
find all java files in the current folder and search for the pattern REGEX | find . -name '*.java' -exec grep REGEX {} \; |
Find all regular files 1 level down the $dir directory | find $dir -maxdepth 1 -type f |
Calculate the md5 sum of the contents of all files sorted in directory tree "/path" | find /path -type f | sort -u | xargs cat | md5sum |
Display machine architecture, ie. x86_64 | uname -m |
Find all files in /tmp whose names begin with the current user's name followed by "." | find /tmp -maxdepth 1 -name "$USER.*" |
Dump a MySQL database over a compressed SSH tunnel and use it as input to mysql | mysqldump –add-drop-table –extended-insert –force –log-error=error.log -uUSER -pPASS OLD_DB_NAME | ssh -C user@newhost “mysql -uUSER -pPASS NEW_DB_NAME” |
find all the files in current folder which have been updated in the last 60 minutes | find . -mmin -60 |
Search for files in your home directory which have been modified in the last twenty-four hours. | find $HOME -mtime 0 |
Search the files residing in the current directory tree whose names contain "bills" for "put" | find . -name "*bills*" -print0 | xargs -0 grep put |
find all the png files in current folder which are present in the pattern list file "search.txt" | find . -name '*.png' | grep -f < |
find all the files in the current directory which have been modified in the last 24 hours | find . -mtime 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.