nl_command
stringlengths 14
387
| bash_code
stringlengths 0
532
|
---|---|
Find executable regular files in the current directory tree
|
find . -type f -exec test -x {} \; -print
|
search for all the symbolic links in a folder and display all the broken/non-existent links
|
find /target/dir -type l ! -exec test -e {} \; -print
|
Send one ping request to host whose name or IP address is specified by variable "remote_machine".
|
ping -c 1 $remote_machine
|
Find files in the current directory tree whose content was changed within the last 60 minutes
|
find . -mmin -60
|
Sets 'globstar' shell option.
|
shopt -s globstar
|
split file /etc/gconf/schemas/gnome-terminal.schemas into pieces per 1000000 lines
|
split -n 1000000 /etc/gconf/schemas/gnome-terminal.schemas
|
Find all .zip files in the current directory tree and unzip them deleting the archives on success
|
find . -depth -name '*.zip' -exec /usr/bin/unzip -n {} \; -exec rm {} \;
|
Find all PHP files in the current directory recursively and search them for string "$test" with 8 simultaneous processes
|
find . -name \*.php -type f -print0 | xargs -0 -n1 -P8 grep -Hn '$test'
|
Save the md5 sum hash of "${my_iso_file}" to variable "md5"
|
md5=`md5sum ${my_iso_file} | awk '{ print $1 }'`
|
Archive the directory structure under current directory into directory-structure.tar
|
find . -type d -print0 | tar cf directory-structure.tar --null --files-from - --no-recursion
|
Search the entire file system for any file that is writable by other.
|
find / – perm -0002
|
Recursively removes all files and folders that match pattern '/usr/local/{lib/node{,/.npm,_modules},bin,share/man}/npm*'
|
rm -rf /usr/local/{lib/node{,/.npm,_modules},bin,share/man}/npm*
|
Use the uncompressed contents of "data.gz" as input to "./complicated-perl-script-that-reads-stdin" and print a status
|
pv data.gz | gunzip -c | ./complicated-perl-script-that-reads-stdin
|
search all the files in the current folder and assign them to a variable
|
files=`find .`
|
find all files that are readable and writable by their owner
|
find . -perm -600 -print
|
display all normal/regular files or directories in the folder "$ORIG_DIR"
|
find "$ORIG_DIR" -name "*" -type d -o -name "*" -type f
|
Search the home directory tree for files owned by sam
|
find /home -user sam
|
Archive all filepattern-*2009* files/directories under data/ into 2009.tar
|
find data/ -name filepattern-*2009* -exec tar uf 2009.tar {} ;
|
Print the first line and lines with "f" as the third "," separated field in "input" and format the result as a "," delimited table
|
awk -F, '{ if (NR == 1)print}{if($3 == "f")print}' input | column -t -s,
|
display a long listing of the files in current folder which have been modified in the last 60 minutes
|
find . -mmin -60 |xargs ls -l
|
Print last 10 commands in history
|
history 10
|
Make directory named in variable "archive" with ".tar*" stripped from the end
|
mkdir ${archive%.tar*}
|
Find symbolic links under /etc/
|
find /etc -type l
|
Creates temporary folder in a TMPDIR folder or /tmp folder if TMPDIR doesn`t defined, with folder name like current shell name and 10-letter suffix, and saves created path in 'mydir' variable.
|
mydir=$(mktemp -d "${TMPDIR:-/tmp/}$(basename $0).XXXXXXXXXXXX")
|
Archive all ".txt" files in the current directory to "/path/to/dest" keeping partially transferred files
|
rsync -aP --include=*/ --include=*.txt --exclude=* . /path/to/dest
|
Find all fonts that belong to the user 'warwick'
|
find /usr/local/fonts -user warwick
|
Find .txt files on the system whose size is greater than 12000 bytes
|
find / -name "*.txt" -size +12000c
|
find all txt files under the current folder except ./directory folder
|
find -name "*.js" -not -path "./directory/*"
|
List all files under the current working directory tree
|
find $/ -type f
|
Find all xml files under current directory and archive them to .bz2 archives
|
for i in `find . | grep ".xml$"`; do bzip2 $i&; done
|
Recursively copy all ".txt" files to "[email protected]:/tmp/newdir/"
|
rsync -rvv *.txt [email protected]:/tmp/newdir/
|
find case-insentive example.com file, omit ./beta path
|
find ./ -path ./beta/* -prune -o -iname example.com -print
|
Find files/directories writable by group and others under the /path directory
|
find /path -perm -go+w
|
Find regular files named "regex" under and below /dir/to/search/
|
find /dir/to/search/ -type f -name 'regex' -print
|
Prints process tree of the current process with parent processes.
|
pstree -s $$
|
Find files not matching the patterns 'Image*-70x70*' and 'Image*-100x100*' in their names under Folder1 and copy them to Folder2
|
find Folder1 \ | xargs -i% cp -p % Folder2
|
Create a tar archive of files from directory tree "data"
|
find data/ -print0 | tar --null -T - --create -f archive.tar
|
find all html or cgi files in current folder
|
find ./ -type f -iregex ".*\.html$" -or -iregex ".*\.cgi$"
|
Recursively finds all files with any cased text "Text" in a current folder, and precedes found string with its number in file.
|
grep -inr "Text" folder/to/be/searched/
|
Find all directories in 1 level down the /home directory that have two consecutive vowels in their names and count them
|
find /home -mindepth 1 -maxdepth 1 -type d -name '*[aeiou][aeiou]*' -printf '*' | wc -c
|
Find all files/directories which have been modified within the last day in the drectories/files taken from the glob pattern '/tmp/test/*'
|
find /tmp/test/* -mtime -1
|
Find all regular files under ${path} without following symlinks
|
find ${path} -P -type f
|
Recursively change the owner of all "*.txt" files under "/mydir" to "root"
|
find /mydir -type f -name "*.txt" -execdir chown root {} ';'
|
Find .rmv files in the current directory recursively
|
find . -name *.rmv
|
Create intermediate directories "b and "c" as required and directory "c"
|
mkdir -p a/b/c
|
find all files in the current folder that are modified exactly 1 minute ago
|
find -mmin 1 -print
|
Search for the pattern '^use strict' in all *.pl files under current directory
|
find . -name '*.pl' | xargs grep -L '^use strict'
|
Recursively finds all files and prints all strings with 'text-to-find-here' from that files.
|
find / -type f | xargs grep 'text-to-find-here'
|
Read two bytes from "/dev/urandom" and print them as an unsigned integer
|
od -A n -N 2 -t u2 /dev/urandom
|
Print the content of the file 'file' deleting the last four lines
|
nl -b a file | sort -k1,1nr | sed '1, 4 d' | sort -k1,1n | sed 's/^ *[0-9]*\t//'
|
Filter the cron list of user "user" through "my_wonderful_sed_script" and re-apply the resulting output.
|
crontab -u user -l | sed "$my_wonderful_sed_script" | crontab -u user -
|
Find files that are 0 bytes in size in the current directory and remove them
|
find . -maxdepth 1 -size 0c -exec rm {} \;
|
Remount "/dev/stl12" on "/system" as read only
|
mount -o ro,remount /dev/stl12 /system
|
display a long listing of all regular files in current folder which have been modified in the last 60 minutes
|
find . -mmin -60 -type f | xargs ls -l
|
Delete all files in the TBD directory that were modified more than 1 day ago
|
find /TBD/* -mtime +1 | xargs rm -rf
|
Returns unsuccessful exit code on each found file like '*tests*' within current directory.
|
find . -name '*tests*' -print -exec false \;
|
Delete all files in the current directory.
|
find . -exec /bin/rm {} \;
|
Recursively move "./dir" to "user@host:/path" via ssh on port 2222 compressing data and displaying progress during transmission
|
rsync -rvz -e 'ssh -p 2222' --progress --remove-sent-files ./dir user@host:/path
|
Saves location of file $1 in 'dir' variable.
|
dir=$
|
display all the regular/normal files in a folder and save errors to a log file
|
find ./subdirectory -type f 2>>error.log
|
Find all regular files under $dir directory tree with name pattern provided by the first positional parameter and show only the $num'th line from each of those files
|
find $dir -type f -name $1 -exec sed $num'q;d' {} \;
|
Print host name without a newline
|
echo -n `hostname`
|
Print the list of files in the current directory tree skipping SVN files
|
find . -type d -name .svn -prune -o -print
|
Print each column in "file" with "-" character removed
|
fold -w1 file | pr -4t | tr -d '\n\t\- ' | sed '$a\'
|
Write "suspend" to standard output and to file "/sys/bus/usb/devices/usb3/power/level"
|
echo suspend | sudo tee /sys/bus/usb/devices/usb3/power/level
|
find all the files in the entire file system whose size is between 50Mb to 100MB
|
find / -size +50M -size -100M
|
delete all the tmp files in the /tmp folder. Print0 is used to display all those files which have newline in their names or files whose name is only spaces.
|
find /tmp -name "*.tmp" -print0 | xargs -0 rm find /tmp -name "*.tmp" -print0 | xargs -0 rm
|
Silently read a single character from standard input into variable "REPLY" without backslash escapes, with a timeout of 5 seconds, and using the prompt $'Press any key or wait 5 seconds to continue...\n'
|
read -rsp $'Press any key or wait 5 seconds to continue...\n' -n 1 -t 5
|
Find all files under $d directory and set read-write permission for owner and group and no permission for other for those files
|
find $d -type f -exec chmod ug=rw,o= '{}' \;
|
Search the current directory tree for symlinks whose contents match pattern "*sysdep.c"
|
find . -lname '*sysdep.c'
|
find all ".flac" files starting with "cmn-" and search for files having CJK characters using unicodes
|
find . -name 'cmn-*.flac' -print | grep -P '[\x4e00-\x9fa5]'
|
Split "t.txt" into files with at most 30000000 lines each and use a prefix "t" and numeric suffixes of length 2
|
split --lines=30000000 --numeric-suffixes --suffix-length=2 t.txt t
|
Search all regular files in the current directory tree for "string"
|
find . -type f -exec grep string {} \;
|
Run "command" on server "host" as user "user"
|
echo "command" | ssh user@host
|
Search the current directory tree for files and directories whose names do not end in ".exe" and ".dll"
|
find . -name \*.exe -o -name \*.dll -o -print
|
display all the files in the home folder that have been modified in the last 7*24 hours
|
find $HOME -mtime -7
|
Calculate the sha1 sum and md5 sum of "foo"
|
echo foo | tee > >
|
Find all *.jpg files and copy them to /
|
find / -type f -name *.jpg -exec cp {} . \;
|
find all the files in current directory of size greater than 2GB.
|
find . -size +2G
|
Find all files/directores under '/usr/local' directory tree that case insensitively contain the word 'blast' in their names
|
find /usr/local -iname "*blast*"
|
find for a filename with multiple patterns in the current folder
|
find . -name "photo*.jpg"
|
Print the type of the current shell
|
echo $(cat /proc/$$/cmdline)
|
find all files that belong to root user
|
find . -uid 0 -print
|
Delete files in /var/tmp/stuff and below that have not been modified in over 90 days
|
find /var/tmp/stuff -mtime +90 -print0 | xargs -0 /bin/rm
|
Archive directory "." to "server2::sharename/B"
|
rsync -av . server2::sharename/B
|
Replace all ' ' with '-' from standard input
|
tr ' ' '-'
|
sort and display the unique lines display the contents of all the files that have been modified in the last 91 days and not in the last 2 days
|
find . -name "*.txt" -type f -daystart -mtime -91 -mtime +2 | xargs cat | sort | uniq
|
split the result of command "ping -c 25 google.com | tee " into pieces per 100000 bytes named as "/home/user/myLogFile.logNNN"
|
ping -c 25 google.com | tee >(split -d -b 100000 - /home/user/myLogFile.log)
|
add read permission to others for the files in the current folder having the name "rc.conf" in their name.
|
find . -name "*rc.conf" -exec chmod o+r '{}' \;
|
Removes trailing and starting newlines from file
|
tac file | sed -e '/./,$!d' | tac | sed -e '/./,$!d'
|
display a long listing of all the log files in the current folder which are bigger than 1MB
|
find . -size +1000k -name *.log -print0 | xargs -0 ls –lSh
|
Locate all *.csv files under the current directory tree separating the file names with zeroes
|
find . -name "*.csv" -print0
|
find all the files with the name test in the current folder
|
find . -iname test
|
Prints process tree of a current process with parents processes and id numbers.
|
pstree --show-parents -p $$ | head -n 1 | sed 's/\+.*/\1/' | less
|
Prints path to the target of symbolic link 'relative/path/to/file'
|
dirname `readlink -e relative/path/to/file`
|
Copy "src/prog.js" and "images/icon.jpg" to "/tmp/package/" keeping relative path names
|
rsync -Rv src/prog.js images/icon.jpg /tmp/package/
|
Print the date, then prompt "Hit ENTER or wait ten seconds" with a 10 second timeout, then the date again
|
date ; read -t 10 -p "Hit ENTER or wait ten seconds" ; echo ; date
|
Print all directories under $root appending a : (colon) at the end of each path
|
find $root -type d -printf '%p:'
|
Find all *.txt and *.json files
|
find . -type f \( -name "*.txt" -o -name "*.json" \)
|
Find files named 'fileName.txt' under '/path/to/folder' directory tree ignoring 'ignored_directory'
|
find /path/to/folder -name fileName.txt -not -path "*/ignored_directory/*"
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.