nl
stringlengths 13
387
| bash
stringlengths 1
532
|
|---|---|
Print numbers from 1 to 100
|
seq 1 100
|
Print numbers from 1 to 30 with 0 padding to a width of 2
|
seq -f "%02g" 30
|
Print numbers from 1 to 30 with a leading 0
|
seq -w 30
|
Print numbers from 1 to 30 with equalized 0 padding
|
seq -w 30
|
Print numbers from 1 to the number in variable "$1"
|
seq $1
|
Print numbered list of all third-level files under the current directory
|
ls -d -1 $PWD/**/*/* | cat -n
|
Print numbered list of all top-level files in the current directory, with name containing 'android'
|
ls | grep "android" | cat -n
|
Print number of bytes in $file.
|
cat $file | wc -c
|
Print the number of entries (files, directories, symlinks, etc.) in the subdirectories of the current directory, stopping search at any device mount points.
|
sudo find . -xdev -type f | cut -d "/" -f 2 | sort | uniq -c | sort -n
|
Prints number of files with extension "${EXTENSION}" in the "${SEARCHPATH}" directory.
|
echo "Number files in SEARCH PATH with EXTENSION:" $(ls -1 "${SEARCHPATH}"/*."${EXTENSION}" | wc -l)
|
Print the number of lines in file.txt.
|
wc -l file.txt | cut -f1 -d" "
|
Print number of lines that equal in files '/home/xyz/a.csv1' and '/home/abc/tempfile'
|
comm -12 <(sort -u /home/xyz/a.csv1) <(sort -u /home/abc/tempfile) | wc -l
|
Print the number of regular files found in the current directory tree
|
find . -type f | wc -l
|
Print numerically sorted list of unique strings from 'ip_addresses' file, with number of occurrences of each string.
|
sort -n ip_addresses.txt | uniq -c
|
Print only alphanumeric values from "/dev/urandom"
|
cat /dev/urandom | tr -dc 'a-zA-Z0-9'
|
Print only common file names in sorted listings of directory 'dir1' and 'dir2'
|
comm -1 -2 <(ls /dir1 | sort) <(ls /dir2 | sort)
|
Print only common strings in sorted content of files 'file1' and 'file2'
|
comm -1 -2 <(sort file1) <(sort file2)
|
Print only digits in variable "$name"
|
echo $name | tr -c -d 0-9
|
Prints only first ten characters of each string of file $file.
|
cat $file | cut -c 1-10
|
Print only first line of 'file' content, formatted as 29-symbol wide column
|
cat file | fold -w29 | head -1
|
Print only first line of 'file' content, formatted as 29-symbol wide column, regarding space symbol as a word separator
|
cat file | fold -s -w29 | head -1
|
Print only group names from /etc/group.
|
cut -d: -f1 /etc/group
|
Print onlt last slash-separated field from $PATH value
|
echo "$PATH" | rev | cut -d"/" -f1 | rev
|
Print only the line "foo///" given two empty directories foo and bar
|
find foo/// bar/// -name foo -o -name 'bar?*'
|
Print only lines from 'file1.txt' that not present in 'file2.txt' and beginning with 'Q'
|
cat file1.txt | grep -Fvf file2.txt | grep '^Q'
|
Print only the number of lines in file "$f"
|
wc -l $f | tr -s ' ' | cut -d ' ' -f 1
|
Print only printable characters from "/dev/urandom"
|
cat /dev/urandom | tr -dC '[:graph:]'
|
Print only second from the end field from slash-separated string in file 'datafile'
|
cat datafile | rev | cut -d '/' -f 2 | rev
|
Print only strings from file 'file2' that not found in 'file1'
|
comm -1 -3 file1 file2
|
Print only unique lines in files 'set1' and 'set2'
|
cat set1 set2 | sort -u
|
Print only unique lines of 'file_name' file
|
cat -n file_name | sort -uk2 | sort -nk1 | cut -f2-
|
Prints out all the logged-in users along with their group information.
|
groups $(who | cut -d' ' -f 1)
|
Print out the contents of all *.txt files in the home directory
|
find ~ -name '*.txt' -print0 | xargs -0 cat
|
Print out the contents of all *.txt files in the home directory
|
find ~/ -name '*.txt' -exec cat {} ;
|
Print out the full path name of "mypathname" with dots resolved
|
readlink -ev mypathname
|
Print out the names and types of all files in the current directory tree
|
find . -printf "%y %p\n"
|
Print the path composed of the current working directory and the directory containing "$0"
|
echo `pwd`/`dirname $0`
|
Prints path location of $BASH_SOURCE file.
|
echo this dir: `dirname $BASH_SOURCE`
|
Print the path names of all .png files in the /home/kibab directory tree
|
find /home/kibab -name '*.png' -exec echo '{}' ';'
|
Print the path names of all files and directories in the current directory tree
|
find -printf '"%h/%f" '
|
Print the path names of all regular .rb files prefixing them with string "Hello, "
|
find . -name "*.rb" -type f | xargs -I {} echo Hello, {} !
|
Print the paths of the directories from the paths expanded by the glob pattern /path/to/directory/*
|
find /path/to/directory/* -maxdepth 0 -type d
|
Prints path to folder that contains file "/path/to/vm.vmwarevm/vm.vmx".
|
dirname "/path/to/vm.vmwarevm/vm.vmx"
|
Prints path to folder that contains file "/path/to/vm.vmwarevm/vm.vmx".
|
echo /path/to/vm.vmwarevm/vm.vmx | xargs dirname
|
Prints path to the target of symbolic link 'relative/path/to/file'
|
dirname `readlink -e relative/path/to/file`
|
Print the pathnames of all files from the /tmp/dir1 directory tree
|
find /tmp/dir1 -exec echo {} \;
|
Print pathnames of all files in the current directory and below skipping directories named SCCS and files in them
|
find . -name SCCS -prune -o -print
|
Print pathnames of all files in the current directory and below skipping files under SCCS directories
|
find . -print -name SCCS -prune
|
Print the percentage of packets lost of the 5 packets sent to "$host"
|
ping -c 5 -q $host | grep -oP '\d+(?=% packet loss)'
|
Print permissions of every directory in the current directory tree
|
tree -p -d
|
Prints process tree for the current process with ASCII line drawing characters.
|
pstree -A -s $$
|
Prints process tree of a current process with id numbers and parent processes.
|
pstree -sp $$
|
Prints process tree of a process having id $ID with parent processes.
|
pstree -s $ID
|
Prints process tree of the current command process.
|
pstree -p $$
|
Prints process tree of the current process with parent processes.
|
pstree -s $$
|
Prints process tree, showing only strings with 'MDSImporte', and chopping output after ${WIDTH} characters.
|
pstree | grep MDSImporte | cut -c 1-${WIDTH}
|
Prints process tree with command line arguments and process id numbers.
|
pstree -apl
|
Prints process tree with command line arguments of a process having id $PID.
|
pstree -a "$PID"
|
Prints random line from file $FILE.
|
sort --random-sort $FILE | head -n 1
|
print readline bindings that use key code '\\e\\C-k'
|
bind -P | grep '\\e\\C-k'
|
Print the real path of "$F" where each symbolic link component must exist
|
echo "$(dirname $(readlink -e $F))/$(basename $F)"
|
Prints real path of the folder containing $0 file.
|
$(readlink -f $(dirname "$0"))
|
Print received input to the terminal
|
tee
|
Print relative path of device of disk with UUID "b928a862-6b3c-45a8-82fe-8f1db2863be3"
|
readlink /dev/disk/by-uuid/b928a862-6b3c-45a8-82fe-8f1db2863be3
|
Print reverse lookup for adress 127.0.0.1
|
dig -x 127.0.0.1
|
Print reverse lookup for IP address 72.51.34.34
|
dig -x 72.51.34.34
|
Print revesed second from the end dot-bounded field in $i value
|
j=`echo $i | rev | cut -d "." -f2`;
|
Prints running process that has id 'pid' with command line arguments.
|
pstree -a pid
|
Print second field from semicolon-seprated line $string.
|
echo $string | cut -d';' -f2
|
Print second field from semicolon-seprated line <line>.
|
echo "<line>" | cut -d ";" -f 2
|
Print second section of data coming from stdin where sections are separated by one or more whitespace.
|
tr -s ' ' | cut -d ' ' -f 2
|
Print second section of space-separated data from text file "a".
|
cut "-d " -f2 a
|
Print the second space separated fields from standard input
|
tr -s ' ' | cut -d ' ' -f 2
|
Print sed commands that would replace all occurrences of 'previousword' with 'newword' in all regular files with '.cpp' extension under '/myprojects' directory tree
|
find /myprojects -type f -name '*.cpp' -print0 | xargs -0 echo sed -i 's/previousword/newword/g'
|
Prints sequentially listing of a current folder and calendar of a current month.
|
echo `ls` "`cal`"
|
Prints shell option 'globstar' with indication of its status.
|
shopt -p globstar
|
Print short DNS lookup for each domain name in a file 'list'
|
dig +short -f list
|
Print short TXT record of domain o-o.myaddr.l.google.com from nameserver 8.8.8.8
|
dig TXT +short o-o.myaddr.l.google.com @8.8.8.8
|
Print short TXT record of domain o-o.myaddr.l.google.com from nameserver ns1.google.com
|
dig TXT +short o-o.myaddr.l.google.com @ns1.google.com
|
Print the sizes and names of all TXT files from the current directory tree
|
find . -iname "*.txt" -exec du -b {} +
|
Print the size for every *.ogg file found under the home directory
|
find $HOME -name '*.ogg' -type f -exec du -h '{}' \;
|
Print the sizes of all files from the current directory tree
|
find . -iname '*.jpg' -type f -printf +%b
|
Prints sorted list of logged in users.
|
w -h | cut -d' ' -f1 | sort | uniq
|
Print sorted list of strings from 'ip_addresses' file, with number of occurrences of each string.
|
sort ip_addresses | uniq -c
|
Print the sorted unique column of usernames of users who are currently logged in
|
finger | cut -d ' ' -f1 | sort -u
|
Print the sorted unique column of usernames of users who are currently logged in without the header
|
finger | cut -d ' ' -f1 | sort -u | grep -iv login
|
Print the sorted uniqe list of folders in compressed archive nginx-1.0.0.tar.gz
|
tar tf nginx-1.0.0.tar.gz | xargs dirname | sort | uniq
|
Print source directory of bash script
|
dirname "$(readlink -f "$0")"
|
Print source of the file system containing $path.
|
df -P $path | tail -1 | cut -d' ' -f 1
|
Print space separated list of numbers from "$start" to "$end"
|
echo `seq $start $end`
|
Print space separated list of numbers from "$start" to "$end"
|
seq -s' ' $start $end
|
Print space separated numbers from 1 to 10
|
seq 10 | xargs echo
|
Print standard input to standard output line by line, discarding any adjascent duplicate lines.
|
uniq
|
Print summary of files present only in dir1.
|
diff -rq dir1 dir2 | grep 'Only in dir1/'
|
Print summary of new/missing files, and which files differ between /path/to/folder1 and /path/to/folder2, sorted alphabetically.
|
diff -rq /path/to/folder1 /path/to/folder2
|
Print summary of new/missing files, and which files differ between dir1 and dir2.
|
diff --brief --recursive dir1/ dir2/
|
Print summary of new/missing files, and which files differ between dir1 and dir2.
|
diff -q dir1 dir2
|
Print summary of new/missing files, and which files differ between dir_one and dir_two, sorted alphabetically.
|
diff -qr dir_one dir_two | sort
|
Print summary of new/missing files, and which files differ between folder1 and folder2.
|
diff -arq folder1 folder2
|
Print summary of new/missing files, and which files differ between folder1 and folder2, excluding those matching pattern "node_modules".
|
diff -rqyl folder1 folder2 --exclude=node_modules
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.