nl_command
stringlengths
14
387
bash_code
stringlengths
0
532
Search the regular files of the current directory tree for string "whatever"
find . -type f | xargs -L 100 grep whatever
Rename "file.txt" in directories "v_1", "v_2", and "v_3" each to "v_1.txt", "v_2.txt", and "v_3.txt" respectively and print the conversion
rename -v 's#/file##' v_{1,2,3}/file.txt
Page through the contents of 'file', but excess from lines that don't fit within the screen/window width is cut.
less -S file
Recursively changes group ownership of every file in '/var/tmp/jinfo' to 'www-data'.
chgrp -R www-data /var/tmp/jinfo
Copy all files from the current directory tree to /path/to/destination/dir preserving their times, permissions, and ownership
find . | cpio -pdumv /path/to/destination/dir
display all the directories in the current folder for the files which have not been accessed in the last 48 hours
find . -type d -atime +2
Move files older than 1 day to directory TMP
find . -atime +1 -type f -exec mv {} TMP \;
Find *.avi and *.flv files in /path/to/your/directory and below and copy them to /path/to/specific/folder
find /path/to/your/directory -regex '.*\.\(avi\|flv\)' -exec cp {} /path/to/specific/folder \;
Md5sum the last 5 files in /directory1/directory2/
find /directory1/directory2/ -maxdepth 1 -type f | sort | tail -n 5 | xargs md5sum
Find all files in current directory excluding hidden files, archive them and put the output into variable full_backup_dir
full_backup_dir="$(find . -depth \ -prune -o -print | cpio -oav)"
force remove all the regular/normal files which begin with sess in the temp folder
find /tmp -type f -name sess* -exec rm -f {} \;
Find all *.jpg files in */201111 paths
find */201111 -name "*.jpg"
Find files with pattern "*[!0-9][1-9].txt" and execute chmod and ls command with AND condition then sort the output
sudo find -name "*[!0-9][1-9].txt" -exec chmod 744 '*' {} \; -a -exec ls -l {} \; | sort | parallel ls -l
Find all catalina* files/directories under /path/to/search/in
find /path/to/search/in -name 'catalina*'
download content from "http://127.0.0.1:8000" and output to "index.html"
curl http://127.0.0.1:8000 -o index.html
Archive "/source/backup" to "/destination" with compression during transfer
rsync -ravz /source/backup /destination
display all the .sh scripts in the folder /usr
find /usr -name \*.sh
List all files/directories under current directory matching the posix-egrep type regex ".+\.$" in their names excluding the files that contain 'generated' or 'deploy' in their paths
find . -regextype posix-egrep -regex '.+\.$' -print0 | grep -vzZ generated | grep -vzZ deploy | xargs -0 ls -1Ld
List all files under current directory matching the regex '.*\.\'
find . -type f -regex '.*\.\' -exec ls {} \;
Gets list of folders containing files with changes.
git diff --name-only | xargs dirname | uniq
Calculate the total size of all *.jpg files in the directory tree
find . -name "*jpg" -exec du -k {} \; | awk '{ total += $1 } END { print total/1024 " Mb total" }'
Copy all files matching "*.sh" in "$from/*" to "root@$host:/home/tmp/" compressing data during transmission
rsync -zvr --include="*.sh" --exclude="*" $from/* root@$host:/home/tmp/
display all files which have been modified between two dates in current folder
find . -type f -newermt "2014-01-01" ! -newermt "2014-06-01"
Force create a symbolic link without dereferencing named "alpha" to "alpha_2"
ln -nsf alpha_2 alpha
change owner of the file /home/bob to user root
sudo chown root /home/bob
Find all files/directories under '/home/user/' directory tree whose status were changed 10 minutes ago
find /home/user/ -cmin 10 -print
Find all *.mov files under current directory and run an ffmpeg command with the path and the name for each file
find . -iname "*.mov" -print0 | xargs -0 -i sh -c 'ffmpeg -i {} -f flv `basename {}`'
Find all regular files with name pattern $filename under $fileloc directory tree
find "$fileloc" -type f -prune -name "$filename" -print
Find files on the system created during the last 50 days
find / -ctime -50
Copy recursively "tata/" to "tata2/" and remove read, write, and execute permission for other
rsync -avz --chmod=o-rwx -p tata/ tata2/
find all the findme.txt files in the file system
find / -name findme.txt -type f -print
Count all the lines of all files with names ending with 'php' in current directory recursively
find -name '*php' | xargs cat | wc -l
Search for all the directories in directories taken from the glob pattern '/path/to/folders/*' and add the extension ".mbox" to all and create directories named 'Messages' inside them
find /path/to/folders/* -type d -exec mv {} {}.mbox \; -exec mkdir {}.mbox/Messages \;
search for all text files in the directory "/path/to/inputfiles" and pass them as input to the shell script in exec command and save the output to the file out.txt
find /path/to/inputfiles -name "*.txt" -exec /path/to/myprogram.sh {} \; > Out.txt
Look for `regexp' in binary files
find . -type f -print|xargs file|grep -i text|cut -fl -d: | xargs grep regexp
search for all regular/normal files in current folder and display all the files which contain 16 lines
find . -type f -print0 | xargs -0 grep -cH '' | awk -F: '$2==16'
Check if process ID 1 exists and current user has permission to send it signals.
kill -0 1
display all the text and pdf files in the current folder
find . -regex ".*\(\.txt\|\.pdf\)$"
Print the contents of "${SPOOL_FILE}" file to the console and append to "${LOG_FILE}" file
cat ${SPOOL_FILE} | tee -a ${LOG_FILE}
Find all files that have wrong permission
find / \ \ -ls
Print the type of the current shell
echo $
Mount "proc" file system on "/var/snmp3/proc"
mount -t proc none /var/snmp3/proc
Find all *.mp3 files in entire file system greater than 10MB and delete them
find / -type f -name *.mp3 -size +10M -exec rm {} \;
find all the video files in the home folder
find ~ -type f -exec file -i {} + | grep video
Set 644 permission to all regular files under current directory
find . -type f -exec chmod 644 {} \;
Creates temporary file and saves path to it in 'fif2' variable.
fif2=$(mktemp -u)
Save the full path of command "~/f" to variable "foo"
foo=`which ~/f`
Test if files named 'something' were found in YOUR_DIR
[[ ! -z `find 'YOUR_DIR/' -name 'something'` ]] && echo "found" || echo "not found"
looks for all files larger than 10 megabytes within /home
find /home -type f -size +10485760c -print
search for MP3 files in the current folder and subfolders exclude dir1 AND dir2
find ! -path "dir1" ! -path "dir2" -iname "*.mp3"
search for all the regular/normal files in the /etc folder which have been modified in the last 24 hours
find /etc/ -type f -mtime -1
Display PHP info one page at a time, pausing for user interaction after each page.
php -i | more
Print input "your, text, here" formatted to fit 70 characters per line breaking at spaces
echo 'your, text, here' | fold -sw 70
Change all directories under "./storage/" to owner "apache" and group "laravel"
sudo find ./storage/ -type d -exec chown apache:laravel {} \;
Search for .bam files anywhere in the current directory recursively
find . -name "*.bam"
Look for any files that have not been modified in the last two days
find -mtime +2
Finds recursively and following symlinks from root folder all files that contain "text-to-find-here" and prints files names.
grep -Ril "text-to-find-here" /
Print lines containing string TEXT from all log files in the current directory.
grep -e TEXT *.log | cut -d':' --complement -s -f1
Find all regular files in the current directory tree ignoring GIT and SVN directories
find . \( -type d -regex '^.*/\.\(git\|svn\)$' -prune -false \) -o -type f -print0
find all the jpg files in the entire file system and discard all the errors.
find / -name *.jpg 2>/dev/null
Find all directories starting from root that contain the string "99966" in their names
find / -type d -name "*99966*" -print 2>/dev/null
Find empty files and directories
find . -empty
search for the host "slc02oxm.us.oracle.com" in all the xml files in the current folder and display the files which has the matched content
find -name “*.xml” -exec grep -l “slc02oxm.us.oracle.com” {} \;
Find files in /var/tmp/stuff and below that have not been modified in over 90 days
find /var/tmp/stuff -mtime +90 -print
find the oldest normal file in the current directory
find . -type f -print0 | xargs -0 ls -ltr | head -n 1
Exclude directory from find . command
find . -type d -name proc -prune -o -name '*.js'
set alisa "py" for command "$EDITOR"
alias -s py=$EDITOR
Find all orm* files/directories under current directory
find . -name 'orm*'
Add execute permission to all files ending in ".sh"
chmod +x *.sh
Perform white space safe deletion of files named core under /tmp
find /tmp -name core -type f -print0 | xargs -0 /bin/rm -f
Find all regular files under ${S} directory
find "${S}" -type f
Search for 'ireg' in all PHP files under 'project' directory tree and show only the files that match
find project -name '*.php' -type f -print0 | xargs -0 grep -l ireg
Print numbers from 1 to 10 with 2 values per line
seq 10 | paste -sd" \n" -
Lists enabled repositories along with debugging information.
yum -v repolist enabled
display all the files on the current folder excluding those that are present in the folder "./src/emacs"
find . -path ./src/emacs -prune -o -print
Recursively change the owner of all files in "/home/test" to "test"
sudo chown -R test /home/test
Finds every folder with file 'header.php' within, and copies file 'topscripts.php' to every one of them.
find -type f -name 'header.php' | xargs -n 1 dirname | xargs -n 1 cp -f topscripts.php
find all files in the current folder which have only the write permission for the others
find . -perm -0002 -print
Rename "new" to "old" and backup to "old.old" if "old" exists
mv new old -b -S .old
Find all files under current directory
find . -type f -print
Set 644 permission to all regular files under current directory
find . -type f -exec chmod 644 {} \;
find all the files in the file system that belong to the user www
find / -user www -print
Print file type of the executable file of command "file"
file `which file`
search for the word "search-pattern" in all the regular/normal files in the current folder and display the matched file name
find . -type f | xargs grep -l "search-pattern"
Write a random list of numbers to /tmp/lst and stdout.
seq 1 10 | sort -R | tee /tmp/lst |cat <(cat /tmp/lst) <(echo '-------') **...**
Show all lines as they are executed and stop at the first command returning nonzero
set -ex
Find all *.txt files/directories under current directory
find -name '*.txt'
Create a tar file containing all the files in ~/Library folder that contain spaces in their names
find ~/Library -name '* *' -print0 | xargs -0 tar rf blah.tar
change group of the file myfile to group friends
chown :friends myfile
Find all *.so files/directories under current directory and run myCommand with the file/directory paths as its argument then search for ExpectedResult in the output of myCommand
find . -name *.so -print0 | xargs -0 -I % sh -c 'echo % ; myCommand "%" | grep ExpectedResult'
Executes 'echo "$ret"' in a subshell that is opened by command 'true'.
true | echo "$ret"
Append "deb blah ... blah" to "/etc/apt/sources.list" as root
echo 'deb blah ... blah' | sudo tee --append /etc/apt/sources.list > /dev/null
display all the files in the current directory excluding the paths "targert", "tools", "git"
find . \( ! -path "*target*" -a ! -path "*tools*" -a ! -path "*.git*" -print \)
Compress the base64 encoded first 200 characters of "/dev/urandom" as input to uuencode
uuencode <
Remove all .mpg files in the /home/luser directory tree
find /home/luser -type f -name '*.mpg' -print0 | xargs -0 rm -f
Moves window from 4 place to 3.
tmux movew -s 4 -t 3
Send SIGKILL signal to all processes using TCP port 8080, terminating them instantly.
kill -9 $
List files in the current directory tree using echo
find . -exec echo {} ;
Find all the SGID bit files whose permissions set to 644 in the file system
find / -perm 2644
Lists content of compressed text file.
zless MyFile