nl_command
stringlengths
14
387
bash_code
stringlengths
0
532
Archive "fileToCopy" to "/some/nonExisting/dirToCopyTO" on host "ssh.myhost.net" via ssh
rsync -ave ssh fileToCopy ssh.myhost.net:/some/nonExisting/dirToCopyTO
find all the empty directories in the current folder
find . -type d -empty
Remove all files with names like "vmware-*.log" from the current directory tree
find . -name vmware-*.log -delete
find suffix tcl files under all directories started with 'n'
find ./n* -name "*.tcl"
Find all files/directories under current directory and append a null character at the end of each path
find -print0
Print the help message for tree
tree --help
Find all regular files under $dir directory tree that are bigger than $size MB in size and print them along with their sizes in decreasing order of size
find $dir -type f -size +"$size"M -printf '%s %p\n' | sort -rn
Delete all MP3 files under /tmp
find /tmp -iname '*.mp3' -print0 | xargs -0 rm
create directories foo and bar
mkdir foo bar
Find files in the /var/log folder which were modified modified 2 weeks ago
find /var/log/ -mtime +7 -mtime -8
Find any files in the current directory and its sub-directories that were last accessed more than 7 days and are larger than 20480 blocks in size.
find . -atime +7 -size +20480 -print
Find all regular files in the current directory tree whose names end with ".DS_Store" and delete them
find . -type f -name '*.DS_Store' -ls -delete
Find all files under /path/to/dir that were modified less than 7 days ago with null character as the delimiter
find /path/to/dir -type f -mtime -7 -print0
Find all files under current directory and show their file information
find . -type f | xargs file
Remove all directories called "test" from the current directory tree
find -name "test" -type d -delete
Execute "${MD5}" on all files found under "${1}", numerically sort the results, and save to variable "DATA"
DATA=$
create directory dir1
mkdir dir1
search for the word "mysql" in all the files in the current containing the word "notes" in their name. print0 is used to handle files with newlines in their names or those which have only spaces in their names
find . -iname "*notes*" -print0 | xargs -I{} -0 grep -i mysql "{}"
Creates temporary file in $appdir variable with name formatted like expression in variable ${template}, and saves path to it in 'launcherfile' variable.
launcherfile=$(mktemp -p "$appdir" "$template")
Find all files/directories under /path directory that were modified more than 30 minutes ago
find /path -mtime +30m
search for the file "file" in current folder and save the output to the same file
find -name file -fprint file
find all the html files in the current folder which have not been modified in the last 7 days
find . -mtime +7 -name "*.html" -print
Set variable PING to 1 if it's possible to ping host ADDRESS, to 0 otherwise.
PING=$(ping ADDRESS -c 1 | grep -E -o '[0-9]+ received' | cut -f1 -d' ')
display all the files in the current folder excluding the current folder and do not search in the sub directories
find . -maxdepth 1 -type d \( ! -name . \)
Print standard input to standard output line by line, discarding any adjascent duplicate lines.
uniq
Run .makeall.sh in an empty environment.
env -i ./makeall.sh
find all the regular/normal files in the current folder which have been accessed in the last 1440*24 hours and not modified in 1441*24 hours excluding those which are in the custom sub directory tree
ionice -c 3 find . -type f -amin -1440 -mmin +1441 -not -path custom/ -print0
List all environment variables whose name either equals PATH or starts with GOBIN
env | grep '^\'
find all files that are readable or writable by their owner
find . -perm +600 -print
get the root access
sudo su -
display the directory name along with the modified time for all the files /var
find /var -maxdepth 2 -type d -printf "%p %TY-%Tm-%Td %TH:%TM:%TS %Tz\n"
Execute the ruby script "genrc.rb" which will output a filename, and interpret this file in the current shell.
source $
Find files/directories that does not have write permssion for group
find /path ! -perm /g+w
Remove trailing white spaces from all files under current directory ignoring directories wtih *.git* (case insensitive) in their paths and keep backups of the originals
find . -type f -not -iwholename '*.git*' -print0 | xargs -0 sed -i .bak -E "s/[[:space:]]*$//"
get a PID of a process with name 'test.sh &'
jobs -l | grep 'test.sh &' | grep -v grep | awk '{print $2}'
List all empty files under the current directory
find . -maxdepth 1 -empty
ssh into "ssh.myhost.net" as user "myusername" and run command "mkdir -p $2"
ssh [email protected] "mkdir -p $2"
find all files in the file system whose size is bigger than 3GB
find / -size +3G
Find all files whose owner is `user1'
find / -user user1
Allocate a pseudo-terminal and execute "screen -r -X ls" which executes "ls" within the screen session on host "example.com"
ssh -t example.com "screen -r -X ls"
find file which case-insensitive name is too in currect directory
find . -iname foo
Search for all files newer than file /tmp/t
find / -newer /tmp/t
Show all files that have not been accessed in the $HOME directory for 30 days or more
find $HOME -atime +30
Check that the master SSH control socket "my-ctrl-socket" to "[email protected]" is running
ssh -S my-ctrl-socket -O check [email protected]
display all the symbolic links in the current folder
find . -type l
Search the files from the current directory tree for "foo"
find . -exec grep foo {} \;
copy all the files with the extension ".type" from one folder to a target directory
find "$sourcedir" -type f -name "*.type" | xargs cp -t targetdir
find all directories with the name test in a directory
find /home/john -type d -name test -print
Brings down network interface eth0.
ifconfig eth0 down
Print the sorted unique column of usernames of users who are currently logged in without the header
finger | tail -n +2 | awk '{ print $1 }' | sort | uniq
Start bash in a completely empty environment, without parsing /etc/bashrc or ~/.bashrc
env -i bash --norc
Search the current directory tree for files named 'Subscription.java'
find . -name 'Subscription.java'
Find all files recursively starting from / that have been modified in the past 30 minutes and list them
find / -mmin -30 -ls
find all the directories in the folder /raid with the extension local_sd_customize.
find /raid -type d -name ".local_sd_customize" -print
Print a randomly sorted list of numbers from 1 to 10 to file "/tmp/lst" and the screen followed by " -------"
seq 1 10 | sort -R | tee /tmp/lst |cat < <
Find all *bar files/directories under current directory
find -name *bar
change owner of the file destination_dir to user "user:
chown user destination_dir
List all files/directories under /data1/Marcel which are greater than 524288 bytes and were modified or accessed more than 1 year ago
find /data1/Marcel -size +1024 \ -ls
find all the files in the folder "myfiles" which have been modified exactly 48 hours back.
find /myfiles -mtime 2
display all the files in the current folder which have not been modified in the last 7 days and which are not in the list "file.lst"
find -mtime +7 -print | grep -Fxvf file.lst
Save standard input to variable "myVar"
myVar=$(tee)
Split "foo.txt" into files with 1 line each and use a suffix length of 5
split --suffix-length=5 --lines=1 foo.txt
Report file system containing the current directory disk usage
df .
Read a line of standard input into variable "input_cmd" with prompt "command : "
read -p "command : " input_cmd
search for version in system.info files.
find /home/*/public_html/ -type f -iwholename "*/modules/system/system.info" -exec grep -H "version = \"" {} \;
file all the Sticky Bit set files whose permission are 551
find / -perm 1551
Split "input.txt" into files of at most 10 bytes each with prefix "xxx/split-file"
split -b 10 input.txt xxx/split-file
Find "file.xml" under the current directory and change directory to its parent
cd `find . -name file.xml -printf %h`
List all files in the /var directory tree whose size is greater than 10 megabytes
find /var/ -size +10M -ls
List all *.txt files/directories under current directory
find . -name *.txt -exec ls {} \;
Run 'somecommand' in an environment without the FOO variable.
env -u FOO somecommand
change permissions of all the script files in a directory
find /home/john/script -name "*.sh" -type f -exec chmod 644 {} \;
Find all MP3 files in the home directory tree that were modified in the last 24 hours
find ~ -type f -mtime 0 -iname '*.mp3'
Search the home directory for files accessed more than 10 days ago
find ~/ -atime +10
Force create a symbolic link named "$*" to the canonical absolute path of "$1"
ln -sf "$(readlink -f "$1")" "$*"
Write "deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen" to standard output and append to "/etc/apt/sources.list.d/10gen.list" as root
sudo echo "deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen" | sudo tee -a /etc/apt/sources.list.d/10gen.list
Find the total size of *.jpg files within the directory tree ./photos/john_doe
find ./photos/john_doe -type f -name '*.jpg' -exec du -ch {} + | grep total$
Format time string @$TIMESTAMP according to default time format
date -d @$TIMESTAMP
Find all files under current directory that were modified more than 1 day ago
find -mtime +1
find all the file that have not been modified in the last 3 days ( considers day starting not 24 hours )
find ./ -daystart -mtime +3
Read a line from standard input with prompt "Is this a good question (y/n)? " and save the response to variable "answer"
read -p "Is this a good question (y/n)? " answer
Find all regular files under $d directory tree and change their permissions to 777
find "$d/" -type f -print0 | xargs -0 chmod 777
Find all files/directores under '/usr/local' directory tree that contain the word 'blast' in their names
find /usr/local -name "*blast*"
Force create a symbolic link named "id_rsa" to "$keyname"
ln -sf $keyname id_rsa
Find all files named `file1' on the system
find / -name file1
Recursively from current folder searches only files that names match ".*xxx" pattern, ignores binary files and prints file name before every string that contains "my Text to grep".
grep --include="*.xxx" -nRHI "my Text to grep" *
Search the /path directory recursively for TXT files
find /path -type f -iname "*.txt"
Counts lines in each *.php file.
wc -l `find . -name "*.php"`
Locate all *.csv files under the current directory tree
find . -name "*.csv"
List all files from the current directory tree that were modified less than 60 minutes ago
find . -mmin -60 | xargs -r ls -ld
Print a line of "$variable" '-' characters
printf '%0.s-' $
display a long listing of all the files in the current folder which are bigger than 10KB
find . -size +10k -exec ls -lh {} \+
display all the files in the current folder which are bigger than 100MB and save the output list to the file /root/big.txt
find \( -size +100M -fprintf /root/big.txt %-10s %p\n \)
Find all *.txt files/directories under current directory
find -name \*.txt
delete all the empty files in the current folder
find . -empty -delete -print
Find all directories under current directory and change their permission to 755
find . -type d -exec chmod 755 {} \;
display list of all the regular/normal files in the current folder which start with "my"
find . -name 'my*' -type f -ls
display a long listing of all the xls or csv files in the entire file system
find / -regex ".*\.\(xls\|csv\)"
Find all CSS files
find . -name "*.css"
List all files that are between 10000 and 32000 bytes in size
find . -size +10000c -size -32000c -print