nl_command
stringlengths
14
387
bash_code
stringlengths
0
532
Find all *.java files in the current directory tree
find . -name \*.java
find all the files that are modified in the last 7 days
find -daystart -mtime -7
Search for ERROR in all btree*.c files under current directory
grep ERROR $(find . -type f -name 'btree*.c')
Print the content of file
sed 's/\n//' file
Find all files/directories under .. directory and copy them to ~/foo/bar
find .. -exec cp -t ~/foo/bar -- {} +
list regular file which file name end with 'cache' 'xml' or 'html' in current directory
find . -type f \
Find all *.jpg files/directories under current directory
find . -name '*.jpg'
Recursively find the latest modified file in the current directory and print the modification time and filename
find . -type f -printf '%T@ %p\n' | sort -n | tail -1 | cut -f2- -d" " | sed 's/.*/"&"/' | xargs ls -l
Store info about all mounted file systems, printing all sizes in powers of 1000
a=$( df -H )
search for all the .o files in the current directory which have permisssions 664 and print them.
find . -name *.o -perm 664 -print
Add cron lists from "file1" and "file2" to list of cron jobs, giving errors for any lines that cannot be parsed by crontab.
cat file1 file2 | crontab
Change directory to the parent of the real path of the current script
cd $(dirname $)
Create md5sum of a directory
du -csxb /path | md5sum > file
Find SQL files with text `expression'
find . -name "*.sql" -print0 -type f | xargs -0 grep "expression"
Login to remote system "app1" through an ssh gateway system called "gw"
ssh -At gw ssh -A app1
Scan every file in /etc for IPV4 addresses.
find /etc -exec grep '[0-9][0-9]*[.][0-9][0-9]*[.][0-9][0-9]*[.][0-9][0-9]*' {} \;
Prints total count of lines of all files in a current folder and subfolders.
find . -type f -exec wc -l {} \; | awk '{ SUM += $0} END { print SUM }'
Change permissions to 644 of multiple regular files with permissions 755
find . -type f -perm 755 -exec chmod 644 {} \;
Remove all libGLE* files from the current directory tree
find . -name libGLE* | xargs rm -f
Compare each .xml file under the current directory with a file of the same name in "/destination/dir/2"
find . -name *.xml -exec diff {} /destination/dir/2/{} \;
Running javascript program "app" with node outputs the name of a directory, go into that directory.
cd "$"
Find all files modified on the 7th of June, 2007, starting from the current directory
find . -type f -newermt 2007-06-07 ! -newermt 2007-06-08
Print the base name of the current working directory
basename "`pwd`"
Reports count of characters in the value of ${FOO_NO_WHITESPACE} variable as follows: "length(FOO_NO_WHITESPACE)==<counted number of characters>"
echo -e "length(FOO_NO_WHITESPACE)==$(echo -ne "${FOO_NO_WHITESPACE}" | wc -m)"
find all the files in the current folder with the name "test-a" and move them to the folder test-10
find ~ -type f -name test-a -exec mv {} test-10 \;
Find regular files which have 644 permission
find . -perm 644 -type f -exec ls -l {} \;
find all regular/normal files in the current folder whose name has the word photo or picture and which have been modified in the last 30 minutes
find . \ -and ! -type d -and -mmin -30
Find files containing string "#!/bin/ksh" and append their names and matching strings to /tmp/allfiles
find . -type f -execdir /usr/bin/grep -iH '#!/bin/ksh' {} \; | tee /tmp/allfiles
list all the sqlite files in the current folder
find ./ -name "*.sqlite" -ls
Find all regular files under '/home/john' directory tree that start with 'landof' in their names
find /home/john -name "landof*" -type f -print
Add "new." to the beginning of the name of "original.filename", renaming it to "new.original.filename".
rename 's/(.*)$/new.$1/' original.filename
Search the home directory tree for all .txt files
find ~/ -name '*.txt'
Print information of the root mount point
mount -v | grep " on / "
Search the current directory recursively for .sh files whose names begin with "new"
find . -name "new*.sh"
Find all *.jpg files under maximum 2 levels down the temp/images/* paths and run `mogrify -resize 100x100">" -quality 80 -compress JPEG -monitor -strip` with the file paths as arguments
find temp/images/* -maxdepth 2 -iname "*.jpg" -print0 | xargs -0 mogrify -resize 100x100">" -quality 80 -compress JPEG -monitor -strip
display the filenames which do not have begin with dot (.)
find . -maxdepth 1 -name '[!.]*' -printf 'Name: %16f Size: %6s\n'
Find all directories in maximum 1 level down the current directory that were modified less than 1 day ago
find -maxdepth 1 -type d -mtime -1
List the .py files which reside in the current directory tree and whose parent directory contains a Makefile
find . -name '*.py' -exec bash -c 'test -f $/Makefile' -- {} \; -print
Change directory to the user's home directory
cd
Read a line from standard input with prompt "Are you sure you wish to continue?"
read -p "Are you sure you wish to continue?"
Show the number of lines for each PHP file in the current directory tree
find . -type f -name "*.php" -exec wc -l {} +;
Calculate md5 sum of file $item and save it to variable 'md5'
md5=$(md5sum $item | cut -f1 -d\ )
run programm "/home/oracle/database/runInstaller" as user oracle in background
su oracle -c "/home/oracle/database/runInstaller" &
Recursively change ownership of "/usr/local/lib" to the current user
sudo chown -R `whoami` /usr/local/lib
Pushes current folder to the directory stack.
pushd .
Search the /home/test directory tree for directories and files called '.ssh'
find /home/test -name '.ssh'
Create a table from '111 22 3\n4 555 66\n' with columns separated by a single space
echo -en '111 22 3\n4 555 66\n' | column -t | sed 's/ \/\1/g'
Find all files/directories under current directory and print their paths
find . -exec echo {} +
Search the current directory recursively for files last modified within the past 24 hours ignoring paths ./es* and ./en*
find . -mtime 0 | grep -v '^\./en' | grep -v '^\./es'
Disables shell option 'nullglob'.
shopt -u nullglob
Copy all .patch files from the current directory tree to patches/
find -name '*.patch' -print0 | xargs -0 -I {} cp {} patches/
display all the directories in specific path excluding those that are present in a path and save the ouput to a file
find $x -type d -wholename '*' ! -wholename */@eaDir* > /tmp/mediaindex/$nn.dir
Print summary of new/missing files, and which files differ between dir1 and dir2.
diff --brief --recursive dir1/ dir2/
Search the .java files from the /Applications/ directory tree for TODO lines
find /Applications/ -name "*.java" -exec grep -i TODO {} \;
Get a list of all files in the /home directory tree and their coressponding inode numbers
find /home -type f -printf "%i@%p\n"
Compress every file in the current directory tree that matches "*cache.html" and keep the original file
find . -type f -name "*cache.html" -exec sh -c "gzip < {} > {}.gz" \;
Find all 777 permission regular files and use chmod command to set permissions to 644
find / -type f -perm 0777 -print -exec chmod 644 {} \;
Print file size and user name with color support for each file in the current directory tree
tree -Csu
Find .jpg files owned by user daniel in the current directory and its sub-directories but ignore any file beginning with "autumn".
find . -user daniel -type f -name *.jpg ! -name autumn*
Saves list of currently logged in users in 'userlist' variable.
userlist=$(w|awk 'BEGIN{ORS=","}NR>2{print $1}'|sed 's/,$//' )
Open all .java files in the current directory tree in the vim editor
find . -name '*.java' | xargs vim
Find files bigger than 20 megabytes in the home directory tree
find ~ -size +20M
display all the files in the folder "/Users/Me/Desktop" which have read permission to them
find /Users/Me/Desktop -readable
Create a symbolic link named "/usr/local/bin/subl" to "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl"
sudo ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" /usr/local/bin/subl
Extract rpm "foo.rpm"
rpm2cpio foo.rpm | xzcat | cpio -idmv
Find all files/directories under _CACHE_* directories
find _CACHE_*
Print NS record for domain 'domain.' from 'some.other.ip.address' nameserver
dig @some.other.ip.address domain. ns
Print all files in the current directory as a comma separated list
ls -1 | paste -sd "," -
Recursively finds all '*.pdf' files in a current folder and removes them.
find . -name "*.pdf" -exec rm {} \;
Search for files specifying the maximum depth of the search
find -maxdepth num -name query
Print the full path of command "rails"
which rails
Search /usr/local recursively for directories whose names end with a number 0-9
find /usr/local -type d -name '*[0-9]'
Recursively compresses all files within $2 folder.
find $2 -type f -exec bzip2 {} \;
Dump "a\0b" as hexadecimal bytes
printf "a\0b" | od -tx1
Print a sorted list of directories from the ~/Music tree containing files whose names begin with "cover."
find ~/Music/ -iname 'cover.*' -printf '%h\n' | sort -u
Print the IP address of your SSH session
who am i|awk '{ print $5}'
Print sed commands that would replace all occurrences of 'previousword' with 'newword' in all regular files with '.cpp' extension under '/myprojects' directory tree
find /myprojects -type f -name '*.cpp' -print0 | xargs -0 echo sed -i 's/previousword/newword/g'
Find all files and directories starting from the current directory and excluding hidden files and directories
find . \ | sed 's/^..//'
find all the files in the current folder and display adding quotations to each file
find . -exec echo -n '"{}" ' \;
Print the line with most consecutive repeats prefixed with its count from standard input
uniq -c | sort -n | tail -n1
Print the second line of output of "ls -l"
ls -l | head -2 | tail -1
Measure the disk space taken up by all *.txt files in directory trees folder1 and folder2
find folder1 folder2 -iname '*.txt' -print0 | du --files0-from - -c -s | tail -1
Display standard input as octal bytes
cat | od -b
Find all SGID set files under current directory and show a few lines of output from the beginning
find . -perm /g+s | head
Locate files not owned by any user or group
find / -path /proc -prune -o -nouser -o -nogroup
sort each file in the bills directory, leaving the output in that file name with .sorted appended
find bills -type f | xargs -I XX sort -o XX.sorted XX
Print the current working directory prepended by "pwd: "
echo pwd: `pwd`
Print short TXT record of domain o-o.myaddr.l.google.com from nameserver ns1.google.com
dig TXT +short o-o.myaddr.l.google.com @ns1.google.com
Sort and print each unique line in "myfile.txt"
cat myfile.txt| sort| uniq
Change directory to "/lib/modules/" of the current kernel release
cd /lib/modules/$/
change the permissions of all the directories in the folder "/path/to/someDirectory" to 755
sudo find /path/to/someDirectory -type d -print0 | xargs -0 sudo chmod 755
Get the actual find exectuable path
which find
Create an empty file called "emptyfile.c"
cp /dev/null emptyfile.c
Print revesed second from the end dot-bounded field in $i value
j=`echo $i | rev | cut -d "." -f2`;
display all the ip addresses in all the files that are present in /etc folder
find /etc -exec grep '[0-9][0-9]*[.][0-9][0-9]*[.][0-9][0-9]*[.][0-9][0-9]*' {} \;
Mount "/tmp/loop.img" on "/mnt/image" as a loop back device
mount /tmp/loop.img /mnt/image -o loop
Print the last line of the alphabetically sorted lines in file "set"
tail -1 <(sort set)
Search for files/directories which have read and write permission for their owner, and group and only read permission for others
find . -perm -664
Rename all files in current directory to lowerase.
rename 'y/A-Z/a-z/' *
Prints current directory name
pwd | awk -F/ '{print $NF}'