nl
stringlengths
13
387
bash
stringlengths
1
532
Prints line count of each file within current directory.
find . -type f -print0 | xargs -0L1 wc -l
Print lines in "file1" that exist in "file2"
join -t " " -j 1 <(sort file1) <(sort file2)
Print lines in "file1.txt" that do not exist in "file2.txt"
sort <(sort -u file1.txt) file2.txt file2.txt | uniq -u
Print lines in "foo.txt" that are found only once
sort foo.txt | uniq
Print lines in file 'file' that do not match any word specified in file 'blacklist' (one word per line)
grep -w -v -f blacklist file
Print lines in file 'filename' that do not match the regex 'pattern'
grep -v 'pattern' filename
Print lines in the sorted contents of "a.txt" that are not in the sorted contents of "b.txt"
comm -23 <(sort a.txt) <(sort b.txt)
Print lines in the sorted contents of "file1" that are not in the sorted contents of "file2"
comm -23 <(sort file1) <(sort file2)
Print lines in the sorted contents of "file2" that are not in the sorted contents of "file1"
comm -13 <(sort file1) <(sort file2)
Print lines in the sorted contents of "second.txt" that are not in the sorted contents of "first.txt"
comm -13 <(sort first.txt) <(sort second.txt)
Print lines of 'file' reverted order, and reverted characterwise
tac file | rev
Print the lines of file "strings" not specified in file "index"
join -v 2 index <(nl strings)
Print the lines of file "strings" specified in file "index"
join <(sort index) <(nl strings | sort -b)
Print lines that only unique ones in 'set1' and 'set2' files
cat <(grep -vxF -f set1 set2) <(grep -vxF -f set2 set1)
Print lines unique and common to sorted files "file1" and "file2"
comm file1 file2
Print the line with most consecutive repeats prefixed with its count from standard input
uniq -c | sort -n | tail -n1
Print line, word and byte counts for each .php files in current directory tree and also show the total counts
wc `find | grep .php$`
Print line, word and byte count for each file recursively and also show the total counts
wc `find`
Print linux group names on multiple lines instead of single line output
groups | tr \ \\n
Print the list of 1st level subdirectories in /fss/fin
find /fss/fin -d 1 -type d -name "*" -print
Prints listing of a root folder including hidden files, and saves output to 'output.file'.
ls -a | tee output.file
Print the list of all directories in the /myfiles directory tree
find /myfiles -type d
Print the list of all directories under the current directory and below
find ./ -type d -print
Print the list of all files except files named BBB
find . \! -name BBB -print
Print the list of all files in the current directory except for SVN, CVS, GIT, and binary files
find . -not \( -name .svn -prune -o -name .git -prune -o -name CVS -prune \) -type f -print0 | xargs -0 file -n | grep -v binary | cut -d ":" -f1
Print the list of all regular files from the current directory tree that contain "confirm", case insensitive
find . -type f -exec grep -il confirm {} \;
Print the list of all regular files on the system using "echo"
find / -type f -exec echo {} \;
Print the list of all regular files residing in the current directory and below
find ./ -type f -print
Print the list of all subdirectories of the current directory
find . -maxdepth 1 -mindepth 1 -type d
Print the list of the current directory's subdirectories
find -maxdepth 1 -type d
Print the list of the current directory's subdirectories
find . -maxdepth 1 -mindepth 1 -type d -printf '%f\n'
Print the list of the current directory's subdirectories
find . -type d -maxdepth 1
Print the list of directories residing in the current directory tree
find . -type d -exec ls -ld {} \;
Print the list of directories that are present in the /mnt/raid directory tree
find /mnt/raid -type d
Print the list of files and directories of the /etc directory
find /etc ! -name /etc
Print the list of files and directories of the /etc directory
find /etc/. ! -name . -prune
Print the list of files and directories of the /etc directory
find /etc/. ! -name /etc/.
Print the list of files and directories of the current directory
find . ! -name . -prune
Print the list of files and directories of the current directory including "."
find . \( -name . -o -prune \)
Print the list of files changed within the last minute
find / -newerct '1 minute ago' -print
Print the list of files from the "/zu/durchsuchender/Ordner" directory tree whose names begin with "beispieldatei" and which contain string "Beispielinhalt"
find "/zu/durchsuchender/Ordner" -name "beispieldatei*" -print0 | xargs -0 grep -l "Beispielinhalt"
Print the list of files in the current directory tree ignoring .svn, .git, and other hidden directories
find . -type f -not -path '*/\.*'
Print the list of files in the current directory tree skipping Git files
find . -path './.git' -prune -o -type f
Print the list of files in the current directory tree skipping SVN files
find . -name .svn -a -type d -prune -o -print
Print the list of files in the current directory tree skipping SVN files
find . -path '*/.svn*' -prune -o -print
Print the list of files in the current directory tree skipping SVN files
find . -type d -name .svn -prune -o -print
Print the list of files in the current directory tree with "xx" preceding and following each filename
find . -exec echo xx{}xx \;
Print the list of files in directory /tmp/a1 recursively
find /tmp/a1
Print the list of files in the home directory tree whose names begin with "Foto"
find ~ -name 'Foto*'
Prints list of folders containing '.git', searching recursively from a current folder.
find . -name '.git' | xargs -n 1 dirname
Print the list of non-hidden directories in the current directory
find -type d -maxdepth 1 ! -name ".*" -printf "%f\n"
Print the list of regular files from the current directory that were last modified on November, 22
find . -maxdepth 1 -type f -newermt "Nov 22" \! -newermt "Nov 23" -exec echo {} +
Print the list of regular files in the current directory and all subdirectories
find . -type f
Print the list of the subdirectories of /path/to/dir
find /path/to/dir/ -mindepth 1 -maxdepth 1 -type d
Print the list of the subdirectories of the current directory
find . -mindepth 1 -maxdepth 1 -type d -printf "%P\n"
Print local files without descending non-local directories
find . ! -local -prune -o -print
Print local SRV record of domain '_etcd-client._tcp.'
dig @"127.0.0.1" _etcd-client._tcp. SRV
Prints long listing of "$dir/$file" file.
ls -l -- "$dir/$file"
Prints long listing of ${0} file.
ls -l ${0}
Prints long listing of content in a root folder, including hidden files, with human-readable sizes, and stores output to '/root/test.out' file.
echo 'ls -hal /root/ > /root/test.out' | sudo bash
Prints long listing of content in a root folder, including hidden files, with human-readable sizes, and stores output to '/root/test.out' file.
ls -hal /root/ | sudo tee /root/test.out
Prints long listing of content in the current folder with C-style escapes for nongraphic characters
ls -lb
Prints long listing of directories "./my dir" and "./anotherdir" sorted from oldest to newest, with appended indicators.
$ ls -Fltr "./my dir" "./anotherdir"
Prints long listing of directory $var sorted from oldest to newest, with appended indicators.
$ ls -Fltr $var
Prints long listing of file 'file.ext'.
ls -al file.ext
Prints long recursive listing of all content of a current folder, saving output to 'output.file'.
ls |& tee files.txt
Prints long recursive listing of all content of a root folder, appending output to 'output.file'.
ls -lR / | tee -a output.file
Print ls output for all non-empty files under under current directory
find . -type f ! -size 0 -exec ls -l '{}' \;
Print how many files are inside each directory under the current one
find */ | cut -d/ -f1 | uniq -c
Print the MD5 message digest of "/path/to/destination/file"
md5sum /path/to/destination/file
Prints message info about filename and location of the current script
echo "The script you are running has basename `basename $0`, dirname `dirname $0`"
Print the most recently modified file
ls -1tr * | tail -1
Print multiline text "ONBOOT=\"YES\"\nIPADDR=10.42.84.168\nPREFIX=24" to the terminal, replacing '\n' with newline symbol, and append that text to file /etc/sysconfig/network-scripts/ifcfg-eth4 as root user.
echo -e "ONBOOT=\"YES\"\nIPADDR=10.42.84.168\nPREFIX=24" | sudo tee -a /etc/sysconfig/network-scripts/ifcfg-eth4
Print the names and sizes of all regular files from the current directory tree
find . -type f -printf "%f %s\n"
Print the names and sizes of regular files residing in the "dir" directory tree
find dir -type f -printf "f %s %p\n"
Print the name of "file1" if this file is newer than "file2"
find file1 -prune -newer file2
Print the names of all files and directories in the current directory tree
find .
Print the names of all files and directories in the current directory tree
find . -print
Print the names of all files from the /tmp/dir1 directory tree
find /tmp/dir1 -exec basename {} \;
Print the names of all the files from directory tree ~/some/directory whose names end in "rb"
find ~/some/directory -name "*rb" -exec basename {} \;
prints the names of all files in the directory tree rooted in /usr/src whose name ends with ‘.c’ and that are larger than 100 Kilobytes.
find /usr/src -name '*.c' -size +100k -print
Print the names of all files in or below the current directory, with all of the file permission bits S_ISUID, S_ISGID, and S_IWOTH set
find . -perm -o+w,+s
Print the names of all hidden regular files from the current directory
find . -maxdepth 1 -type f -name '.*' -exec basename {} \;
print the names of all of the unstripped binaries in the /usr/local directory tree. Builtin tests avoid running file on files that are not regular files or are not executable
find /usr/local -type f -perm /a=x | xargs file | grep 'not stripped' | cut -d: -f1
Print the names of all regular files in the current directory tree
find . -type f -exec echo {} \;
Print the names of any differing files in directories "dir1/" and "dir2/"
diff --brief --recursive dir1/ dir2/
Print name of the file system containing $path.
df -h $path | cut -f 1 -d " " | tail -1
Print the names of the subdirectories of /usr/local/svn/repos/ prepending "/usr/local/backup" to them
find /usr/local/svn/repos/ -maxdepth 1 -mindepth 1 -type d -exec echo /usr/local/backup{} \;
Prints name of temporary file but doesn`t create nothing.
mktemp -u
Print the newest *.txt file under current directory with timestamp and path
find . -name "*.txt" -printf "%T@ %p\n" | sort | tail -1
Print newline, word and byte count for all .h, .c, .cpp, .php and .cc files under current directory tree and also show the total counts
wc `find . -name '*.[h|c|cpp|php|cc]'`
Prints newline, word, and byte count for each *.py in a current folder.
wc *.py
Print newline, word, and byte counts of each '*.java' file within current directory, and total newline, word, and byte counts
find . -name \*.java | tr '\n' '\0' | xargs -0 wc
Print nothing because B.txt is compared with itself.
comm -2 -3 <(sort -n B.txt) <(sort -n B.txt)
Print NS record for domain 'domain.' from 'some.other.ip.address' nameserver
dig @some.other.ip.address domain. ns
Print NS record for domain 'domain.' from 8.8.8.8 nameserver
dig @8.8.8.8 domain. ns
Prints the Nth line of output from 'ls -1'
ls -1 | tail -n +N | head -n1
Print numbers 1 through 10 separated by ":"
yes | head -n10 | grep -n . | cut -d: -f1 | paste -sd:
Print numbers from 1 to 10 using up to 4 processes
seq 10 | xargs -P4 -I'{}' echo '{}'
Print numbers from 1 to 10 with padded leading zeros
seq -w 1 10