nl
stringlengths
13
387
bash
stringlengths
1
532
Print the contents of "my_script.py"
cat my_script.py
Print the contents of "n"
cat n
Print the contents of "numbers.txt"
cat numbers.txt
Print the contents of "xx.sh"
cat xx.sh
Print the contents of "~/.ssh/config"
cat ~/.ssh/config
Print content of '1' file
$ cat 1
Print content of 'a' file, showing all non-printing characters including TAB characters, and displaying $ at the end of each line.
cat -vet a
Print content of 'domains.txt' with removed first one of dot-delimited fields
rev domains.txt | cut -d '.' -f 2- | rev
Print content of 'file' file reverted characterwise
rev file
Print content of 'filename' file, showing all non-printing characters and displaying $ at the end of each line.
cat -v -e filename
Print content of 'whatever' file
cat whatever | egrep 'snozzberries|$'
Print content of /etc/passwd and /etc/group files
cat /etc/passwd /etc/group
Print content of all files ending with '*.foo' in current directory recursively
find . -name '*.foo' -exec cat {} \;
Print content of all files ending with '*.foo' under the current directory
cat $(find . -name '*.foo')
Print content of all files found regarding seach options '[whatever]'
find [whatever] -exec cat {} +
Print content of all files found regarding seach options '[whatever]'
find [whatever] -exec cat {} \;
Print content of all files found regarding seach options '[whatever]'
find [whatever] -print0 | xargs -0 cat
Print content of all files found regarding seach options '[whatever]'
find [whatever] | xargs cat
Print content of each file under the current directory followed by that file name
find . -type f -exec cat {} \; -print
Print continuous lines of 100 random characters either "." or " "
cat /dev/urandom | tr -dc '. ' | fold -w 100
Print the current date followed by ": $line"
echo "$(date): " $line
Print the current date followed by ' doing stuff'
echo $(date) doing stuff
Print the current date in '%H:%M:%S' format followed by the string ': done waiting. both jobs terminated on their own or via timeout; resuming script'
echo "$(date +%H:%M:%S): done waiting. both jobs terminated on their own or via timeout; resuming script"
Print the current default full path of the "java" executable
echo "The current default java is $(readlink --canonicalize `which java`)"
Print the current directory
find -maxdepth 0
Print the current directory
find -mindepth 0 -maxdepth 0
Print the current directory
find -prune
Prints current directory name
pwd | grep -o "\w*-*$"
Print the current directory tree with file permissions
tree -p
Print the current directory tree with file sizes
tree -s
Prints current month calendar, without highlighting of a current date.
cal -h
Print current shell using process ID
ps -ef | grep $$ | grep -v grep
Print the current user's mail file in "/var/spool/mail"
cat /var/spool/mail/`whoami`
Print current UTC date in ISO format with precision to seconds
date -u -Iseconds
Print the current working directory and the base name of "$1"
echo "$(pwd)/$(basename "$1")"
Print the current working directory prepended by "pwd: "
echo pwd: `pwd`
Print the current working directory with resolved symbolic links
pwd -P
Print the current working directory without a trailing newline
echo -n $(pwd)
Print the date followed by the host name
echo `date` `hostname`
Print the date formatted with "%a %x %X" followed by the host name
echo `date +"%a %x %X"` `hostname`
Print the day 1 day ago
date --date='1 days ago' '+%a'
Print differences between files in directories folder1 and folder2 recursively, with unified context, ignoring changes in the amount of white space
diff -bur folder1/ folder2/
Print the directory name of the full real path to the current script
echo "dirname/readlink: $(dirname $(readlink -f $0))"
Print the directory of the full path to the current script
echo $(dirname $(readlink -m $BASH_SOURCE))
Print the directories that are taken by the glob pattern $SrvDir*
find $SrvDir* -maxdepth 0 -type d
Prints directory where the executing script ($0) is located.
$(dirname $0)
Prints directory where the executing script ($0) is located.
`dirname $0`
print disk usage of files or folders in current directory
du -sh *
Print each character in "Hello" as a hexadecimal value
echo -n "Hello" | od -A n -t x1
Print each character in "orange" on a new line
echo orange | fold -w 1
Print each character of "abcdefg" on a line
echo "abcdefg" | fold -w1
Print each line in "f1" and "f2" separated by a space and "f3" separated by a tab
paste <(paste -d" " f1 f2) f3
Print each line in "file1" whose first word does not exist as the first word of any line in "file2"
join -v 1 <(sort file1) <(sort file2)
Print each line in "file1.txt" that is not found in "file2.txt"
sort file1.txt file2.txt file2.txt | uniq -u
Print each line in parallel in files "tmp/sample-XXX.tim" and "tmp/sample-XXX.log"
paste tmp/sample-XXXX.{tim,log}
Print each logged in user's full name
finger -l | grep "Name:" | cut -d ":" -f 3 | cut -c 2- | sort | uniq
Print each logged in user's username and full name
finger -l | grep "Name:" | tr -s ' ' | cut -d " " -f 2,4- | sort | uniq
Print each unique line that is duplicated in files "file1" and "file2" combined
sort file1 file2 | uniq -d
Print either "one" or "two" randomly three times
yes $'one\ntwo' | head -10 | nl | sort -R | cut -f2- | head -3
Print the empty directories and files under current directory
find -empty
Print epoch seconds for given time string "Oct 21 1973"
date -d "Oct 21 1973" +%s
Print equal lines in compressed files "number.txt" and "xxx.txt"
comm -12 <(zcat number.txt.gz) <(zcat xxx.txt.gz)
Print every two lines in "file" on a single line separated by a space
cat file | paste -d' ' - -
Print every two lines in "file" on a single line separated by a space
cat file | paste -d\ - - -
Print every 3 characters of standard input as a line
fold -w3
Print every three lines of "file" as a comma separated line
paste -sd',,\n' file
Print every file's type, name, and inode
find -printf "%y %i %prn"
Print every found file like '*.cfg' under '/path/to/files/' directory followed by its content, and wait 2 seconds after each printed file
find /path/to/files -type f -name \*.cfg -print -exec cat {} \; -exec sleep 2 \;
Print extended file information for regular files found under the home directory whose names start with my
find . -name 'my*' -type f -ls
Print the file content of command "f"
cat "$(which f)"
Print the file content of command "f"
cat `which f`
Print file extension assuming there is only one dot in the file name.
echo "$FILE" | cut -d'.' -f2
Print the files in the current directory as a list of comma separated values
ls -1 | tr '\n' ','
Print the files in the current directory as a list of semicolon separated values
ls -1b | tr '\n' ';'
Print the files in the current directory as a list of semicolon separated values
ls -m | tr -d ' ' | tr ',' ';'
Print file information of command "bash"
echo $(ls -l $(which bash))
Print file information of command "passwd"
ls -l `which passwd`
Print file information of command "studio"
ls -l "$( which studio )"
Print file information of command "studio"
which studio | xargs ls -l
Print file information of the executable file of command "g++"
ls `which g++` -al
Print file information of the executable file of command "gcc"
ls `which gcc` -al
Print the file names along with their sizes under current directory tree
find . -type f -printf "%f %s\n"
Print file names of all files ending with '*.csv' in '/home/ABC/files/' directory
ls /home/ABC/files/*.csv | rev | cut -d/ -f1 | rev
Print file name without extension assuming there is only one dot in the file name.
echo "$FILE" | cut -d'.' -f1
Print file name without the last two extensions assuming the file name doesn't contain any other dots.
echo "$FILE" | cut -d'.' --complement -f2-
Print file name without the last two extensions assuming the file name doesn't contain any other dots.
echo "$FILE"|rev|cut -d"." -f3-|rev
Print the file paths and their sizes for all files under full_path_to_your_directory
find full_path_to_your_directory -type f -printf '%p %s\n'
Prints the file path composed from the path where symlink target file is located, and name of the symbolic link itself.
echo "$(dirname $(readlink -e $F))/$(basename $F)"
Print the file sizes along with their paths for all *.txt (case insensitive) files/directories under current directory tree
find . -iname "*.txt" -exec du -b {} +
Print the file sizes along with their paths for all *.txt (case insensitive) files/directories under current directory tree
find . -name "*.txt" -print0 |xargs -0 du -ch
Print file size and user name with color support for each file in the current directory tree
tree -Csu
Print file size with the file name
find . -name '*.ear' -exec du -h {} \;
Print the file system "file/goes/here" is on
df -P file/goes/here | tail -1 | cut -d' ' -f 1
Print file system disk space usage
df
Print file system disk space usage and grand total for the root file system with sizes in powers of 1000
df -H --total /
Print the file system disk space usage for "/dev/disk0s2" if exists
df | grep /dev/disk0s2
Print file system disk space usage in 1 KiB blocks of the current directory's file system
df -k .
Print file system disk space usage in posix and human readable format, format as a table
df -Ph | column -t
Print file system disk space usage of the current directory's file system
df .
Print file system disk space usage with a grand total
df --total