nl stringlengths 13 387 | bash stringlengths 1 532 |
|---|---|
Ping every address from 192.168.0.1 to 192.168.0.254 with a timeout of 1 second and filter out no responses | echo $(seq 254) | xargs -P255 -I% -d" " ping -W 1 -c 1 192.168.0.% | grep -E "[0-1].*?:" |
Pipe 3 newlines to sshe-keygen, answering prompts automatically. | echo -e "\n\n\n" | ssh-keygen -t rsa |
Pipe content of 'somedata.txt' file to the input of command "$outfile" | cat somedata.txt | "$outfile" |
Pipe the output of ls into "read var" in its separate process | ls | read var |
Places current job to background. | bg % so it wont die when you logoff |
Prefix all files and directories in the current directory with "Unix_" | ls | xargs -I {} mv {} Unix_{} |
Prefix all files and directories in the current directory with "unix_" | ls | xargs -i mv {} unix_{} |
Prefix all files and folders in the current directory with "PRE_" | find * -maxdepth 0 ! -path . -exec mv {} PRE_{} \; |
Prefix all files and folders in the current directory with "PRE_" | ls | xargs -I {} mv {} PRE_{} |
Prefix each non-blank line in "filename" with a line number | nl filename |
Prepend date to ping output to google.com | ping google.com | xargs -L 1 -I '{}' date '+%+: {}' |
Prepend the reverse history number to the output of the history command with arguments "$@" | history "$@" | tac | nl | tac |
prevents curl from returning error (23) Failed writing body when grepping for foo | curl "url" | tac | tac | grep -qs foo |
Prevent ssh from reading from standard input and execute "touch /home/user/file_name.txt" on "$R_HOST" as "$R_USER" | ssh -n $R_USER@$R_HOST 'touch /home/user/file_name.txt' |
Print "#include" statements found in "file2" that are not in "file1" | comm -13 <(grep '#include' file1 | sort) <(grep '#include' file2 | sort) |
Print "$1" or default 10 random lines from standard input | nl | sort -R | cut -f2 | head -"${1:-10}" |
Prints "$NEWFILE" to the terminal and file '/etc/timezone' as a root user. | echo "$NEWFILE" | sudo tee /etc/apt/sources.list |
Print "$line" in hexadecimal 2-byte units | echo -n $line | od -x |
Print "$somedir is empty" if $somedir is empty | find "$somedir" -maxdepth 0 -empty -exec echo {} is empty. \; |
Print "*Checking Partition Permission* Hostname=$(hostname) LastChecked=" followed by the current date | echo -n *Checking Partition Permission* Hostname=$(hostname) LastChecked=$(date) |
Print "/tmp/myfile" starting at line 11 | tail -n +11 /tmp/myfile |
Print "Cannot acquire lock - already locked by " followed by content of $lockfile file | echo "Cannot acquire lock - already locked by $(cat "$lockfile")" |
Print "I am USER and the program named ls is in LS_PATH" where "USER" is the current user's user name and "LS_PATH" is the full path of the command "ls" | echo I am $(whoami) and the program named ls is in $(which ls). |
Print "RDBMS exit code : $RC " to the console and append to "${LOG_FILE}" | echo " RDBMS exit code : $RC " | tee -a ${LOG_FILE} |
Print "Total generated: " followed by the number of unique lines in "$generated_ports" | echo "Total generated: $(echo "$generated_ports" | sort | uniq | wc -l)." |
Print "a\nb\ncccccccccccc\nd" as two columns and neatly format into a table | echo -e "a\nb\ncccccccccccc\nd" | paste - - | column -t |
Print "deb http://ppa.launchpad.net/webupd8team/java/ubuntu precise main" and append to file "/etc/apt/sources.list" | echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu precise main" | tee -a /etc/apt/sources.list |
Print "echo ping -c 2" on each string in file 'ips' | cat ips | xargs -n1 echo ping -c 2 |
Print "echo ping -c 2" on each string in file 'ips' | cat ips | xargs echo ping -c 2 |
Print "file1.txt" "file2.txt" and "file3.txt" with filename headers | tail -n +1 file1.txt file2.txt file3.txt |
Print "hello" followed by the current user name | echo hello `whoami` |
Print "huge-file.log" starting at line 1000001 | tail -n +1000001 huge-file.log |
Print "huzzah" if directory "/some/dir" is empty | find /some/dir/ -maxdepth 0 -empty -exec echo "huzzah" \; |
Print "new.txt" with line numbers prepended | cat new.txt | nl |
Print "on" to standard output and to files matching "/sys/bus/usb/devices/usb*/power/level" | echo "on" | tee /sys/bus/usb/devices/usb*/power/level |
Print "test=hello world" | echo "hello world" | echo test=$(cat) |
Print the $N'th line from file by replacing commas (',') with newlines | head -$N file | tail -1 | tr ',' '\n' |
Print $d if $d is an empty directory | find "$d" -prune -empty -type d |
Print $d if $d is empty | find "$d" -prune -empty |
Prints $m latest modified files within the $d folder, using $f format for printing timestamp. | find "$d" -type f -printf "%T@ :$f %p\n" | sort -nr | cut -d: -f2- | head -n"$m" |
Print '"HTTP/1.1 200 OK', two new lines and the current date | echo -e "HTTP/1.1 200 OK\n\n $(date)" |
Print '-exec is an action so an implicit -print is not applied' for every file/directory found by the name 'file' under current directory tree | find -name file -exec echo '-exec is an action so an implicit -print is not applied' \; |
Print '-ok is an action so an implicit -print is not applied' with confirmation from the user for each file or directory found by the name 'file' under current directory tree | find -name file -ok echo '-ok is an action so an implicit -print is not applied' \; |
Print '-okdir is an action so an implicit -print is not applied' for each file/directory found by the name 'file' under current directory tree | find -name file -okdir echo '-okdir is an action so an implicit -print is not applied' \; |
Print '111 22 3\n4 555 66\n' by replacing the spaces with tabs and '\n' with newlines | echo -en '111 22 3\n4 555 66\n' | tr ' ' '\t' |
Print 'Since -printf is an action the implicit -print is not applied\n' for every file named 'file' found under current directory tree | find -name file -printf 'Since -printf is an action the implicit -print is not applied\n' |
Print 'This should print the filename twice if an implicit -print is applied: ' appended with file paths for all files named 'file' under current directory tree | find -name file -exec echo 'This should print the filename twice if an implicit -print is applied: ' {} + |
Print 'bla.txt' if at least one file with such name is present below the current directory. | ls -alFt `find . -name "bla.txt"` | rev | cut -d" " -f1 | rev | head -1 |
Print 'cp' commands that would copy a file xyz.c to all the files with '.c' extension present in the ./C directory and below | find ./C -name "*.c" | xargs -n1 echo cp xyz.c |
Print 'echo 'hello, world' | echo 'hello, world' | cat |
Print 'file' content, formatting output as 29-symbol wide column, regarding space symbol as a word separator | cat file | fold -s -w29 |
Print 'file' file, splitting lines into pieces with no more that 3 words in each one. | cat file | xargs -n3 |
Print 'infile' content with line numbers | cat -n infile |
Print /some/dir/ if it's empty | find /some/dir/ -maxdepth 0 -empty |
Print 1 to 10 by separating them with colon (':') | echo {1..9}: 10 | tr -d ' ' |
Print 10 "#" characters in a row | yes '#' | head -n 10 | tr -d '\n' |
Print 10 lines of a single "x" | yes x | head -n 10 |
Print 1000 astarisk ('*') | head -c 1000 /dev/zero | tr '\0' '*' |
Print 2 lines of "123456789" | yes 123456789 | head -2 |
Print three lines of "some line " followed by a random number | seq -f 'some line %g' 500 | nl | sort -R | cut -f2- | head -3 |
Print 3 newline separated "y"s | yes | head -3 |
Print 3 space separated '%' | echo $(yes % | head -n3) |
Print the 5th space separated fields in "file" as a comma separated list | cut -d' ' -f5 file | paste -d',' -s |
Print 7 spaces in a row | yes ' ' | head -7 | tr -d '\n' |
Print a 2 byte hexadecimal value, printable character, and octal value of "$1" | echo "$1" | od -xcb |
Print a colon-separated list of all directories from the $root directory tree | find $root -type d -printf '%p:' |
Print a colon-separated list of all directories from the $root directory tree | find $root -type d | tr '\n' ':' |
Print a colon-separated list of all directories from the ~/code directory tree, except hidden ones and those below them | find ~/code -name '.*' -prune -o -type d -printf ':%p' |
Print a colon-separated list of all directories from the ~/code directory tree, except hidden ones and those below them | find ~/code -name '.*' -prune -o -type f -a -perm /u+x -printf ':%h\n' | sort | uniq | tr -d '\n' |
Print a count of all unique entries in "ips.txt" with the most frequent results at the top | sort ips.txt | uniq -c | sort -bgr |
Print a count of all unique lines in "ports.txt" sorted from most frequent to least frequent | sort ports.txt | uniq -c | sort -r |
Print a count of case insensitive duplicate filenames in the current directory | ls -1 | tr '[A-Z]' '[a-z]' | sort | uniq -c | grep -v " 1 " |
Print a count of each unique line from standard input | sort | uniq -c |
Print a count of each unique line from standard input sorted from least frequent to most frequent | sort | uniq -c | sort -n |
Print a count of each unique line in "ip_addresses" | sort ip_addresses | uniq -c |
Print a count of each unique line in "ip_addresses.txt" sorted numerically | sort -n ip_addresses.txt | uniq -c |
Print a count of files and directories in the current directory tree | tree | tail -1 |
Print a detailed list of all regular files from the current directory tree | find . -type f -ls |
Print a hex dump byte to byte of the output of "echo Aa" | echo Aa | od -t x1 |
Print a hex dump of "$DIREC" as characters | echo "$DIREC" | od -c |
Print a line of 10 '#' characters | seq -f "#" -s '' 10 |
Print a line of 100 random characters either "." or " " | cat /dev/urandom | tr -dc '. ' | fold -w 100 | head -1 |
Print a line of 3 '%' characters | seq -s % 4|tr -d '[:digit:]' |
Print a line of 99 '=' characters | seq -s= 100|tr -d '[:digit:]' |
Print a listing of the `other' directory | $ find other -maxdepth 1 |
Print a listing of the `other' directory | find other -maxdepth 1 -printf "%P\n" |
Print a list of all files and directories in the /var/log directory tree | find /var/log/ |
Print a list of all the files in entire file system whose inode has been modified no later than one minute ago | find / -newerct '1 minute ago' -print |
Print a list of all regular files residing in the current directory | find . -maxdepth 1 -type f -print0 |
Print a list of differing files | diff -q /dir1 /dir2|cut -f2 -d' ' |
Print a list of each file with the full path prefix in the current directory tree excluding symbolic links | tree -fi |grep -v \> |
Print a list of JPG files residing in the current directory tree | find . -name “*.jpg” |
Print a list of regular files from directory tree sort_test/ sorted with LC_COLLATE=C | find sort_test/ -type f | env -i LC_COLLATE=C sort |
Print a list of symbolic links reachable from the current directory that do not resolve to accessible files | find -L. -type l |
Print a minimal set of differences between files in directories "a" and "b", ignore differences in whitespace, and print 0 lines of unified context | diff -dbU0 a b |
Print a minimal set of differences between files in directories "a" and "b", ignore the first 3 lines of output, and print any line starting with "-" with the first character removed | diff -dbU0 a b | tail -n +4 | grep ^- | cut -c2- |
Print a NULL-separated list of all directories of the current directory tree | find . -type d -print0 |
Print a NULL-separated list of all hidden regular files from the home directory | find $HOME -maxdepth 1 -type f -name '.*' -print0 |
prints a number stored among text in $filename | echo $filename | egrep -o '[[:digit:]]{5}' | head -n1 |
Prints a random line from $FILE | sort --random-sort $FILE | head -n 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.