nl_command
stringlengths
14
387
bash_code
stringlengths
0
532
Find all files/directories under '/abs/path/to/directory' directory non-recursively that match the pattern '.*invalidTemplateName.*' in their names
find /abs/path/to/directory -maxdepth 1 -name '.*invalidTemplateName.*'
delete all the log files in the current folder
find ./ -name '*.log' -print0 | xargs -0 rm
Change permissions to 644 for all files in the current directory tree
find . -type f | xargs -I{} chmod -v 644 {}
Recursively set all permissions under "/folder" to 755
chmod 755 /folder -R
Find all 15MB files in entire file system
find / -size 15M
find all instances of a file in the current folder and create a backup of it in the floppy
find . -name nameoffile -print | cpio -iv > /dev/fd0
search for the regular/normal file "myfile" in the current folder excluding search in the paths of "work" and "home" sub directories
find . \( -name work -o -name home \) -prune -o -name myfile -type f -print
Find files patching "pattern"
find . -name "pattern" -print
find non-hidden files (ones that do not start with the period "." chartacter) that were are modified in the last 15 minutes.
find . -mmin -15 \( ! -regex ".*/\..*" \)
Search for 'Processed Files' in all $srch* (case insensitive) files under current directory run the sed script 'N;s/(.*)\n(.*)/\2 \1/' on the output
find . -iname "$srch*" -exec grep "Processed Files" {} \; -print| sed -r 'N;s/(.*)\n(.*)/\2 \1/'
Print a sorted list of the extensions of the regular files from the current directory tree
find . -type f | sed -e 's/.*\.//' | sed -e 's/.*\///' | sort -u
Gets IP address of first listed network interface in system.
ifconfig | grep -E "([0-9]{1,3}\.){3}[0-9]{1,3}" | grep -v 127.0.0.1 | awk '{ print $2 }' | cut -f2 -d:
Set timestamp of B to the timestamp in stat format specified by variable "old_time"
touch -d"$" B
Create master SSH control socket "my-ctrl-socket" in the background with no terminal or command execution with connection forwarding from localhost port 50000 to localhost port 3306 via "[email protected]"
ssh -M -S my-ctrl-socket -fnNT -L 50000:localhost:3306 [email protected]
find all the html files in the current folder and rename them to .var files
find -name '*.html' -print0 | xargs -0 rename 's/\.html$/.var/'
Extract host name part from URL.
echo "$url" | cut -d'/' -f3
show all the regular/normal files in the folder /home/user/demo
find /home/user/demo -type f -print
Print chmod commands that can change permissions of regular files residing in the current directory tree to u=rw,g=r,o=
find . -type f -exec echo chmod u=rw,g=r,o= '{}' \;
display list of all the files in the current directory (print0 handles file names with newlines or spaces)
find -print0 | xargs -0 ls
Search for file names with "bad" characters in the current directory and delete the files.
find . -name '*[+{;"\\=?~<>&*|$ ]*' -maxdepth 0 -exec rm -f '{}' \;
List all files/directories under current directory with 'FooBar' in their names ensuring white space safety
find . -name 'FooBar' -print0 | xargs -0
Return the depth of the current directory tree
find . -type d -printf '%d:%p\n' | sort -n | tail -1
Find all files/directories that are newer than 'backup.tar.gz' by modification time
find . -newer backup.tar.gz
Change permissions of all files ending ".php" under the current directory to 755 with a progress bar based on lines
find . -name "*.php" | pv --line-mode | xargs chmod 755
display all the ".c" files which have been modified in the last 10 minutes
find /home/david -amin -10 -name '*.c'
Numerically sort IPv4 addresses specified on standard input with presedence to first, second, third, then fourth octet
tr '.' ' ' | sort -nu -t ' ' -k 1 -k 2 -k 3 -k 4 | tr ' ' '.'
Find all files/directories under maximum 1 level down the current directory and print their inode numbers and names
find . -maxdepth 1 -print0 | xargs -0 stat -c '%i %n'
Print numbers from 1 to 10 with 2 values per line
seq 10 | sed 'N;s/\n/ /'
Set variable OS to the name of the operating system, ie. "Linux"
OS=`uname -s`
Rename "original.filename" to "new.original.filename"
mv {,new.}original.filename
Find all *.py files under and below the current directory and search them for "xrange"
find . -name '*.py' -exec grep --color 'xrange' {} +
List all files/directories under current directory
find . -print
Change user ownership to `foo' for files with UID=1005
find / -user 1005 -exec chown -h foo {} \;
Print all files and directories in the `.' directory tree skipping SCCS directories but printing out the SCCS directory name
find . -print -name SCCS -prune
Replace spaces in directory names with underscores for all directories in the current directory tree
find -name "* *" -type d | rename 's/ /_/g'
Find all *.c files on the system and feed the output to wc
find / -name *.c | wc
Print each line in "f1" and "f2" separated by a space and "f3" separated by a tab
paste < f3
Find files under current directory that contains the string '/bin/ksh'
find . -type f -exec grep -iH '/bin/ksh' {} \;
Find all the files which are changed in last 1 hour in entire file system and show a few lines of output from the beginning
find / -cmin -60 | head
Remove the "^M" characters from all *.ext files under /home directory and save the results to new files with _new appended in their names
find /home -type f -name "*.ext" -print0 | while read -r -d "$" -r path; do cat $path | tr -d '\r' > $path"_new"; done
Search for 'Text To Find' in all regular files under current directory tree and show the matched files
find ./ -type f -exec grep -l "Text To Find" {} \;
Remove all subdirectories of the current directory, except for "bar", "foo", "a", and "b"
find . -maxdepth 1 -type d \( ! -name "bar" -a ! -name "foo" -a ! -name "a" -a ! -name "b" \) -delete
Find all regular files under $dir
find $dir -type f
Recursively search for all directories containing "foo" (case insensitive) under the current directory, renaming them to replace "foo" (case insensitive) with "Bar"
find . -type d -iname '*foo*' -depth -exec rename 's@Foo@Bar@gi' {} +
Find all files whose filename does not end with *.html.
find . -type f -not -name "*.html"
Make directory expanded by $dir variable
mkdir $dir
Copy "local_file" to "user@host:remote_file" via ssh protocol, saving partially transferred files, and showing progress
rsync --partial --progress --rsh=ssh local_file user@host:remote_file
Find all files under current directory matching the posix-egrep type regex '^.*/[a-z][^/]*$' in their names
find . -regextype posix-egrep -regex '^.*/[a-z][^/]*$' -type f
List all php files below current directory whose full pathname name does not include "libs", "tmp", "tests", or "vendor", sorted by number of lines, letting the user page interactively through the output.
find . -name '*.php' -print0 | xargs -0 wc -l | sort -nr | egrep -v "libs|tmp|tests|vendor" | less
find files in home directory that accessed more than 100 days ago
find ~ -atime 100
Move all files/directories under current directory to ~/play
find . | xargs -I'{}' mv '{}' ~/play/
Print "/tmp/myfile" starting at line 11
tail -n +11 /tmp/myfile
copy all the regular files in the current directory to the temporary diectory.
find . -type f -exec cp {} /tmp +
Recursively removes all files like '*.pyc' in a current folder.
find . -name "*.pyc" -exec rm -rf {} \;
run a command "dbca -silent -createDatabase -templateName General_Purpose.dbc -gdbName qualidade -sysPassword password -systemPassword password -scriptDest /u01/app/oracle/oradata/qualidade -characterSet WE8ISO8859P1" with bash shell as user oracle
su -c "dbca -silent -createDatabase -templateName General_Purpose.dbc -gdbName qualidade -sysPassword password -systemPassword password -scriptDest /u01/app/oracle/oradata/qualidade -characterSet WE8ISO8859P1" -s /bin/sh oracle
display the names without extensions of all the data files in current folder which have not been changed in the last 60 mins
find . -prune -name "*.dat" -type f -cmin +60 |xargs -i basename {} \;
find all the files in the entire file system that have been modified exactly 50 days ago
find / -mtime 50
Make directories to file "/full/path/to/file.txt" as needed
mkdir -p `dirname /full/path/to/file.txt`
Find all empty directories under /tmp and below
find /tmp -type d -empty
List all files/directories under current directory
find .
concatenates file1.txt, file2.txt, and file3.txt with the filenames printed at the beginning of file contents
head -n99999999 file1.txt file2.txt file3.txt
Search directory tree `MyApp.app' for directories whose name is 'Headers' and delete them
find -d MyApp.app -name Headers -type d -exec rm -rf "{}" \;
Recursively finds all "file_pattern_name" files and folders and prints strings with "pattern", searching through found folders recursively.
find ./ -name "file_pattern_name" -exec grep -r "pattern" {} \;
Removes shell alias with name 'python'.
unalias python
Check if "\[$VLABEL\]" is mounted and save the result in variable "AMV"
AMV=$
Display the first 10 lines of the byte hex dump with no file offset data for "/bin/ls"
od -t x1 -An /bin/ls | head
find all text files in the current directory and compress them to a cpio file
find . -name '*.txt' | cpio -pdm /path/to/destdir
Search the entire file hierarchy for files named zsh that exist on ext3 file systems and print out detailed information about the file.
find / -fstype ext3 -name zsh -ls
remove all the files in current folder which have the extension "DS_Store"
find . -name ".DS_Store" -exec rm {} \;
search for al cpp files in current folder and display distinct parent directory of these files in sorted order
find . -name "*.cpp" -exec dirname {} + | sort -u
find all files under the current folder except dir1 dir2 dir3 folder
find . -type d \( -path dir1 -o -path dir2 -o -path dir3 \) -prune -o -print
Find all files/directories under /myfiles that were modified 2 days ago
find /myfiles -mtime 2
Print space separated list of numbers from "$start" to "$end"
seq -s' ' $start $end
Delete all regular files that start with 'sess_' in their names, are at least 1 level deep and were modified more than $gc_maxlifetime minutes ago under $save_path directory tree
find -O3 "$save_path" -depth -mindepth 1 -name 'sess_*' -ignore_readdir_race -type f -cmin "+$gc_maxlifetime" -delete
Update the timestamp of '/tmp/$$' to the current month and day
touch -t `date +%m%d0000` /tmp/$$
Find all *.tex regular files in maximum 2 levels down the current directory
find . -type f -maxdepth 2 -name "*.tex"
Page through the contents of yourFile, adding a $ at the end of each line and replacing tab characters by ^I.
cat -vet file | less
Find all files under current directory, calculate their md5sum and print each of the outputs to filename.md5 files
find . -type f | while read f; do g=`md5sum $f` > $f.md5; done
Pipe the output of ls into "read var" in its separate process
ls | read var
Remove all Thumbs.db files from the current directory tree
find . -name Thumbs.db -exec rm {} \;
find -name '*.js' -not -path './node_modules/*' -not -path './vendor/*'
find -name '*.js' -not \( -path './node_modules/*' -o -path './vendor/*' \)
Send ping requests to hostname specified by variable "c" for 1 second.
ping -w 1 $c
Make directory "TestProject"
mkdir TestProject
Remove all files containing 'sample' (case insensitive) in their names under '/home/user/Series' directory tree
/usr/bin/find /home/user/Series/ -iname "*sample*" -exec rm {} \;
Recursively make all mounts under "/" private
mount --make-rprivate /
Find all *$VERSION* files/directories under current directory where $VERSION is a variable
find . -name "*$VERSION*"
Find all files inside all directories in /tmp/test directory and print the number of files in each directory and also print the file/directory paths
find . -type d -print0 | xargs -0 -I {} sh -c ' echo "{}: \c" ; find {} -maxdepth 1 -type f | wc -l ; find {} -maxdepth 1 -type f -print'
Search the XML files from directories /res/values-en-rUS and /res/xml for string "hovering_msg"
find /res/values-en-rUS /res/xml -iname '*.xml' -print0 | xargs -0 -d '\n' -- grep -i "hovering_msg" --
Change onwer to "root" and group to "wheel" of "com.xxxx.adbind.plist"
sudo chown root:wheel com.xxxx.adbind.plist
create directory /var/svn as user root
sudo mkdir /var/svn
search for the file "myletter.doc" in the home folder
find ~ -name myletter.doc -print
Find all regular files that reside in the current directory tree and were last modified more than 2 days ago
find . -type f -mtime +2
display all instances of the file tkConfig.sh in the folder /usr
find /usr -name tkConfig.sh
Display kernel name, release, and version.
uname -s -r -v
Print the day at 1 day ago in 2 months from now
date -d "$ -1 day" +%a
Find apparent size of a target directory
du -hs /path/to/directory
Search the home directory tree for files last modified less than 2 days ago or newer than file "filename"
find ~/ -mtime -2 -o newer filename
display all the files in the current folder and traverse from the sub directories
find . -type d -depth
find all the regular/normal files in the current directory and print them skip searching all the directories in the current folders.
find * -type f -print -o -type d -prune
Search $MYGROUP in /etc/group, take the 4th colon (':') separated field, replace comma (',') with newline and save the result to variable 'MYUSERS'
MYUSERS=`grep $MYGROUP /etc/group | cut -d ":" -f4| tr "," "\n"`