nl
stringlengths
13
387
bash
stringlengths
1
532
Find smallest file in the current directory with find commad
find . -type f -printf "%s\t%p\n" | sort -n |head -1
Find SQL files with text `expression'
find . -name "*.sql" -print0 -type f | xargs -0 grep "expression"
Find string "STRING" in files residing in the current directory tree, case insensitive
find . -type f -print | xargs grep -ni "STRING"
Find the string 'joomla' case insensitively in all the php and html files under current directory tree and display the matched lines along with the file names and line numbers
find . \( -name "*.php" -o -name "*.html" \) -print0 | xargs -0 grep -Hin "joomla"
Finds strings having text "searched-string" in all files recursively in a current folder.
find . | xargs grep "searched-string"
Find strings with 'Features' in /var/run/dmesg.boot' file
cat /var/run/dmesg.boot | grep Features
Finds strings with 'TEXT' from *.log files and prints all but first field from any space-delimited string.
grep -e TEXT *.log | cut -d' ' --complement -s -f1
Finds strings with text "searched-string" recursively in all files of current folder and prints names of files with matched strings.
grep -r -l "foo" .
Finds string with text "string to be searched" in any cased files like "*.cs" recursively in a current folder.
find ./ -type f -iname "*.cs" -print0 | xargs -0 grep "content pattern"
Finds strings with text "text" in all files named "string to be searched" recursively in a current folder.
find . -name "string to be searched" -exec grep "text" "{}" \;
Find StringBuffer in all *.java files
find . -type f -name "*.java" -exec grep -l StringBuffer {} \;
find StringBuffer in all *.java files
find . -type f -name "*.java" -exec grep -l StringBuffer {} \;
find StringBuffer in all *.java files, ignoring case
find . -type f -name "*.java" -exec grep -il string {} \;
find suffix tcl files under all directories started with 'n'
find ./n* -name "*.tcl"
Find SUID files
find / -perm +4000
Find SUID files
find / -perm +u=s
Find suspicious PHP files
find . -type f -name "*.php" -exec grep --with-filename "eval(\|exec(\|base64_decode(" {} \;
find symbolic link file that name match '*sysdep.c'
find . -lname '*sysdep.c'
Find symbolic links in /usr/lib and /usr/lib64 to files whose pathnames contain "libstdc++"
find /usr/lib/ /usr/lib64/ -lname "*libstdc++*"
Find symbolic links in /usr/sbin and /usr/bin to files whose pathnames end in "*/systemctl"
find /usr/sbin /usr/bin -lname "*/systemctl"
Find symbolic links in directory /etc and below
find /etc -type l
Find symbolic links in lpi104-6 and research/lpi104-6 to files whose pathnames end in "file1"
find lpi104-6 research/lpi104-6 -lname "*file1"
Find symbolic links under /etc/
find /etc -type l
find symbolic links with pattern` '*sysdep.c'
find . -lname '*sysdep.c'
Find symlinks under and below the "test" directory and replace them with the content of the linked files
find test -type l -exec cp {} {}.tmp$$ \; -exec mv {}.tmp$$ {} \;
Find text in whole directory tree
find . -type f | xargs grep "text"
Find things changed today
find /path/to/search -daystart -ctime -1
Find the top 25 files according to their size in the current directory and its subdirectories
find . -type f -exec ls -al {} \; | sort -nr -k5 | head -n 25
find the top 25 files in the current directory and its subdirectories
find . -type f -exec ls -al {} \; | sort -nr -k5 | head -n 25
Find the top 5 big files
find . -type f -exec ls -s {} \; | sort -n -r | head -5
Find the top 5 biggest files
find . -type f -exec ls -s {} \; | sort -n -r | head -5
Find the top 5 small files
find . -type f -exec ls -s {} \; | sort -n | head -5
Find the total size of *.jpg files within the current directory tree
find . -type f -iname '*.jpg' -print0 | du -c --files0-from=-
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$
find the type & description of all the regular/normal files in the home folder
find /home -type f -print0 | xargs -0 file
find the type of all the regular/normal files in the current folder
find . -type f -exec file {} \;
find the type of all the regular/normal files in the current folder
find . -type f | xargs file
find the type of all the regular/normal files in the current folder (plus takes bulk of files as input to the file command)
find . -type f -exec file {} \+;
Find user daniel's files of type jpeg
find . -user daniel -type f -name *.jpg
Find user daniel's files of type jpeg without `autumn' in the name
find . -user daniel -type f -name *.jpg ! -name autumn*
Find users whose names begin with "ab" and ends with "1"
who | cut -d ' ' -f 1 | grep -e '^ab' -e '1$'
Find users whose names begin with "ab" or whose terminal from which they are logged in ends with "1"
who | grep -e '^ab' -e '1$'
Find which ruby files under current directory contain the string 'jump'
find . -name '*.rb' -exec grep -H jump {} \;
Find with combine multiple search criterias , in this command serach files that begin with abc in there name and dont have .py extension .
find . -type f -name 'abc*' ! -name '*.py'
Find writable regular files in the current directory
find -type f -maxdepth 1 -writable
Find writable regular files in the current directory
find . -maxdepth 1 -type f -writable
Find writable regular files omitting those that contain sites/default/files in their names
find . -type f -writable | grep -v sites/default/files
Find x* files/directories under /tmp directory whose status was changed less than 1 day ago
find /tmp/ -ctime -1 -name x*
Find x* files/directories under /tmp directory whose status was changed less than 1 day ago and move them to ~/play
find /tmp/ -ctime -1 -name "x*" -exec mv '{}' ~/play/
Find x* files/directories under /tmp directory whose status was changed less than 1 day ago and move them to ~/play
find /tmp/ -ctime -1 -name "x*" | xargs -I '{}' mv '{}' ~/play/
Find x* files/directories under /tmp directory whose status was changed less than 1 day ago and move them to ~/play
find /tmp/ -ctime -1 -name 'x*' -print0 | xargs -r0 mv -t ~/play/
Fix files to default permissions 644
find . -type f -exec chmod 644 {} \;
Fix permissions for a group of files with given extension
find /usr/local -name "*.html" -type f -exec chmod 644 {} \;
Follows symbolic link $BASH_SOURCE, and prints path to its target.
$(dirname $(readlink -f $BASH_SOURCE))
Follow symbolic links for the full path of "lshw"
readlink -f $(which lshw)
For each item in array "alpha", display the basename, that is the part following the last slash, or the whole item if no slash is present.
basename -a "${alpha[@]}"
For each line in file2 whose first field appears as a first field in file1, print an output line constructed following the specified -o format.
join -11 -21 -o1.1,1.2,1.3,2.3 file1 file2
For each line of colon-separated information in files 'empsal' and 'empname' whose first field matches in both files, output: first field of empname, second field of empname, fourth field of empname, and third field of empsal.
join -j 1 -t : -o 2.1,2.2,2.4,1.3 <(sort empsal) <(sort empname)
For each line of the sorted output of both file1 and file2, print lines whose first field of file2 does not appear as first field of file1.
join -v1 <(sort file1) <(sort file2)
For each line which has a common first field in file1.csv and file2.txt, output the first 4 fields of file1.csv
join -o 1.1,1.2,1.3,1.4 -t, <(sort file1.csv) <(sort file2.txt)
For each line which has a common first field in file1.csv and file2.txt, output the first 4 fields of file1.csv - both files must be sorted first.
join -o 1.1,1.2,1.3,1.4 -t, file1.csv file2.txt
For each line which has a common first field in test.1 and test.2, output the first 2 fields of test.2 and the field 2 and 3 of test.1
join -j1 -o 2.1,2.2,1.2,1.3 <(sort test.1) <(sort test.2)
For each line whose first field is the same in file1 and file2, output the common first field followed by all other fields in file1 and file2.
join -j1 file2 file1
Force create a hard link in "/usr/local/bin" to "findpdftext"
sudo ln -f "findpdftext" /usr/local/bin
Force create a hard link named "non_secret_file.txt" to "secret_file.txt"
ln -f secret_file.txt non_secret_file.txt
Force create a hard link named '/home/user/Musik/youtube converted/aesthesys~ I Am Free, That Is Why I'"'"'m Lost..mp3' with target '/home/user/Musik/mix-2012-13/aesthesys~ I Am Free, That Is Why I'"'"'m Lost..mp3'
ln -f '/home/user/Musik/mix-2012-13/aesthesys~ I Am Free, That Is Why I'"'"'m Lost..mp3' '/home/user/Musik/youtube converted/aesthesys~ I Am Free, That Is Why I'"'"'m Lost..mp3'
Force create a symbolic link as a file named "/usr/lib/jvm/default-java" to "$default_java_dir" with verbose output
sudo ln -sTfv "$default_java_dir" "/usr/lib/jvm/default-java"
Force create a symbolic link named "$*" to the canonical absolute path of "$1"
ln -sf "$(readlink -f "$1")" "$*"
Force create a symbolic link named "$lines" to "$c" without dereferencing "$lines"
ln -sfn "$c" "$lines"
Force create a symbolic link named "$pdir" to "$pluginpath" with verbose output
sudo ln --symbolic --verbose --force "$pluginpath" "$pdir"
Force create a symbolc link named "/usr/local/bin/fpt" to "/usr/local/bin/findpdftext"
sudo ln -s -f "/usr/local/bin/findpdftext" "/usr/local/bin/fpt"
Force create a symbolic link named "currentDir" to "newDir" without dereferencing "currentDir"
ln -sfn newDir currentDir
Force create a symbolic link named "id_rsa" to "$keyname"
ln -sf $keyname id_rsa
Force create a symbolic link named "mylink" with target "/apps/myapps/new/link/target"
ln -f -s /apps/myapps/new/link/target mylink
Force create a symbolic link to "$f" in "~/my-existing-links/" with name the basename of "$f"
ln -sf "$f" "~/my-existing-links/$(basename $f)"
Force create a symbolic link without dereferencing named "$SYMLINK_PATH" to "$lastModified"
ln -nsf $lastModified $SYMLINK_PATH
Force create a symbolic link without dereferencing named "alpha" to "alpha_2"
ln -nsf alpha_2 alpha
Force create a symbolic link without dereferencing named "mylink" to "dir2"
ln -nsf dir2 mylink
force create hard link between $GIT_DIR/../apresentacao/apresentacao.pdf and $GIT_DIR/../capa/apresentacao.pdf
ln -f $GIT_DIR/../apresentacao/apresentacao.pdf $GIT_DIR/../capa/apresentacao.pdf
Force decompress all files into '/etc'
gzip -d --force * /etc
force delete all the core files in the home folder
find $HOME -name core -exec rm -f {} \;
force delete all the directories the folder "test folder"
find 'Test Folder' -type d -print0 | xargs -0 rm -rf
Forcefully delete all files in the current directory that begin with spam-
find . -name 'spam-*' | xargs rm
Force delete all files in the current folder
find . | xargs -i rm -f "{}"
force delete all the files in the current folder expect xml files
find . | grep -v xml | xargs rm -rf {}
Force delete all files in the temp folder which have not been accesses in the last 240 hours
find /tmp/* -atime +10 -exec rm -f {} \;
Force delete all jpg files in current directory which are less than 50KB and do not search in the sub directories
find . -maxdepth 1 -name "*.jpg" -size -50k -exec rm {} \;
Force delete all jpg files in current directory which are less than 50KB and do not search in the sub directories
find . -maxdepth 1 -name "*.jpg" -size -50k | xargs rm -f
force delete all the regular/normal files in the current folder
find . -type f -exec rm -fv {} \;
Force delete all the regular/normal files in the current folder and do not search in the sub folders
find . -maxdepth 1 -type f -exec rm -f {} \;
Force delete all the regular/normal files in the current folder and do not search in the sub folders (print0 is used to handle files which have newlines in their names or files with the name only as spaces )
find . -maxdepth 1 -type f -print0 | xargs rm -f
force delete all the regular files with the name "test.txt"
find /home -type f -name test.txt -exec rm -f {} \
force delete all the temp files which are of size 0 bytes and which have not been accessed in the last 10 days
find /tmp -size 0 -atime +10 -exec rm -f {} \;
Force the group stickiness for directories under /var/www
find /var/www -type d -print0 | xargs -0 chmod g+s
Force pseudo tty allocation on connection to "somehost" and execute "~/bashplay/f"
ssh -t somehost ~/bashplay/f
force remove all the c files in the current folder
find . -name "*.c" | xargs rm -rf
force remove all the c files in the current folder, print0 is used to handle all files with new lines in their names or files with only spaces in their name
find . -name "*.c" -print0 | xargs -0 rm -rf
force remove all the directories with the name logs in the folder /var/www
find /var/www -type d -mtime 0 -name logs -exec sudo rm -fr {} \;
Force remove all files and folders in the physical current working directory
rm -rf "$(pwd -P)"/*
force remove all the regular/normal files which begin with sess in the temp folder
find /tmp -type f -name sess* -exec rm -f {} \;