nl
stringlengths
13
387
bash
stringlengths
1
532
Remove all regular files from the current directory tree whose names do not end with "ignore1" or "ignore2"
find . -type f -not -name '*ignore1' -o -not -name '*ignore2' | xargs rm
Remove all regular files from the current directory tree whose names do not end with "txt"
find . -type f -not -name '*txt' -print0 | xargs -0 rm --
Remove all regular files in the current directory
find ./ -type f -exec rm -rf {} \;
Remove all regular files named "Waldo" in the ~/Books directory tree
find ~/Books -type f -name Waldo -exec rm {} \;
Remove all regular files under $DIR directory tree that were accessed more than 5 days ago
find "$DIR" -type f -atime +5 -exec rm {} \;
Remove all regular files under '/var/log/remote' directory tree that have not been modified in the last 14 days where day count starts from today
find /var/log/remote/ -daystart -mtime +14 -type f -exec rm {} \;
Remove all regular files under and below directory "$DIR" that were last accessed more than 5 days ago
find "$DIR" -type f -atime +5 -exec rm {} \;
Remove all regular files with extensions php, css, ini, txt from directory tree /old/WordPress/
find /old/WordPress/ -type f -regex ".*\.\(php\|css\|ini\|txt\)" -exec rm {} \;
Remove all regular non-hidden files modified more than 7 days ago and residing in the /tmp directory tree
find /tmp -type f -name '*' -mtime +7 -print0 | xargs -0 rm -f
Remove all spaces from standard input
tr -d ' '
Remove all subdirectories of the current directory, except for "bar", "foo", "a", and "b"
find . -maxdepth 1 -type d \( ! -name "bar" -a ! -name "foo" -a ! -name "a" -a ! -name "b" \) -delete
remove all text files from the current folder
find -name "*.txt" | xargs rm
remove all text files from the current folder. Print0 is used to handle files whose names have only spaces or those files which have newlines in their names
find -name "*.txt" -print0 | xargs -0 rm
Remove all text files in the home directory with confirmation
find $HOME/. -name *.txt -ok rm {} \;
Remove all tmp/*.mp3 files
find tmp -maxdepth 1 -name '*.mp3' -maxdepth 1 | xargs -n1 rm
Remove all tmp/*.mp3 files
find tmp -maxdepth 1 -name '*.mp3' -maxdepth 1 | xargs rm
Remove all tmp/*.mp3 files
find tmp -maxdepth 1 -name *.mp3 -print0 | xargs -0 rm
Removes all top-level *.pdf files in a current folder.
rm -f *.pdf
Removes all top-level empty folders within the current folder.
ls | xargs rmdir
Remove all vmware-*.log files under current directory
find . -name "vmware-*.log" -exec rm '{}' \;
Remove all vmware-*.log files under current directory
find . -name vmware-*.log -delete
Remove all vmware-*.log files under current directory
find . -name vmware-*.log | xargs rm
Remove all white space from "infile.txt" and wrap each line to 80 characters
cat infile.txt | tr -d "[:space:]" | fold -80
Remove containing directories and suffix ".wiki" from specified path, output the result.
basename /home/jsmith/base.wiki .wiki
Remove directories in /media/1Tb/videos modified more than 7 days ago
find /media/1Tb/videos -maxdepth 1 -type d -mtime +7 -exec rm -rf {} \;
Remove duplicate phrases and keep the original order of lines in "$infile"
nl -w 8 "$infile" | sort -k2 -u | sort -n | cut -f2
Remove each unique item listed on standard input and do nothing if empty
sort | uniq -u | xargs -r rm
Remove empty directories
find -type d -exec rmdir --ignore-fail-on-non-empty {} + ;
Remove empty directories from the current directory tree
find . -depth -empty -type d -delete
Remove empty directories from directory tree /srv/${x}
find /srv/${x} -type d -empty -exec rmdir {} \;
Removes empty folder 'edi' and 'edw'.
rmdir edi edw
Removes empty folder, and hides error message if one is not empty.
rmdir --ignore-fail-on-non-empty $newBaseDir/Data/NewDataCopy
Remove empty folder, and skip error message if one is not empty.
rmdir --ignore-fail-on-non-empty newBaseDir/Data/NewDataCopy
Remove ESC key bind
bind -r '\e'
Removes everything from current folder but '*ddl*' and '*docs*' files.
ls -1|grep -v -e ddl -e docs| xargs rm -rf
Remove everything in a current folder prompting user on each action.
rm -ri *
Remove everything in a current folder without prompting.
find -mindepth 1 -maxdepth 1 -print0 | xargs -0 rm -rf
Remove everything in a current folder without prompting.
rm -rf *
Removes files 'junk1', 'junk2', 'junk3'.
rm junk1 junk2 junk3
Remove files cart4, cart5, cart6 in directory ~/junk
find ~/junk -name 'cart[4-6]' -exec rm {} \;
Remove files erroneously named `-F'
find . -name "-F" -exec rm {} \;
Remove files from the file system that are owned by nobody
find / -nouser -exec rm {} +
Remove files from the file system that are owned by nobody
find / -nouser -exec rm {} \;
Remove files from the file system that are owned by nobody, asking the user before each removal
find / -nouser -ok rm {} \;
Remove files from the home directory tree that were last accessed more than 100 days ago
find ~ -atime +100 -delete
Remove the files from the home directory tree that were last accessed more than 100 days ago, with confirmation
find ~/ -atime +100 -exec rm -i {} ;
Remove files in the current directory tree modified more than 31 days ago recursively
find . -type f -mtime +31 -print0 | xargs -0 -r rm -f
Remove files in the current directory tree whose names match pattern "file?"
find . -name "file?" -exec rm -vf {} \;
Remove files matching pattern '*-*x*.*' from the current directory tree
find -name '*-*x*.*' | xargs rm -f
Remove files named "core" from the /work directory tree and write their names to /dev/stderr (the standard error
find /work \( -fprint /dev/stderr \) , \( -name 'core' -exec rm {} \; \)
Remove the files or directories 'bin/node', 'bin/node-waf', 'include/node', 'lib/node', 'lib/pkgconfig/nodejs.pc' and 'share/man/man1/node' with superuser privilege
sudo rm -rf bin/node bin/node-waf include/node lib/node lib/pkgconfig/nodejs.pc share/man/man1/node
Remove the files or directories 'bin/node', 'bin/node-waf', 'include/node', 'lib/node', 'lib/pkgconfig/nodejs.pc' and 'share/man/man1/node.1'
rm -r bin/node bin/node-waf include/node lib/node lib/pkgconfig/nodejs.pc share/man/man1/node.1
Remove files that are less than 1MB in size under current directory
find . -size -1M -exec rm {} \;
Remove files that are less than 1MB in size under current directory
find . -type f -size -1M -exec rm {} +
Remove files under /mnt/zip matching "*prets copy" with confirmation
find /mnt/zip -name "*prefs copy" -print0 | xargs -0 -p /bin/rm
Remove files under current directory that contains white space in their name
find . -name "* *" -exec rm -f {} \;
Remove files under current directory with inode number $inum
find . -inum $inum -exec rm {} \;
Remove files whose names match regular expression '^.*/[A-Za-z]+-[0-9]+x[0-9]+\.[A-Za-z]+$' from the current directory tree
find -regex '^.*/[A-Za-z]+-[0-9]+x[0-9]+\.[A-Za-z]+$' | xargs echo rm -f
Remove files whose names start with `Foo'
find . -type f -name "Foo*" -exec rm {} \;
Remove file with inode number 31246
find . -inum 31246 -exec rm [] ';'
Remove the file with inode number 752010
find -inum 752010 -exec rm {} \;
Removes first and last parts of path $path and saves the result in 'finalName' variable.
finalName=$(basename -- "$(dirname -- "$path")")
Removes first and last parts of path $path and saves the result in 'finalName' variable.
finalName=$(dirname ${path#*/})
Removes first and last parts of path 'test/90_2a5/Windows' and prints the result.
echo 'test/90_2a5/Windows' | xargs dirname | xargs basename
Remove from the current directory tree all the regular files which have a dot in their names and contain string "<img-name>-<width:integer>x<height:integer>.<file-ext> syntax"
find . -name "*.*" -type f -exec grep -l '<img-name>-<width:integer>x<height:integer>.<file-ext> syntax' {} \; | xargs rm -f
Remove gitlab.site.org from root's known hosts file.
ssh-keygen -f "/root/.ssh/known_hosts" -R gitlab.site.org
Remove junk files modified more than 31 days ago recursively
find /path/to/junk/files -type f -mtime +31 -exec rm -f {} \;
Remove junk files modified more than 31 days ago recursively
find /path/to/junk/files -type f -mtime +31 -print0 | xargs -0 -r rm -f
Remove the last two components (directories) of $path
echo $path | rev | cut -d'/' -f4- | rev
Removes the last 2 lines from a file
head -n -2 myfile.txt
Remove the last 2 tab-separated fields of each line in file pointed to by filename
cat $filename | rev | cut -c 3- | rev
Remove last two underscore-delimited fields and following characters in "t1_t2_t3_tn1_tn2.sh" keeping only "t1_t2_t3"
echo t1_t2_t3_tn1_tn2.sh | rev | cut -d_ -f3- | rev
removes last N lines from file.txt
head --lines=-N file.txt
Remove lines matching "kpt#" from "data.txt" and add left-justified line numbers
grep -v 'kpt#' data.txt | nl -nln
Remove Mac OS X Desktop Services Store files
find . -name ".DS_Store" -exec rm {} \;
Remove newline characters from "file.txt"
paste -sd "" file.txt
Remove the path $1 from the PATH environment variable
PATH=$(echo $PATH | tr ":" "\n" | grep -v $1 | tr "\n" ":")
Removes resursively all files and folders named ".DS_Store".
find . -name ".DS_Store" -print0 | xargs -0 rm -rf
Removes resursively all files and folders named "Thumbs.db", ignoring case distincts.
find . -iname "Thumbs.db" -print0 | xargs -0 rm -rf
Remove recursively Emacs backup files in the current directory
find . -name '*~' -print0 | xargs -0 rm
Remove regular files changed more than 15 days ago from the /tmp directory tree
find /tmp/ -ctime +15 -type f -exec rm {} \;
Remove the regular files from the current directory that were last modified on November, 22
find -maxdepth 1 -type f -newermt "Nov 22" \! -newermt "Nov 23" -delete
Remove the regular files from the current directory tree that were last modified on November, 21
find -type f -newermt "Nov 21" ! -newermt "Nov 22" -delete
Remove regular files whose names match Perl regular expression '\w+-\d+x\d+\.\w+$' from the current directory tree
find -type f | grep -P '\w+-\d+x\d+\.\w+$' | xargs rm
Remove sess_* files that were modified more than 2 days ago
find sess_* -mtime +2 -exec rm {} \;
Remove spaces from output of "echo aa | wc -l"
echo aa | wc -l | tr -d ' '
Remove symbolic links and get absolute path of "${the_stuff_you_test}" and save to variable "DIR_PATH"
DIR_PATH=`readlink -f "${the_stuff_you_test}"`
remove top-level domain (.com, .org) from URL's in urllist.txt
rev urllist.txt | cut -d. -f 2- | rev
Remove with prompting all files starting in /mydir that have not been accessed in over 100 days
find /mydir -atime +100 -ok rm {} \;
Rename "/usr/bin/php" to "/usr/bin/~php"
sudo mv /usr/bin/php /usr/bin/~php
Rename "Tux.png" to ".Tux.png"
mv Tux.png .Tux.png
Rename "blah1" to "blah1-new"
mv blah1 blah1-new
Rename "blah2" to "blah2-new"
mv blah2 blah2-new
Rename "fghfilea" to "jklfilea"
mv fghfilea jklfilea
Rename "file0001.txt" to "1.txt"
mv file0001.txt 1.txt
Rename "new" to "old" and backup to "old.old" if "old" exists
mv new old -b -S .old
Rename "new" to "old" and make a backup if "old" exists
mv new old -b
Rename "original.filename" to "new.original.filename"
mv original.filename new.original.filename
Rename "original.filename" to "new.original.filename"
mv {,new.}original.filename
Rename "svnlog.py" to "svnlog"
mv svnlog.py svnlog