nl_command
stringlengths
14
387
bash_code
stringlengths
0
532
search for the directory "mysql" in the entire file system
find / -name mysql -type d
Find all PDF files in the current directory and its sub-directories that are not currently stored in the ./pdfs directory and move them into the ./pdfs directory.
find . -name "*.pdf" -print | grep -v "^\./pdfs/" | xargs -J X mv X ./pdfs/
List and remove all regular files named "core" that are larger than 500KB
find /prog -type f -size +1000 -print -name core -exec rm {} \;
display a long listing of all the files in the current folder which have spaces in their names and save the output to the file log.txt
find . -name "filename including space" -print0 | xargs -0 ls -aldF > log.txt
Create a symbolic link named "~/bin/subl" to "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl"
ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" ~/bin/subl
Find all .txt files in the current directory tree and edit them with `vim'
find . -name "*.txt" | xargs vim
List all files in the /hometest directory tree whose names are "Trash", and their sizes
find /hometest -name Trash -exec ls -s {} \;
Find files/directories under current directory excluding the path ./src/emacs
find . -path ./src/emacs -prune -o -print
Find files/directories in entire file system that had their meta information changed more than 3 days ago
find / -ctime +3
Display the total count of all the files/directories with '.old' extension under current directory tree
find . -name “*.old” -print | wc -l
Find all files/directories with '.js' extension under current directory tree without descending into and ignoring './directory' completely
find . -not \( -path ./directory -prune \) -name \*.js
Copies defined file to the target folder without overwriting existing files.
cp -n
Print the first 32 hexadecimal characters from "/dev/urandom", determining C locale for character handling functions
cat /dev/urandom | env LC_CTYPE=C tr -cd 'a-f0-9' | head -c 32
Search the current user's home directory and its sub-directories for any file that was modified less than 2 days ago or was modified after filename was last modified.
find ~/ -mtime -2 -o -newer filename
Find all .core files on the system starting from / and delete them
find / -name "*.core" | xargs rm
Count the number of "x" characters in "filename"
sed 's/[^x]//g' filename | tr -d '\012' | wc -c
Find writable files in the current directory tree
find . -writable
Locate all `readme.txt' files under the home directory
find ~ -name readme.txt
display all the .sh scripts and perl files in the current folder
find . -type f \
display all directories in vim folder do not search in sub directories
find .vim/ -maxdepth 1 -type d
Find all files under $source_dir that match the regex expanded by $input_file_type in their paths
find "$source_dir" -type f|egrep "$input_file_type"
display all regular/normal files in the entire file system with the name dummy and discard all the errors
find / -type f -name dummy 2>/dev/null
search in root ( / ) directory downwards all files which have exactly 2 links.
find / -links 2 -print
Search the current user's home directory and below for all .png files and copy those files in the directory imagesdir.
find ~/ -name *.png -exec cp {} imagesdir \;
Search the files in the current directory tree that are named "string to be searched" for "text"
find . -name "string to be searched" -exec grep "text" "{}" \;
Save the list of all subdirectories of the current directory as "dirs_to_remove"
find . -maxdepth 1 -type d > dirs_to_remove
List *.txt files under current directory that have 'mystring' in their name
find . -name *.txt | egrep mystring
Print "$1" or default 10 random lines from standard input
nl | sort -R | cut -f2 | head -"${1:-10}"
Find all files beneath the current directory that end with the extension .java and contain the characters StringBuffer. Print the name of the file where a match is found.
find . -type f -name "*.java" -exec grep -l StringBuffer {} \;
Saves real path of the folder containing the current script
DIR=$(dirname "$")
Print the list of files in the current directory tree excluding those whose paths contain "exclude3" or "exclude4"
find . | egrep -v "" | sort
Delete all filename* files under /dir directory
find /dir -name "filename*" -type f -delete
Search the current directory, except the subdirectory tree ".svn", for files whose name is "foo.cpp"
find . -name 'foo.cpp' '!' -path '.svn'
search for all Scala files under the current directory that contain the string null
find . -type f -name "*.scala" -exec grep -B5 -A10 'null' {} \;
Replace the leading spaces in the output of "history" with periods
history | sed 's/^ */&\n/; :a; s/ \/.\1/; ta; s/\n//'
Verbosely compresses all files on seventh and eighth depth level keeping original files in place.
bzip2 -kv */*/*/*/*/*/*/*
Create intermediate directories foo and bar as required and directory foo/bar/baz
mkdir -p foo/bar/baz
Run the node expression "JSON.parse.foo" on the contents of "foobar.json"
node -pe 'JSON.parse.foo' "$"
Find all files/directores that are newer than /etc/motd and conain the string 'top' at the beginning of their names under user's home directory tree
find ~ -name 'top*' -newer /etc/motd
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 -exec ls -l {} \;
Find all fglrx-libglx* files under and below debian/fglrx/
find debian/fglrx/ -name 'fglrx-libglx*'
Save system information appended with the current date in 'filename' variable
filename="$(uname -a)$(date)"
Find all files/directories named 'text' under current directory
find -name "text"
change group of the file /var/lib/php/session to group lighttpd
chown -R :lighttpd /var/lib/php/session
Print the first 2 lines of tree's help message by redirecting it from standard error to standard output
tree --help |& head -n2
Find all files that belongs to user root under / directory and show a few lines of output from the beginning
find / -user root | head
Find files/directories that is under group 'root' or have no group and set their group to 'apache'
find /var/www -group root -o -nogroup -print0 | xargs -0 chown :apache
run command "exec > > 2>&1 ; cd $WKD; { $BIN $ARG & }; echo \$! > $PID " as user $USR
su -l $USR -s /bin/bash -c "exec > > 2>&1 ; cd $WKD; { $BIN $ARG & }; echo \$! > $PID "
find all the files in the current folder which do not have the read permission
find . -type f ! -perm -444
Show human-readable file type description of file "/mnt/c/BOOT.INI"
file /mnt/c/BOOT.INI
Find all files/directories under current directory and print only 2nd field from output delimited by '/'
find . | awk -F"/" '{ print $2 }'
display all files in the current folder which do not belong to the user john
find . ! -user john
Change to directory 'foo' and print to terminal all received on standard input
cd foo | cat
Search the files from the current directory tree for "foo"
find . -exec grep -l foo {} \;
Find all files/directories in current directory and execute the script itself with minimal invocation for those files/directories
find . -exec $0 {} +
Make directory "aaa/bbb"
mkdir aaa/bbb
Find all 400 permission files under /data directory with null character as the delimiter
find /data -type f -perm 400 -print0