nl stringlengths 13 387 | bash stringlengths 1 532 |
|---|---|
Save the md5 sum of $twofish to variable 'twofish' | twofish=`echo -n $twofish | md5sum | tr -d " -"` |
Save the network node hostname append with '-', the current date and '.txt' into variable 'filename' | filename="$(uname -n)-$(date +%F).txt" |
Save number of lines in '/some/big/file' to 'LINES' variable | LINES=$(cat /some/big/file | wc -l) |
Save number of lines in 'file.txt' file in 'nbLines' variable | nbLines=$(cat -n file.txt | tail -n 1 | cut -f1 | xargs) |
Save number of lines with any-cased 'merge' from $COMMIT_EDITMSG file in 'MERGE' variable | MERGE=$(cat $COMMIT_EDITMSG|grep -i 'merge'|wc -l) |
Save the number of matching executables for "$cmd" in $PATH to variable "candidates" | candidates=$(which -a $cmd | wc -l) |
Save number of processors in system to 'NP' variable | NP=`cat /proc/cpuinfo | grep processor | wc -l` |
Save number of strings with $expression pattern in 'foo.txt' to 'big_lines' variable. | big_lines=`cat foo.txt | grep -c "$expression"` |
Save the numerically greater value of "$kf" and "$mp" into variable "gv" | gv=$(echo -e $kf'\n'$mp | sort -t'.' -g | tail -n 1) |
Save only the digits in "$filename" to variable "number" | number=$(echo $filename | tr -cd '[[:digit:]]') |
Save the percentage of packets lost of the 5 packets sent to "$host" in variable "packet_loss" | packet_loss=$(ping -c 5 -q $host | grep -oP '\d+(?=% packet loss)') |
Save the physical current working directory to variable "END_ABS" | END_ABS=`pwd -P` |
Saves real path of the folder containing the current script | DIR=$(dirname "$(readlink -f \"$0\")") |
Save the short DNS lookup output of $WORKSTATION to 'WORKSTATION_IP' variable | WORKSTATION_IP=`dig +short $WORKSTATION` |
Save the short host name appended with ".mysqldb" in variable "DBPREFIX" | DBPREFIX="$(hostname -s).mysqldb" |
Save the short system host name to variable "hostname" | hostname=`hostname -s` |
Save small letter short day name of the week to variable 'DayOfWeek' | DayOfWeek=`date +%a |tr A-Z a-z` |
Saves space separated content of $RAW_LOG_DIR in FILES variable | FILES=`cat $RAW_LOG_DIR | xargs -r` |
Save standard input to variable 'stdin' until the first character encoded as '\004' is read | read -d "$(echo -e '\004')" stdin |
Save the system host name in variable "HOSTNAME" | HOSTNAME="`hostname`" |
Save the system host name in variable "HOSTNAME" | HOSTNAME=$(hostname) |
Save the system host name into variable "HOST" | HOST=$(hostname) |
Save the system host name to variable "myHostName" | myHostName=`hostname` |
Save system information appended with the current date in 'filename' variable | filename="$(uname -a)$(date)" |
Save the system load average for the past 1 minute of the currently logged in user to variable 'proc_load_average' | proc_load_average=$(w | head -1 | cut -d" " -f12 | cut -d"," -f1-2 | tr ',' '.') |
Save the user name in upper case of the current user in variable "v" | v=$(whoami | tr 'a-z' 'A-Z') |
Save the user name in upper case of the current user in variable "v" | v=$(whoami | tr [:lower:] [:upper:]) |
Save the user name of the current user to variable "me" | me="$(whoami)" |
Save the user name of the current user to variable "me" | me=$(whoami) |
Save the user name of the current user to variable "whoami" | whoami=$(whoami) |
Save the user name of the current user to variable "x" | x=$(whoami) |
Save the UTC date represented by time string $sting2 as the seconds since epoch to variable 'FinalDate' | FinalDate=$(date -u -d "$string2" +"%s") |
Scan every file in /etc for IPV4 addresses. | find /etc -exec grep '[0-9][0-9]*[.][0-9][0-9]*[.][0-9][0-9]*[.][0-9][0-9]*' {} \; |
Search "file1" for lines matching regex patterns listed in "file2" and list the unique results (sorted alphabetically) | grep -f file2 file1 | sort -u |
Search "file1" for lines matching regex patterns listed in "file2" and list the unique results (sorted alphabetically) | grep -f file2 file1 | sort | uniq |
Search "input.txt" for regex patterns only matching those listed in "ignore.txt", list the unique lines and prefix with the number of occurrences | grep -of ignore.txt input.txt | sort | uniq -c |
Search "inputfile" for lines starting with "t:" and group the results in files with at most 200 lines each | cat inputfile | grep "^t\:" | split -l 200 |
Search the "katalogi" directory tree for files named "wzorzec" | find katalogi -name wzorzec |
Search "mygzfile.gz" for "string to be searched" | gunzip -c mygzfile.gz | grep "string to be searched" |
Search the "test1" directory recursively for regular files | find test1 -type f -print |
Search "whatyousearchfor" in history and print 3 lines before and 4 lines after | history | grep -A 4 -B 3 whatyousearchfor |
Search $MYGROUP in /etc/group, take the 4th colon (':') separated field, replace comma (',') with newline and save the result to variable 'MYUSERS' | MYUSERS=`grep $MYGROUP /etc/group | cut -d ":" -f4| tr "," "\n"` |
Search the `research' directory and one level below for directories that are not owned by group `ian' | find -L research -maxdepth 2 -type d ! -group ian |
Search the 'tmp' directory for .mp3 files | find tmp -maxdepth 1 -name '*.mp3' |
Search the *.c files residing in the current directory tree for string "blash" | find . -name *.c -exec grep -n -e blash {} \; |
Search the *.cc files in the current directory tree for string "xxx" | find . -name "*.cc" -print -exec grep "xxx" {} \; |
Search the *.cc files in the current directory tree for string "xxx" | find . -name "*.cc" | xargs grep "xxx" |
Search the *.code files from the current directory tree for string 'pattern' | find . -name '*.code' -exec grep -H 'pattern' {} + |
Search the *.code files from the current directory tree for string 'pattern' | find . -name '*.code' -print0 | xargs -0 grep -H 'pattern' |
Search the *.txt files from the current directory tree for "string" | find . -name "*.txt" -print0 | xargs -0 egrep 'string' |
Search *.txt files under and below /directory/containing/files for "pattern_to_search" | find /directory/containing/files -type f -name "*.txt" -exec grep -H 'pattern_to_search' {} + |
Search *.x files from the current directory tree for string "fred" | find . -name ‘*.x’ -print0 | xargs -0 grep fred |
Search the ./bin directory recursively for files called "cp" | find ./bin -name “cp” |
Search the .VER files from the current directory tree for Perl regular expression "Model-Manufacturer:.\n." | find . -name "*.VER" -exec grep -P 'Model-Manufacturer:.\n.' '{}' ';' -print |
Search the .VER files from the current directory tree for string "Test_Version=' | find . -name "*.VER" -exec grep 'Test_Version=' '{}' ';' -print; |
Search .c and .h files in the current directory tree for "expr" | find . -name '*.[ch]' | xargs grep -E 'expr' |
Search the .c files residing in the Lib/ directory tree for lines beginning with "PyErr" | find Lib/ -name '*.c' -print0 | xargs -0 grep ^PyErr |
Search the .java files from the /Applications/ directory tree for TODO lines | find /Applications/ -name "*.java" -exec grep -i TODO {} + |
Search the .java files from the /Applications/ directory tree for TODO lines | find /Applications/ -name "*.java" -exec grep -i TODO {} \; |
Search the .java files from the /Applications/ directory tree for TODO lines | find /Applications/ -name "*.java" -print0 | xargs -0 grep -i "TODO" |
Search the .java files from the current directory tree for TODO lines | find . -name "*.java" -exec grep -Hin TODO {} \; |
Search the .java files from the current directory tree for TODO lines | find . -name "*.java" -exec grep -i -n TODO {} \; |
Search the .log files in the current directory tree for string "The SAS System" | find `pwd` -name "*.log" -exec grep "The SAS System" {} \; |
Search the .py files residing in the current directory tree for "something" | find . -name "*.py" -type f -exec grep "something" {} \; |
Search the .sh files in the current directory tree for string "ksh" | find . -name "*.sh" | xargs grep "ksh" |
Search the /Applications directory tree for *.app directories | find /Applications -type d -name "*.app" |
Search the /Path directory tree for files matching pattern "file_name*" | find /Path -name "file_name*" |
Search the /Path directory tree for files whose pathnames match pattern "/Path/bar*" and whose names match pattern "file_name*" | find /Path -path "/Path/bar*" -name "file_name*" |
Search the /Path/bar* directories recursively for files matching pattern "file_name*" | find /Path/bar* -name "file_name*" |
Search the /dir directory tree for files whose names match regular expression '.*2015.*\(album.*\|picture.*\)' | find /dir -regex '.*2015.*\(album.*\|picture.*\)' |
Search the /dir directory tree for files whose names match regular expression '2015.*(album|picture)' | find /dir|egrep '2015.*(album|picture)' |
Search the /etc directory tree for files accessed within the last 24 hours | find /etc -atime -1 |
Search the /etc directory tree for symbolic links | find /etc -type l -print |
Search /etc for files modified within the last 10 minutes | find /etc -type f -mmin -10 |
Search the /etc/apache-perl directory tree for files newer than /etc/apache-perl/httpd.conf | find /etc/apache-perl -newer /etc/apache-perl/httpd.conf |
Search the /home/bozo/projects directory tree for files modified within the last 24 hours | find /home/bozo/projects -mtime 1 |
Search the /home/pankaj directory for regular files whose status has changed within the last 5 minutes | find /home/pankaj -maxdepth 1 -cmin -5 -type f |
Search the /home/sdt5z/tmp directory tree for files named "accepted_hits.bam" | find /home/sdt5z/tmp -name "accepted_hits.bam" |
Search the /home/test directory tree for directories and files called '.ssh' | find /home/test -name '.ssh' |
Search the /home/user1 directory tree for files whose names end in ".bin" | find /home/user1 -name "*.bin" |
Search the /home/weedly directory tree for regular files named myfile | find /home/weedly -name myfile -type f -print |
Search the /home/www directory tree for regular files | find /home/www -type f |
Search the /media/shared directory recursively for MP3 and OGG files | find /media/shared \( -iname "*.mp3" -o -iname "*.ogg" \) |
Search the /mnt/raid/upload directory tree for files that have been modified within the last 7 days | find /mnt/raid/upload -mtime -7 -print |
Search the /myfiles directory tree for files last modified 2 days ago | find /myfiles -mtime 2 |
Search the /myfiles directory tree for files that are 5 512 byte blocks in size | find /myfiles -size 5 |
Search the /myfiles directory tree for files whose names contain "blue" | find /myfiles -name '*blue*' |
Search the /myfiles directory tree for regular files with at least these permissions: 647 | find /myfiles -type f -perm -647 |
Search the /myfiles directory tree for regular files with read and write permissions set for `others' | find /myfiles -type f -perm -o+rw |
Search the /path directory recursively for TXT files | find /path -type f -iname "*.txt" |
Search the /path directory tree for files having permissions 777 | find /path -perm ugo+rwx |
Search the /path directory tree for files lacking the group writable bit | find /path ! -perm /020 |
Search the /path directory tree for files lacking the group writable bit | find /path ! -perm /g+w |
Search the /path directory tree for files missing g+w and o+w bits | find /path ! -perm /022 |
Search the /path directory tree for files missing g+w or o+w bits | find /path ! -perm -022 |
Search the /path directory tree for regular files | find /path -type f |
Search the /path tree for all executables | find /path -perm /ugo+x |
Search the /path/to/dir directory tree for .c files | find /path/to/dir -name \*.c |
Search the /path/to/directory tree for regular files modified 61 days ago and then remove them | find /path/to/directory -type f -mtime 61 -exec rm -f {} \; |
Search /path/to/your/directory for *.avi and *.flv files | find /path/to/your/directory -regex '.*\.\(avi\|flv\)' |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.