nl_command
stringlengths
14
387
bash_code
stringlengths
0
532
Find all files files under the current directory except *.txt
find . -maxdepth 1 -type f -not -regex '.*\.txt'
Recursively removes all files like '*.pyc' of '*.pyo' in a current folder without prompting.
find . -type f -name "*.py[c|o]" -exec rm -f {} +
Give all files in the /path/to/base/dir tree read privileges
find /path/to/base/dir -type f -print0 | xargs -0 chmod 644
Find all the files in the current directory recursively whose permissions are 777
find . -type f -perm 0777 -print
Find all regular files in the current directory tree and count them
find -type f -printf '.' | wc -c
find all the files that were changed within the last 24 hours
find / -ctime -1
Kill process named "python csp_build.py".
ps aux | grep 'python csp_build.py' | head -1 | tr -s ' ' | cut -d " " -f2 | xargs kill
find files in /tmp directory that named are core and deletes them, single or double quotes, spaces or newlines are correctly handled
find /tmp -name core -type f -print0 | xargs -0 /bin/rm -f
create a hard link as directory named "new_hard_link" to the directory "existing_dir" as root
sudo ln -d existing_dir new_hard_link
Find all files and directories and count them
find ./ | wc -l
Find the most recently changed files in a subtree
find . -type f -printf '%TY-%Tm-%Td %TT %p\n' | sort
Search for "foo" in every file in the current directory and number the output
grep foo * | nl
Changes group ownership of '/etc/btsync/[prefered conf name].conf' to 'btsync'.
chgrp btsync /etc/btsync/[prefered conf name].conf
find not case sensitive all directories that names are 'apt' and display details
find / -type d -iname "apt" -ls
Read the history file and append the contents to the history list
history -r
display all the files in the current folder which have been accessed in the last 60 minutes
find . -amin -60
Check if "/path/to/file" exists on remote host "host"
ssh host "test -e /path/to/file"
List each file or directory in the current directory prefixed by its human readable filesize and sorted from largest to smallest
du -h --max-depth=0 * | sort -hr
Recursively finds all files containing text 'OPEN' and prints folder where they are placed.
grep -r OPEN * | awk '{split; print path[1]}' | xargs -I{} dirname {}
Print the absolute path of "$path"
readlink -f "$path"
Archive directory specified by variable "myFolder" to current directory.
rsync -av $myFolder .
display all the files in the current folder along with the change time and display file names of the last 10 changed files
find . -type f -printf "%C@ %p\n" | sort -rn | head -n 10
Strips last section from the path $pathname, and prints basename of the rest part.
echo $(basename $)
Display a sorted count of all the characters in "filename"
fold -w1 filename | sort | uniq -c | sort -nr
Find files in $DIR_TO_CLEAN that are older than $DAYS_TO_SAVE days and print them with null character appended to their paths
find "${DIR_TO_CLEAN?}" -type f -mtime +${DAYS_TO_SAVE?} -print0
Run commands "df -k;uname -a" on server "192.168.79.134"
echo "df -k;uname -a" | ssh 192.168.79.134
Find all regular files in the current directory tree last modified between 1 and 3 days ago and list them using find's -ls option
find ./ -daystart -mtime -3 -type f ! -mtime -1 -exec ls -ld {} \;
sort based on size and display top ten largest normal/regular files in the current folder
find . -type f -exec ls -s {} \; | sort -n -r | head -10
Search the current directory tree for .rb files ignoring the "./vendor" subdirectory
find . -name '*.rb' ! -wholename "./vendor/*" -print
Count the *.html files residing in the /usr/src directory tree and containing string "foo"
find /usr/src -name "*.html" | xargs grep -l foo | wc -l
display all the files in the folder "/Users/Me/Desktop" which belong to the user "popo" and which have the permission 777
find /Users/Me/Desktop -user popo -perm 777
Gets IP address of eth0 network interface.
ifconfig eth0 | grep addr: | awk '{ print $2 }' | cut -d: -f2
Show filename and filetype description of all PHP files in current directory whose name or filetype description includes "UTF"
file *.php | grep UTF
Find the process currently taking the most CPU time.
top -b -n1 -c | grep -A 2 '^$'
Convert all m4a sound files in a directory and its subdirectories to mp3 files
find . -type f -name '*.m4a' -exec bash -c 'avconv -i "$0" "${0/%m4a/mp3}"' '{}' \;
List the unique file extensions of all files under the current directory
find . -type f | grep -o -E '\.[^\.]+$' | sort -u
Run 'git pull' in every subdirectory of the current directory
find . -mindepth 1 -maxdepth 1 -type d -print -exec git -C {} pull \;
Find all the files in file system which are accessed in last 1 hour
find / -amin -60
List all regular files residing in the current directory tree and containing string "/bin/ksh"
find . -type f -print | xargs grep -li 'bin/ksh'
find all the files in the file system which have been changed in the last 24 hours.
find / -ctime -1
Set permissions to 700 for directories under media/
find media/ -type d -exec chmod 700 {} \;
SSH into server "server.com" as user "remote_user"
Print the file sizes along with their paths for all *.txt files/directories under current directory tree
find . -iname "*.txt" -exec du -b {} +
search for all the foo.txt files in the current folder and move them to another location
find . -name foo.txt -print0 | xargs -0 -I{} mv {} /some/new/location/{}
Replace any sequence of spaces in file 'text.txt' with single space and print 4th space separated field
cat text.txt | tr -s ' ' | cut -d ' ' -f 4
Attaches to a 'session name' tmux session.
tmux attach -t <session name>
Measure the execution time of the command: find /usr/src -name "*.html" -exec grep -H "foo" {} ';' | wc -l
time find /usr/src -name "*.html" -exec grep -H "foo" {} ';' | wc -l
Prints a random number between 1 and 10
grep -m1 -ao '[0-9]' /dev/urandom | sed s/0/10/ | head -n1
Print "I am USER and the program named ls is in LS_PATH" where "USER" is the current user's user name and "LS_PATH" is the full path of the command "ls"
echo I am $(whoami) and the program named ls is in $(which ls).
Find files under /some/path that are not executable
find /some/path -type f ! -perm -111 -ls
Find all 'custlist*' files under current directory
find . -name custlist\*
Copy all files with '.png' (case insensitive) extension under '/home/mine' directory tree to '/home/mine/pngcoppies/' directory with new names constructed by prepending 'copy' in their names
find /home/mine -iname "*.png" -printf "%P\n " | xargs -I % -n1 cp % /home/mine/pngcoppies/copy%
Find all files in maximum 1 level down the current directory that were modified less than 1 day ago
find -maxdepth 1 -type f -mtime -1
Find a.out and object files in the current directory tree
find . -print
Find all files in the current directory tree and replace string $1 with string $2 in them
find ./ -type f -exec sed -i "s/$1/$2/" {} \;
Remove all files named "filename" from the current directory tree, ignoring directory "FOLDER1"
find . -name FOLDER1 -prune -o -name filename -delete
Print a listing of the `other' directory
find other -maxdepth 1 -printf "%P\n"
find for the word "dba_2pc_pending" in all the files of current fodler having the word "sql" in their name
find . -print|grep sql|xargs grep -i dba_2pc_pending
Locate files that reside in the home directory and have not been accessed in the past 30 days
find $HOME -atime +30
Find all *.php and *.js files under /home/jul/here excluding /home/jul/here/exclude/* paths
find /home/jul/here -type f \ ! -path "/home/jul/here/exclude/*"
display all the regular files in current folder
find . -type f
display the count of regular/normal files in the current folder do not search in sub directories
find . -maxdepth 1 -type f |wc -l
Delete empty directories
find . -type d -empty -delete
Save absolute path of "$path" whose parents exist to variable "abspath"
abspath=$(readlink -f $path)
List all SGID and SUID files in entire file system
find / -type f \ -ls
Prints running process that has id 'pid' with command line arguments.
pstree -a pid
display all the files in the current folder excluding those that are present in the folder "secret"
find . \ -o -print
Find all the files which are modified in last 1 hour
find / -mmin -60
Remove duplicate lines in "file_name" and print the output on stdout
awk '{print(NR"\t"$0)}' file_name | sort -t$'\t' -k2,2 | uniq --skip-fields 1 | sort -k1,1 -t$'\t' | cut -f2 -d$'\t'
Repeat "image.png" 10 times on a single line
echo $(yes image.png | head -n10)
display all files in the current folder which do not belong to the user john
find . ! -user john
Search for command "tail" in the maps of the process with PID 2671
cat /proc/2671/maps | grep `which tail`
find all raw images in the current folder and pass them one at a time to the xargs command and enable parallel processing of the files
find . -type f -iname '*.CR2' -print0 | xargs -0 -n 1 -P 8 -I {}
Find all empty directories recursively starting from the current one and delete them
find . -type d -empty -delete
display the three largest files by size in current folder
find . -type f -exec ls -s {} + | sort -n -r | head -3
List all regular files modified more than 61 days
find -type f -mtime 61 -exec ls -ltr {} \;
Adds execution permissions on a script ./etc/bash_completion within Homebrew home folder path.
chmod +x $/etc/bash_completion
Find all .txt files in the current directory tree and edit them with `vim'
find . -name "*.txt" | xargs vim
find all files named `linux' on the system
find / -name linux
Search the directory tree given as variable $dir for regular files
find $dir -type f
Find all .py files in the current directory except "setup.py" and those beginning with "test_"
find . -maxdepth 1 -mindepth 1 \
Verbosely compresses all files on sixth and seventh depth level keeping original files in place.
bzip2 -kv */*/*/*/*/*/*
find a file in current folder and discard the errors
find /. -name 'toBeSearched.file' 2>/dev/null
Find all files under current directory and change their permission to 644
find . -type f -exec chmod 644 {} \;
Mount "ext4" filesystem "/dev/xvdf" on "/vol"
sudo mount /dev/xvdf /vol -t ext4
search a url in all regular/normal files in a folder.
find ./ -type f -exec grep https://www.ksknet.net {} \;
Find all files that were not accessed in the past 100 days
find /home -atime +100
Find all .php files in all directory trees matching pattern `/srv/www/*/htdocs/system/application/' and search those files for string "debug ("
find /srv/www/*/htdocs/system/application/ -name "*.php" -exec grep "debug (" {} \; -print
Find all loadable modules for current kernel, whose name includes "perf"
find /lib/modules/`uname -r` -regex .*perf.*
find all the normal/regular files in the current directory which have been modified in the last 24 hours
find . -mtime -1 -type f -print
search for the file "process.txt" in the current directory
find . -name "process.txt"
Numerically sort standard input by the second word of each line and output from greatest value to least value
sort -nrk 2,2
Give the location of every hard link to file1 in the /home directory tree
find /home -xdev -samefile file1 | xargs ls -l
Extract 8 bytes as an unsigned integer that is "$o" offset into "$pkg"
set `od -j $o -N 8 -t u1 $pkg`
Pushes to the dirs stack directory path of the current script, or current directory path if executed from bash shell.
pushd $
Recursively removes all files like any-cased '*.pyc' in a current folder.
find . -iname '*.pyc' -print0 | xargs -0 --no-run-if-empty rm
Search the current directory tree for symlinks whose contents match pattern "*sysdep.c"
find . -lname '*sysdep.c'
split content of the files *.txt beginning with 1001st line into pieces per 1000 lines
cat *.txt | tail -n +1001 | split --lines=1000
Find all mysong.ogg files/directories under your home directory
find $HOME -name 'mysong.ogg'
List all files in the "test" directory tree except those with '/invalid_dir/' in the pathnames
find test -print | grep -v '/invalid_dir/'