nl
stringlengths
13
387
bash
stringlengths
1
532
display files ending with ".ext" in current folder which are present in the file "foo"
find . -type f -name \*.ext | xargs grep foo
display files in current folder ending with "pdf" or "PDF"
find . -name '*.pdf' -or -name '*.PDF'
display the file name and creation month of top 11 files in the entire file system
find / -type f -printf "\n%Ab %p" | head -n 11
display the file name and the file type of all the files in the current directory
find . -printf "%y %p\n"
Display the file size of file '/data/sflow_log' in bytes
du -sb /data/sflow_log | cut -f1
Display file type description of 'file-name' based on contents.
file file-name
Display the file type description of /bin/bash, ie. symbolic link, ELF executable, etc.
$ file /bin/bash
Display file type information for all instances of "file" in the current PATH.
which file | xargs file
display the filenames which do not have begin with dot (.)
find . -maxdepth 1 -name '[!.]*' -printf 'Name: %16f Size: %6s\n'
Display the first 10 lines of the byte hex dump with no file offset data for "/bin/ls"
od -t x1 -An /bin/ls | head
Display the first 32 bytes in "foo" as printable characters with 16 characters per line
od -c foo |head -2
Display hardware platform, ie. x86_64 even if current kernel uses 32-bit addressing.
uname -i
display the help of find command
find --help
Display the host's ECDSA fingerprint using the sha256 hasing algorithm.
ssh-keygen -l -f /etc/ssh/ssh_host_ecdsa_key.pub
Display hostname.
uname -n
display the html, javascript and text files in the current folder (print0 is used to preserve the filenames of all the files which have newlines in their names)
find . -type f \( -name "*.htm*" -o -name "*.js*" -o -name "*.txt" \) -print0 | xargs -0 -n1 echo
Display human-readable file type description of ascii.txt
file ascii.txt
display in a list of all the files that are bigger than 10KB in current folder
find . -size +10k -ls
Display infinite scroll of random ASCII art
yes 'c=(╱ ╲);printf ${c[RANDOM%2]}'|bash
Display infinite scroll of random ASCII art
yes 'printf \\u$[2571+RANDOM%2]'|bash
(GNU specific) Display info on most CPU-intensive processes once and exit.
top -n 1
Display kernel release name.
uname -r
Display the last 3 characters of variable foo.
echo $foo | rev | cut -c1-3 | rev
Display the last colon-separated field of variable 'var'
echo "$var" | rev | cut -d: -f1 | rev
Display the last dot-separated field, in this case "com".
echo 'maps.google.com' | rev | cut -d'.' -f 1 | rev
Display the last slash-separated part of each filename path in file.txt
rev file.txt | cut -d/ -f1 | rev
Display the last slash-separated part of path, in this case "example".
basename /usr/local/svn/repos/example
Display the last space-separated field of each line in file.txt
rev file.txt | cut -d ' ' -f1 | rev
display list of all the C files ( fuiles with ".c" extension ) in current folder
find . -name '*.c' -ls
display list of all the files in the /tmp folder
find /tmp/ -exec ls "{}" +
display list of all the files in the current directory
find | xargs ls
display list of all the files in the current directory (print0 handles file names with newlines or spaces)
find -print0 | xargs -0 ls
display the list of all the files in the current directory which have been accssed in the last 500 days exluding hidden files
find . -type f \( ! -iname ".*" \) -mtime +500 -exec ls {} \;
display list of all the files in the current folder which are empty.
find . -size 0 -ls
display list of all the hidden directories in the directory "/dir/to/search/"
find /dir/to/search -path '*/.*' -ls
display list of all the hidden directories in the directory "/dir/to/search/"
find /dir/to/search/ -type d -iname ".*" -ls
display list of all the hidden files in the directory "/dir/to/search/"
find /dir/to/search/ -name ".*" -ls
display list of all the hidden files in the home folder
find $HOME -name ".*" -ls
display list of all the hidden regular/normal files in the directory "/dir/to/search/"
find /dir/to/search/ -type f -iname ".*" -ls
display the list of all the normal files excluding hidden files which have been accessed in the last 500 days
find . -type f -not -name ‘.*’ -mtime +500 -exec ls {} \;
display list of all the regular/normal files in the current folder which start with "my"
find . -name 'my*' -type f -ls
display list of all the regular/normal files in the home folder which are bigger than 512 kb
find /home/ -type f -size +512k -exec ls -lh {} \;
display list of all the regular/normal files in the home folder which are exactly 6579 bytes
find /home/ -type f -size 6579c -exec ls {} \;
Display list of files ending with '.txt' in the current folder to the terminal twice and output it to the text file "txtlist.txt"
ls *.txt | tee /dev/tty txtlist.txt
display the long listing detials of all the files in the folder junk which is in home folder.
find ~/junk -name "*" -exec ls -l {} \;
Display long listing of all the files/directories owned by the user 'me' under '/tmp' directory tree
find /tmp -user me -ls
display long listing of all the files in the folder "/myfiles"
find /myfiles -exec ls -l {} ;
display long list of all the files in the folder /home/peter which belong to no user and change the owner,group of all these files (after user confirmation) to "peter","peter"
find /home/peter -nouser -exec ls -l {} \; -ok chown peter.peter {} \;
display long listing of all the files in the root folder which are bigger than 3KB
find / -dev -size +3000 -exec ls -l {} ;
display long listing of all the files that have been changed in the last 4 days, daystart is used to compare from the starting of day i.e, at 00:00
find . -daystart -ctime 4 -ls -type f
display long list of all the perl files in the current folder
find . -name "*.pl" -ls
display long listing of all normal/regular files in the current directory which have been modified in the last 2 days.
find . -mtime -2 -type f -name "t*" -exec ls -l '{}' \;
display long listing of all regular/normal files whose size is less than 50 bytes.
find /usr/bin -type f -size -50c -exec ls -l '{}' ';'
display long listing of all the regular hidden files in the folder Musica
find Música/* -type f -name ".*" -exec ls -l {} \;
display long listing of all the symbolic links in the current folder
find . -type l -exec ls -l {} \;
display long listing of all the text files in the current folder
find . -name "*.txt" -exec ls -la {} \;
display long listing of all the text files in the current folder (plus at the end executes quickly by sending bulk data as input to the command in exec)
find . -name "*.txt" -exec ls -la {} +
display long listing of first 10 directories in the current folder
find . -type d -ls | head
display the manual page of find
man find
Display mime type of file specified by variable "file"
file -ib "$file"
Display name and value of 'variable' if it exists.
env | grep '^variable='
Display the named characters in "line1\r\nline2"
echo -e "line1\r\nline2" | od -a
display the name of all directories in the current folder and do not search in sub directories
find . -type d -maxdepth 1 -exec basename {} \;
display the name of all directories in the current folder and do not search in sub directories ( mindepth ensures that the current folder name is removed from the output)
find . -type d -maxdepth 1 -mindepth 1 -exec basename {} \;
display the names without extensions of all the data files in current folder which have not been changed in the last 60 mins
find . -prune -name "*.dat" -type f -cmin +60 |xargs -i basename {} \;
display the names without extensions of all the data files in current folder which have not been changed in the last 60 mins
find ./ -name "*.dat" -type f -cmin +60 -exec basename {} \;
Display non-hidden files in the current directory with the given output format
find . -maxdepth 1 -name '[!.]*' -printf 'Name: %16f Size: %6s\n'
display the number of lines in all the ".c" files in the current folder
find . -name "*.c" -exec wc -l {} \;
display the number of lines in all the ".c" files in the current folder
find . -name "*.c" -print | xargs wc -l
display the number of lines in all the ".c" files in the current folder
find . -name "*.c" -print0 | xargs -0 wc -l
display the number of lines in all the files in the current folder
find . -exec wc -l {} \;
display the number of lines in all the files in the current folder
find . -name '*' | xargs wc -l
display the number of lines in all the header files in the current folder
find . -name "*.h" -print | xargs wc -l
display the number of lines in all the php files in the current folder
find -name '*php' | xargs cat | wc -l
Display the number of lines in all regular files under current directory tree and also show the total count
find . -type f -exec wc -l {} +
Display the number of regular files under current directory tree
find . -type f -exec echo {} \; | wc -l
Display the number of regular files under current directory tree
find . -type f -print0 | tr -dc '\0' | wc -c
display only the file names of all the files which end with ".deb"
find . -name '*.deb' -printf "%f\n"
Display only first and second dot-separated numbers of kernel version, ie. 4.4
uname -r | cut -d. -f1-2
Display permissions, user, group, and full path for each file in the current directory tree as a list
tree -p -u -g -f -i
(GNU specific) Display process information for all processes whose command line contains "processname".
top -b -n1 | grep processname
(GNU specific) Display process information (batch mode, display once) with full command lines.
top -b -n1 -c
Displays process tree of a process with id 'PID', showing parent process and processes id.
pstree -p -s PID
Display the sizes and filepaths of all files/directories sorted in ascending order of size
du -a --max-depth=1 | sort -n
Display the sizes and filepaths of all files/directories sorted in descending order of size
du -a -h --max-depth=1 | sort -hr
Display the sizes and filepaths of all files/directories with '.undo' extension under current directory tree
find -name *.undo -print0 | du -hc --files0-from=-
Display standard input as octal bytes
cat | od -b
Display standard input as printable characters or backslash escapes with no addressing radix
od -cAn;
Displays status of currently active network interfaces.
ifconfig
Display summary of each specified file in human readable form
du -sh *
display table of files with their name, owner, and size in bytes.
find . -printf 'Name: %f Owner: %u %s bytes\n'
display top 11 files along with the last access date for all the files in the file system
find / -type f -printf "\n%AD %AT %p" | head -n 11
display the top 20 biggest files in the current folder which are present in the same partition as that of the current folder
find . -xdev -printf ‘%s %p\n’ |sort -nr|head -20
Display top 500 mp4 and flv files under current directory along with their timestamps in the sorted order of time
find . -regex ".*\.\(flv\|mp4\)" -type f -printf '%T+ %p\n' | sort | head -n 500
Display the total count of all the files/directories with '.old' extension under current directory tree
find . -name “*.old” -print | wc -l
display the type of all the regular/normal files in the entire file system
find / -type f -print | xargs file
display the version of find command
find --version
display the version of find command
find -version
Display who is logged on and what they are doing
w
Download "Louis Theroux's LA Stories" using rsync over ssh
rsync -ave ssh '"Louis Theroux"''"'"'"'"''"s LA Stories"'