nl
stringlengths 13
387
| bash
stringlengths 1
532
|
|---|---|
Prints a random number between 2000 and 65000
|
seq 2000 65000 | sort -R | head -n 1
|
Print a random number from 2000 to 65000
|
seq 2000 65000 | sort -R | head -n 1
|
Print a randomly sorted list of numbers from 1 to 10 to file "/tmp/lst" and the screen followed by " -------"
|
seq 1 10 | sort -R | tee /tmp/lst |cat <(cat /tmp/lst) <(echo '-------')
|
Print A record for domain 'domain.' from 'ns1.newnameserver' nameserver
|
dig @ns1.newnameserver domain. a
|
Print A record for domain 'domain.' from 'ns2.newnameserver' nameserver
|
dig @ns2.newnameserver domain. a
|
Print A record for domain 'domain.' from 8.8.8.8 nameserver
|
dig @8.8.8.8 domain. a
|
Print a sorted list of *.so files in the bla directory tree
|
find bla -name *.so -print0 | sort -rz
|
Print a sorted list of directories from the ~/Music tree containing files whose names begin with "cover."
|
find ~/Music/ -iname 'cover.*' -printf '%h\n' | sort -u
|
Print a sorted list of the extensions of the regular files from the current directory tree
|
find . -type f | grep -o -E '\.[^\.]+$' | sort -u
|
Print a sorted list of regular files from directory tree /folder/of/stuff
|
find /folder/of/stuff -type f | sort
|
Print a sorted list of the subdirectories of ~/Music
|
find ~/Music/ -maxdepth 2 -mindepth 2 -type d | sort
|
Print a sorted list of unique directory paths in entire file system that match the pattern '<name_pattern>' in their names
|
find / -name '<name_pattern>' -type d | sort | uniq
|
Print a space separated list of numbers from 1 to 10 with no trailing new line
|
seq 10 | xargs echo -n
|
Print a summary of the command-line usage of find
|
find --help
|
Print a top 20 histogram of characters used from standard input showing backslash escapes for non-displayables
|
od -cvAnone -w1 | sort -b | uniq -c | sort -rn | head -n 20
|
Print a unique list of characters from standard input showing backslash escapes for non-displayables
|
od -cvAnone -w1 | sort -bu
|
Print a welcome message with the current user's user name
|
echo "Welcome $(whoami)!"
|
Print a welcome message with the current user's user name
|
echo "Welcome `whoami`!"
|
Print a welcome message with the current user's user name
|
echo -ne "Welcome $(whoami)!\n"
|
Print a welcome message with the current user's user name
|
echo -ne "Welcome `whoami`!\n"
|
prints absolute file paths for files in current directory
|
find `pwd` -maxdepth 1
|
Print the absolute path of "$path"
|
readlink -f "$path"
|
Print absolute path of "YOUR_PATH"
|
readlink -f YOUR_PATH
|
Print absolute path of java executable
|
readlink -f $(which java)
|
Print the absolute path of third-level files under the current directory tree and number the output
|
ls -d -1 $PWD/**/*/* | nl
|
Print all '-' separated digits in file 'infile' as dot ('.') separated digits
|
grep -Eo '([0-9]+-){3}[0-9]+' infile | tr - .
|
Print all business days in the current month without column titles
|
cal -h | cut -c 4-17 | tail -n +3
|
Print all directories under $root appending a : (colon) at the end of each path without descending into directories matching the pattern .[a-z]*
|
find "$root" -name ".[a-z]*" -prune -o -type d -printf '%p:'
|
Print all distinct characters in input "He likes cats, really?"
|
echo "He likes cats, really?" | fold -w1 | sort -u
|
Print all files and directories in the `.' directory tree skipping SCCS directories
|
find . -name SCCS -prune -o -print
|
Print all files/directories under ... directory by terminating their paths with a null character
|
find ... -print0
|
Print all files/directories with their sizes under $WHATEVER directory tree
|
find $WHATEVER -printf "%s %p\n"
|
Print all files containing "word1" and "word2" in the current directory tree
|
comm -12 <(grep -rl word1 . | sort) <(grep -rl word2 . | sort)
|
print all files in the current directory and all subdirectories
|
find .
|
print all files in the current directory and all subdirectories
|
find . -print
|
Print all files in the current directory as a comma separated list
|
ls -1 | paste -sd "," -
|
Print all files in the current directory tree as a comma separated list
|
find . -type f -print0 | tr '\0' ','
|
Print all files in the current directory tree as a comma separated list
|
find . -type f | paste -d, -s
|
print all files in the directories except the ./src/emacs directory
|
find . -wholename './src/emacs' -prune -o -print
|
print all files in the file system excluding those ending with ".c"
|
find / \! -name "*.c" -print
|
Print all files on the system owned by group `name_of_group'
|
find / -group name_of_group
|
Print all file/directory names with white space safety under the /proc directory
|
find /proc -print0 | xargs -0
|
Print all file/directory names without white space safety under the /proc directory
|
find /proc | xargs
|
Print all files that exceed 1000 blocks and were modified at least a month ago
|
find / -size +1000 -mtime +30 -exec ls -l {} \;
|
Print all files with a '-' after their name if they are regular files, and a '+' otherwise
|
find / -type f -exec echo {} - ';' -o -exec echo {} + ';'
|
Print all filenames in /usr/src except for those that are of the form '*,v' or '.*,v'
|
find /usr/src -not \( -name "*,v" -o -name ".*,v" \) '{}' \; -print
|
print all filenames of files under current dir containing 'foo', case-insensitive
|
find . -type f -exec grep -il 'foo' {} \;
|
Print all filenames under /proc and below
|
find /proc -exec ls '{}' \;
|
Print all filenames under /proc and below
|
find /proc -print0 | xargs -0
|
Print all filenames under /proc and below
|
find /proc | xargs
|
Print all lines from file 'report.txt' containing any-cased 'error' pattern
|
cat report.txt | grep -i error
|
Print all matching commands in $PATH for command "python"
|
which -a python
|
Print all non-hidden files in the current directory and its subdirectories
|
find . -not -path '*/\.*'
|
print all readline bindings
|
bind -P
|
Prints all Saturday days of a current month.
|
cal -h | cut -c19-20
|
Print all string from file 'file2.txt' matching pattern in file 'file1.txt'
|
grep "$(cat file1.txt)" file2.txt
|
Print all unique strings in $1.tmp file.
|
cat $1.tmp | sort -u
|
Print all user names and terminals of users who are logged in
|
who | cut -d " " -f1,2
|
Print and delete all directories named 'work' under '/usr/ports/' directory tree
|
find /usr/ports/ -name work -type d -print -exec rm -rf {} \;
|
Print and recursively remove the alphabetically last directory in the current directory
|
find -mindepth 1 -maxdepth 1 -type d | cut -c 3- | sort -k1n | tail -n 1 | xargs -r echo rm -r
|
Print and save the ping results of 25 requests to "google.com" in "/home/user/myLogFile.log" containing at most 100000 bytes
|
ping -c 25 google.com | tee >(split -d -b 100000 - /home/user/myLogFile.log)
|
print apparent size rather than disk usage
|
du -B1 --apparent-size /tmp/foo.txt
|
Print appended data in "/var/log/syslog" as the file grows
|
tail -f /var/log/syslog
|
Print appended data in "file" that match "my_pattern"
|
tail -f file | grep --line-buffered my_pattern
|
Print argument "$1" "$number" times
|
yes $1 | head -$number
|
Print as many dots as there are files named "file.ext" in the /home/kibab directory tree
|
find /home/kibab -name file.ext -exec echo . ';'
|
Print the average round trip time of 5 pings to "google.com"
|
ping -q -c 5 google.com | tail -n 1 | cut -f 5 -d '/'
|
Print the average round trip time of 5 pings to "google.com" from OSX
|
ping -c 5 google.com | grep "round-trip" | cut -f 5 -d "/"
|
Print base name of the file name without all extensions.
|
basename "$FILE" | cut -d'.' -f-1
|
print bindings for "p" and "e" with no case sensitivity
|
bind -p|grep -i '"[pE]"'
|
Print the byte count of all regular files found in the current directory tree
|
find . -type f | xargs | wc -c
|
Prints calendar for a current month.
|
cal
|
Print calendar for February, March and April of year 2009 side-by-side
|
paste <(cal 2 2009) <(cal 3 2009) <(cal 4 2009)
|
Prints calendar of February, 1900.
|
cal 2 1900
|
Prints calendars of July, 2009 and July, 2010 side-by-side.
|
paste <(cal 6 2009) <(cal 6 2010)
|
Print canonical filename of "/path/here/.."
|
readlink -f /path/here/..
|
Print canonical filename of "/path/there/../../" even if it does not exist
|
readlink -m /path/there/../../
|
Print characters 2 through 4 of "abcdefg"
|
echo 'abcdefg'|tail -c +2|head -c 3
|
Print the characters in $b that match with any character in $a without printing any newline
|
echo "$b" | grep -o "[$a]" | tr -d '\n'
|
Print the characters in $b that match with any character in $a without printing any whitespace in-between
|
echo "$b" | grep --only-matching "[$a]" | xargs | tr --delete ' '
|
Print characters in variable "$a" that exist in variable "$b"
|
echo "$(comm -12 <(echo "$a" | fold -w1 | sort | uniq) <(echo "$b" | fold -w1 | sort | uniq) | tr -d '\n')"
|
Print chmod commands that can change permissions of regular files residing in the current directory tree to u=rw,g=r,o=
|
find . -type f -exec echo chmod u=rw,g=r,o= '{}' \;
|
Print comma separated gaps in file "file" that contains new line separated ordered numbers
|
seq $(tail -1 file)|diff - file|grep -Po '.*(?=d)'
|
Print command history
|
history
|
Print command line of process with pid 17709
|
cat /proc/17709/cmdline | xargs -0 echo
|
Print command with PID 11383
|
ps | egrep 11383 | tr -s ' ' | cut -d ' ' -f 4
|
Print common files of directory "one" and "two"
|
comm -12 <(ls one) <(ls two)
|
Print common lines in "file1" and "file2"
|
comm -12 file1 file2
|
Print common lines in files "set1" and "set2"
|
comm -12 <(sort set1) <(sort set2)
|
Print common lines in sorted files "ignore.txt" and "input.txt"
|
comm -12 ignore.txt input.txt
|
Print common lines of files "file1", "file2", "file3", and "file4"
|
comm -12 <(comm -12 <(comm -12 <(sort file1) <(sort file2)) <(sort file3)) <(sort file4)
|
Print the compressed size, uncompressed size, compression ratio, and uncompressed filename of "file.zip"
|
gunzip -l file.zip
|
Print concatenated content of all files ending with '.foo' under the current folder
|
cat `find . -name '*.foo' -print`
|
Print the contents of "$FILE" starting from line 2
|
tail -n +2 "$FILE"
|
Print the contents of "${SPOOL_FILE}" file to the console and append to "${LOG_FILE}" file
|
cat ${SPOOL_FILE} | tee -a ${LOG_FILE}
|
Print the contents of "Little_Commas.TXT"
|
cat Little_Commas.TXT
|
Print contents of "file" as space separated hexadecimal bytes on a single line
|
od -t x1 -An file |tr -d '\n '
|
Print the contents of "file" in reverse order
|
nl file | sort -nr | cut -b8-
|
Print the contents of "filename"
|
cat filename
|
Print the contents of "foo.txt" starting with line 2
|
tail -n +2 foo.txt
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.