nl_command
stringlengths
14
387
bash_code
stringlengths
0
532
display all directories in current folder
find -type d
Sets shell option 'extglob'.
shopt -s extglob
Count md5sum of all '*.py' files in a current folder with subfolders.
find /path/to/dir/ -type f -name "*.py" -exec md5sum {} + | awk '{print $1}' | sort | md5sum
Make directory "~/public_html"
mkdir ~/public_html
delete all the empty in the current folder do not search in sub directories
find . -maxdepth 1 -type d -empty -exec rm {} \;
Find all *.epub, *.mobi, *.chm, *.rtf, *.lit and *.djvu files/directories under current directory
find ./ -name '*.epub' -o -name '*.mobi' -o -name '*.chm' -o -name '*.rtf' -o -name '*.lit' -o -name '*.djvu'
display a long listing of the files all non emoty files in current folder which have been modified 60 minutes ago
find . -mmin 60 -print0 | xargs -0r ls -l
Find regular files named "regex" under and below /dir/to/search/
find /dir/to/search/ -type f -name 'regex' -print
Set timestamp of old_file.dat to specified timestamp.
touch -t 200510071138 old_file.dat
Composes full process tree with process id numbers, and prints only those strings that contain 'git'.
pstree -p | grep git
Finds out what groups a current user has.
groups
Search for files/directories named 'fileName.txt' under '/path/to/folder' directory tree without traversing into directories that contain the string 'ignored_directory' in their paths
find /path/to/folder -path "*/ignored_directory" -prune -o -name fileName.txt -print
Find all regular files in the current directory tree and count them
find -type f | wc -l
display all the files in current folder which have been changed in the last 2-6 days
find . -cmin +2 -cmin -6
set alias "unix" for command "date +%s"
alias unix="date +%s"
Find all files starting from the current directory which are owned by the user tommye
find . -user tommye
display all the files in the home folder which begin with "arrow"
find ~ -name 'arrow*'
Updates all packages with 'rpmfusion' in name.
yum update $
Print the top 10 commands with their use count
history | awk '{ print $2 }' | sort | uniq -c |sort -rn | head
display all files in the directory "dir" which have been changed in the last 60 minutes
find /dir -cmin -60
Find all *shp* files/directories under current directory and move them to ../shp_all/
find . -name "*shp*" -exec mv {} ../shp_all/ \;
Find the files in the current directory that match pattern '*.JUKEBOX.*.txt' and move them to folder ./JUKEBOX
find . -name '*.JUKEBOX.*.txt' -maxdepth 1 -print0 | xargs -0 -IFILE mv FILE ./JUKEBOX
Copy the entire "/lib" and "/usr" directory including symlinks from "[email protected]" to "$HOME/raspberrypi/rootfs" and delete files after the transfer
rsync -rl --delete-after --safe-links [email protected]:/{lib,usr} $HOME/raspberrypi/rootfs
Compare "current.log" and "previous.log" line by line and print lines containing regex pattern ">\|<"
diff current.log previous.log | grep ">\|<" #comparring users lists
Find regular files readable by the world
find . -perm -g=r -type f -exec ls -l {} \;
Find all regular files on the system whose size is greater than 20000k and print their names and sizes
find / -type f -size +20000k -exec ls -lh {} \; | awk '{ print $8 ": " $5 }'
find list of all files with file permission , link , owner , group , reation time , size , file name
find . -exec ls -ld {} \;
Save the latest modification time (in format "%T@ %t" of any file under "./$dir" to variable "timestamp"
timestamp=$(find ./$dir -type f -printf "%T@ %t\\n" | sort -nr -k 1,2 | head -n 1)
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" --
Display unique names of logged in users
finger | sed 's/\t/ /' | sed 's/pts\/[0-9]* *[0-9]*//' | awk '{print $2"\t("$1")\t"$3" "$4" "$5}' | sort | uniq
Check if the file "somelink" links to exists
ls `readlink somelink`
Search for files/directories which are writable by either their owner or their group
find . -perm /u=w,g=w
Find all files/directories under current directory and run ipython nbconvert for each of them with the file/directory path as a argument by changing into the parent directory
find -execdir ipython nbconvert {} \;
change the ownership of all directories in the current folder
find . -type d -exec chown username {} \;
Prints hierarchical process tree.
pstree
Make directories as needed in "dest" for every directory found under "src/"
find src/ -type d -exec mkdir -p dest/{} \;
search in current directory downwards all files whose status has changed more then 7 days ago
find . -ctime +7 -print
Show a long listing of the latest file or directory under current directory
ls -lrt | tail -n1
Split "file.txt" into files of at most 1 MiB in size with a numeric suffix, prefix "file", and additional suffix ".txt"
split -b 1M -d file.txt file --additional-suffix=.txt
find all the directories with the name "DIRNAME" in the current folder and force delete them
find . -type d -name “DIRNAME” -exec rm -rf {} \;
Print the contents of "~/.ssh/config"
cat ~/.ssh/config
Removes all empty folders under current path, aged between 'first' and 'last' timestamps.
find . -newer first -not -newer last -type d -print0 | xargs -0 rmdir
Find all directories in the current directory tree
find -type d
List all files in /home/bozo/projects directory tree that were modified within the last day.
find /home/bozo/projects -mtime -1
display long listing of all regular/normal files whose size is less than 50 bytes.
find /usr/bin -type f -size -50c -exec ls -l '{}' ';'
Find all directories under current directory and run ./script.sh for each of them
find . -type d -exec ./script.sh {} \;
Delete all non digits from index "$i" in bash array "depsAlastmodified" and print the hex dump as characters
echo "${depsAlastmodified[$i]}" | tr -cd '[[:digit:]]' | od -c
Print lines that only unique ones in 'set1' and 'set2' files
cat < <
display long listing of all files in the current directory whose size is 24 or 25 bytes.
find . -size -26c -size +23c -ls
find all *.java files/directories under current directory
find . -name \*.java
Search directory trees /usr/share/doc, /usr/doc, and /usr/locale/doc for files named 'instr.txt'
find /usr/share/doc /usr/doc /usr/locale/doc -name instr.txt
Find directories that are directly under /home/user/workspace directory and were modified more than 30 days ago and print a message saying that the directory wasn't modified during last 30 days
find /home/user/workspace -mindepth 1 -maxdepth 1 -type d -mtime +30 -printf "\t- It seems that %p wasn't modified during last 30 day\n"
search for all the php files in current directory and check for their syntax .
find . -name \*.php -type f -exec php -l {} \;
For each line in 'file', print "result = " followed by the line backwards.
awk '{print "result =",$0}' <(rev file)
find all files that names are 'apt'
find / -name "apt"
Format the date represented by time string @1267619929 according to default format and print it
date -ud @1267619929
Prints list of folders containing '.git', searching recursively from a current folder.
find . -name '.git' | xargs -n 1 dirname
display all files in a folder
find "/proc/$pid/fd"
Find all regular files starting from level 3 of directory tree ~/container and move them one level up
find ~/container -mindepth 3 -type f -execdir mv "{}" ./.. \;
Move all directories from the `sourceDir' directory tree to the `destDir' directory
find sourceDir -mindepth 1 -type d -exec mv -t destDir "{}" \+
as root, find from / all files called "file.txt"
sudo find / -name file.txt
Use the octal form to find and print detailed information about all regular files in your home directory and below that have only the group permission set.
find . -perm 040 -type f -exec ls -l {} \;
Find all regular files under current directory (excluding hidden directories) and replace every occurrences of 'subdomainA.example.com' with 'subdomainB.example.com' in those files
find . \( ! -regex '.*/\..*' \) -type f -print0 | xargs -0 sed -i 's/subdomainA.example.com/subdomainB.example.com/g'
Find all files with 644 permission and change the permission to 664
find . -type f -perm 644 -exec chmod 664 {} \;
create directory foo
mkdir foo
Find all files with '.db' extension that belong to user 'exampleuser' and were modified exactly 7 days ago under '/home' directory tree
find /home -user exampleuser -mtime 7 -iname ".db"
Write output of "command_that_writes_to_stdout" to standard output and as input to "command_that_reads_from_stdin"
command_that_writes_to_stdout | tee >
Find all Lemon*.mp3 files under current directory and run mplayer with these files
find . -name 'Lemon*.mp3' -exec mplayer {} ';'
Shows size of compressed file in .bz2 archive.
bunzip2 -c bigFile.bz2 | wc -c
Create a rsa key with comment specified by variable APP and passphrase specified y SSHKEYPASS.
ssh-keygen -t rsa -C "$APP" -N "$SSHKEYPASS" -f ~/.ssh/id_rsa
Find all *.ogg files under your home directory that are less than 100MB in size
find $HOME -iname '*.ogg' -type f -size -100M
Delete files with inode number specified by [inode-number] under current directory
find . -inum [inode-number] -exec rm -i {} \;
Search the current directory tree for files whose name is ".note", case insensitive
find . -iname '.note' | sort
Search the `research' directory and one level below for directories that are not owned by group `ian'
find -L research -maxdepth 2 -type d ! -group ian
Forcibly removes files '/tmp/stored_exception', '/tmp/stored_exception_line', '/tmp/stored_exception_source'
rm -f /tmp/stored_exception /tmp/stored_exception_line /tmp/stored_exception_source
Print the number of lines for each *.txt file from the $DIR directory tree
find $DIR -name "*.txt" -exec wc -l {} \;
Output all lines in 'file' which contain a tab character.
awk -F"\t" 'NF>1' file
Prints the first N bytes of file.txt
head -c N file.txt
display all the files in the current folder excluding the directory aa
find . -type d ! -name aa
Find all files on your system that are world writable
find / -wholename '/proc' -prune -o -type f -perm -0002 -exec ls -l {} \;
Print all lines from file 'report.txt' containing any-cased 'error' pattern
cat report.txt | grep -i error
Set the modification timestamp of file 'filename' to specified date/time.
touch -m --date="Wed Jun 12 14:00:00 IDT 2013" filename
List the current directory recursively ignoring the "dir1" subdirectory
find . -path ./dir1 -prune -o -print
search for all the Joomla's version.php files in various directories and display the latest versions of it.
find /var/www/vhosts/*/httpdocs -type f \ -print0 -exec perl -e 'while { $release = $1 if m/ \$RELEASE\s+= ..;/; $dev = $1 if m/ \$DEV_LEVEL\s+= ..;/; } print qq;' {} \;
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
Remount "/dev/block/mtdblock3" on "/system" with read only permission
mount -o remount,ro -t yaffs2 /dev/block/mtdblock3 /system
list complete path name to process associated with pid "$1"
find /proc/$1/exe -printf '%l\n'
search for the regular/normal file 'myfile' in the folder /root excluding those that are present in the "work" directory
find /root/ -name 'work' -prune -o -name myfile -type f -print
Execute "chown -R ask:ask /www/askapache.com" in the background on server "askapache" with a niceness of 19
ssh askapache 'nice -n 19 sh -c "( & )"'
Print IP addresses of the current host
hostname -I|cut -d" " -f 1
Print content of /etc/passwd and /etc/group files
cat /etc/passwd /etc/group
Display a long listing of all 0777 permission directories under current directory tree
find . -perm 0777 -type d -exec ls -l {} \;
Print the total disk usage in bytes of all files listed in "files.txt"
cat files.txt | xargs du -c | tail -1 | awk '{print $1}'
Find all files/directories under current directory tree whose names start with 'some_text_2014.08.19'
find . -name 'some_text_2014.08.19*'
Remount "/media/Working/" with a umask of 000
mount /media/Working/ -oremount,umask=000
find all files in the current directory which are bigger than 2MB
find -size +2M
remove a specific file among a group of specific files
find . -name "*.pdf" -print | grep -v "^\./pdfs/" | xargs -J X mv X ./pdfs/
Recursively removes all files like "(__pycache__|\.pyc|\.pyo$)" in a current folder.
find . | grep -E "(__pycache__|\.pyc|\.pyo$)" | xargs rm -rf
display all the files in the current folder expect perl shell and python fiels
find . -not -name "*.pl" -not -name "*.sh" -not -name "*.py"
Search the /myfiles directory tree for regular files with at least these permissions: 647
find /myfiles -type f -perm -647