nl_command
stringlengths 14
387
| bash_code
stringlengths 0
532
|
---|---|
Find all .java files starting from the current folder | find . -name "*.java" |
all the files that end with .mp3 and end with .jpg | find . -name '*.mp3' -name '*.jpg' -print |
search in all the regular/normal files of the current folder for the word "word" and display the matched file name | find . -type f -exec grep -l "word" {} + |
find all the directories in the file system which begin with "man" | find / -type d -name 'man*' -print |
Print received input to the terminal | tee |
Count the number of files named `file1' | find -name file1 | wc -l |
Archive the entire file system into tarfile.tar.bz2 | find / -print0 | tar -T- --null --no-recursive -cjf tarfile.tar.bz2 |
replaces the last occurrence of 'a' with 'c' | tac | sed '0,/a/ s/a/c/' | tac |
Measure the disk space taken up by all *.txt files in directory tree /home/d | find /home/d -type f -name "*.txt" -printf "%s\n" | awk '{s+=$0}END{print "total: "s" bytes"}' |
find all regular/normal files which have cpp folder in their path | find . -type f -path "*/cpp/*" |
find all the files in the home folder which have been modified in the last 7 days | find $HOME -mtime -7 |
Remove the first 7 characters of every line in the output of "history" | history | cut -c 8- |
Delete all the .c files present in the current directory and below | find . -name "*.c" | xargs rm -f |
Creates temporary directory with name formatted like .daemonXXXXXXX in /tmp/ folder, and saves path to it in 'TMPDIR' variable. | TMPDIR=$(mktemp -p /tmp -d .daemonXXXXXXX) |
Gets all IP addresses from host network configuration and prints first one. | ifconfig | grep "inet addr:" | grep -v "127.0.0.1" | grep -Eo '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | head -1 |
Find all *.cgi files/directories under current directory and change their permission to 755 | find . -name '*.cgi' -print0 | xargs -0 chmod 755 |
Create MD5 message digest of "/path/to/source/file" starting at byte 100 until the 250th byte | dd if=/path/to/source/file bs=1 skip=100 count=250 | md5sum |
find all the findme.txt files in the file system | find / -name findme.txt -type f -print |
Run 'git pull' in every git repository in the current directory | find . -name ".git" -type d | sed 's/\/.git//' | xargs -P10 -I{} git -C {} pull |
display all the files in the current folder | find ./ |
Create symlinks to all /home/folder2/*.txt files with the same name in current directory | find /home/folder2/*.txt -type f -exec ln -s {} \; |
recursively change owner and group of the directory /your/directory/to/fuel/ and all files into it to user and group nginx | chown nginx:nginx /your/directory/to/fuel/ -R |
search for all tar.gz compress files in the current folder | find -name *.tar.gz |
Create a table containing all information from S43.txt and S44.txt, merging lines where the first field of both files matches, and keeping the line that starts with "Gene" at the start of the file. | join -a1 -a2 < < | column -t | sed s/^00ne/Gene/ |
Counts non-blank lines (lines with spaces are considered blank) in all *.py files in a current folder. | grep -v '^\s*$' *.py | wc |
Set variable GZIP to the full path of command "gzip" | GZIP="$" |
Print the names of the directories from the paths expanded by the glob pattern /path/to/directory/* | find /path/to/directory/* -maxdepth 0 -type d -printf '%f\n' |
Find ".c" and ".h" files in the current directory tree and print lines containing "#include" | tree -if | grep \\.[ch]\\b | xargs -n 1 grep -H "#include" |
Print line number of each line in /etc/passwd file, where current user name is found | cat /etc/passwd -n | grep `whoami` | cut -f1 |
Remove the regular files from the current directory tree that are newer than /tmp/date.start but not newer than /tmp/date.end | find ./ -type f -newer /tmp/date.start ! -newer /tmp/date.end -exec rm {} \; |
Clears the terminal screen. | clear |
Replace all occurrences of edx with gurukul in all *.css files under ./cms/djangoapps/contentstore/management/commands/tests directory | find ./cms/djangoapps/contentstore/management/commands/tests -iname *.css | xargs sed -i s/[Ee][Dd][Xx]/gurukul/g |
Run an awk program on every TXT file found in the current directory tree | find . -name '*txt' -print -exec awk 'BEGIN {nl=1 ;print FILENAME} $9 !="" {if { print $0 ; nl = nl + 1 }}' {} \; |
search the word NEEDLE and substitute it with REPLACEMENT in all the php files of the current folder | find ./ -type f -exec sed -i '' 's#NEEDLE#REPLACEMENT#' *.php {} \; |
Find all directories under /path/to/dir and archive them into files with .tar.gz extension | find /path/to/dir -mindepth 1 -maxdepth 1 -type d -execdir sh -c 'd=${1##*/}; sudo tar -zcpvf "$d".tar.gz "$d"' - {} \; |
display all the files in the folder /home which do not belong to the group test | find /home ! -group test |
split file data.csv into pieces per 100 lines named with additional suffix ".csv" | split --numeric-suffixes=1 --additional-suffix=.csv -l100 data.csv data_ |
Count line numbers on files and record each count along with individual file name. | find /home/my_dir -name '*.txt' | xargs grep -c ^.* |
Search for the regex "\$wp_version =" in all the regular files that end with '/wp-includes/version.php' (case insensitive) in their paths in directories/files taken from the glob pattern '/var/www/vhosts/*/httpdocs' and show the matched lines along with the file names | find /var/www/vhosts/*/httpdocs -type f -iwholename "*/wp-includes/version.php" -exec grep -H "\$wp_version =" {} \; |
Replace all occurrence of "subdomainA.example.com" with "subdomainB.example.com" in all files under /home/www and below | find /home/www/ -type f|xargs perl -pi -e 's/subdomainA\.example\.com/subdomainB.example.com/g' |
Find all files that contain the case insensitive regex 'stringtofind' in maximum 1 level down the / directory without descending into other partitions | find / -maxdepth 1 -xdev -type f -exec grep -li stringtofind '{}' \; |
Find files/directories not changed in two weeks under /dev/shm | find /dev/shm /tmp -type f -ctime +14 |
Find all *.so files under $S directory and run doexe command with minimal invocation for those files | find "${S}" -name '*.so*' -exec doexe '{}' + |
Prints string "0 1 * * * /root/test.sh" to the terminal, and append it to file '/var/spool/cron/root' | echo "0 1 * * * /root/test.sh" | tee -a /var/spool/cron/root |
Find all regular files under current directory and replace every occurrences of 'subdomainA.example.com' with 'subdomainB.example.com' in those files | find . \ -type f -print0 | xargs -0 sed -i 's/subdomainA.example.com/subdomainB.example.com/g' |
find all the png files in the current folder which begin with the word image and do not search in the sub directories | find . -maxdepth 1 -type f -name 'image*png' ` |
Print unique lines of sorted file "A.txt" compared to sorted file "B.txt" | comm -2 -3 <(sort A.txt) <(sort B.txt) |
Prints server name from SOA record for domain yahoo.com | dig +noall +answer soa yahoo.com | awk '{sub;print $5}' |
display long listing of all the files in the root folder which are bigger than 3KB | find / -dev -size +3000 -exec ls -l {} ; |
If variable "c" is a syntactically correct cron job, erase user's cron jobs and add "c" as the only cron job for user. | echo $c | crontab |
find all the configuration files which have been accessed in the last 30 minutes. | find /etc/sysconfig -amin -30 |
Print out the contents of all files in the current directory tree that contain "spaces" in their names | find -name '*spaces*' | while read text; do cat "$text"; done |
List content of 'myfile' in a subshell and returns output to parent shell | $(cat myfile) |
Search for line number 111 in file "active_record.rb" | nl -ba -nln active_record.rb | grep '^111 ' |
create a symbolic link in current directory named "my_db" to file "/media/public/xampp/mysql/data/my_db" | ln /media/public/xampp/mysql/data/my_db -s |
Print "test=hello world" | echo "hello world" | echo test=$(cat) |
find all the files in the entire file system that have been changed exactly 60 days and display ten files | find / -cmin -60 | head |
print all files in the file system excluding those ending with ".c" | find / \! -name "*.c" -print |
find all the files in the home folder that have been modified between 24 to 48 hours | find $HOME -mtime -2 -mtime +1 |
search for *.log files starting from / and only in the current file system | find / -xdev -name "*.log" |
Count the number of lines in all ".php" files in the current directory tree | wc -l `tree -if --noreport | grep -e'\.php$'` |
Make 3 directories named "~/Labs/lab4a/folder" followed by the number 1, 2, or 3 | mkdir ~/Labs/lab4a/folder{1,2,3} |
search for a word in all the php files in the current folder and display the count of all matching lines. | find . -name \*.php -type f -print0 | xargs -0 -n1 grep -Hn '$test' | wc -l |
Recursively copy "original_dir" to "copy_dir" preserving file/dir timestamps, displaying progress, and skipping files which match in size, keeps partially transferred files. | rsync -Prt --size-only original_dir copy_dir |
create a backup of all the files in the current folder excluding those that are present in the .snapshot sub directory and excluding the swap files (files ending with ~) | find . -name .snapshot -prune -o \( \! -name *~ -print0 \) | cpio -pmd0 /dest-dir |
Search for " 000" in the hex dump of "file-with-nulls" | od file-with-nulls | grep ' 000' |
List all files except for those in directory SCCS | find . -print -o -name SCCS -prune |
Format bash array "${arr}" in columns | echo " ${arr[@]/%/$'\n'}" | column |
display all the html files in the current folder that have not been modified in the last 7*24 horus | find . -mtime +7 -name "*.html" -print |
display all the files in the current folder which are present in the path "./src/emacs" | find . -path './src/emacs' -prune -o -print |
Use the first non-zero exit code (if any) of a set of piped commands as the exit code of the full set of commands | set -o pipefail |
Find all files/directories with '.txt' extension under '/home' directory tree that are greater than 100KB in size | find /home -name "*.txt" -size +100k |
Changes group ownership of 'shared' to 'Workers'. | chgrp Workers shared |
Search for 'sometext' in all the files with '.txt' extension under current directory tree and also print the filenames | find . -name '*.txt' -exec grep 'sometext' '{}' \; -print |
Finds recursively all folders named 'a' within current folder and removes only ones without files and another folders within. | find . -name "a" -type d | xargs rmdir |
Remove all vmware-*.log files/directories under current directory | find . -name vmware-*.log | xargs -i rm -rf {} |
Find all files under current directory with their size and paths, reverse sort them numerically, then print the 2nd field of the first 4 entries | find -type f -printf "%s %p\n" | sort -nr | head -n 4 | cut -d ' ' -f 2 |
Print the path composed of the current working directory and the directory containing "$0" | echo `pwd`/`dirname $0` |
find all the files with the name "datainame" in the file system which are bigger than 50MB | find / -size +50M -iname "Dateiname" |
Lists all paths to all subfolders in a current folder. | ls -mR * | sed -n 's/://p' |
Replace spaces in directory names with underscores for all directories in the current directory tree | find -name "* *" -type d | rename 's/ /_/g' |
Extract any line in "set1" which does not appear in "set2" | comm -23 < < |
Read a line from standard input with prompt "Enter your age:\n" | read -p $'Enter your age:\n' |
Move all regular files under current directory to ./newdir | find ./ -type f -print | xargs -l56 -I {} mv -f {} ./newdir |
Find all files beneath the current directory that end with the extension .java and contain the characters StringBuffer. Print the name of the file where a match is found. | find . -type f -name "*.java" -exec grep -l StringBuffer {} \; |
Search the current directory tree for files whose names match regular expression '.*packet.*', ignoring the case | find . -iregex ".*packet.*" |
Search directory tree `MyApp.app' for directories whose name is 'Headers' and delete them in an optimized way | find -d MyApp.app -name Headers -type d -exec rm -rf {} + |
Unsets shell variable 'latest'. | unset -v latest |
display all the files in the home folder which have not been modified in the last 365*24 hours | find $HOME -mtime +365 |
Recursively bind "/dev" to "/var/snmp3/dev" | mount --rbind /dev /var/snmp3/dev |
Find all level 1 subdirectories of the current directory | find . -maxdepth 1 -type d |
Save a comma separated list of all directories under current directory tree to variable 'FOLDER' | FOLDERS=$(find . -type d -print0 | tr '\0' ',') |
Prints full process tree with id number of each process. | pstree -p |
Find all CSS files | find . -name "*.css" |
Counts number of processors and saves in variable NUMCPU. | NUMCPU=$(grep $'^processor\t*:' /proc/cpuinfo |wc -l) |
create a symbolic link named "bar" to file that named is a result of the command `canonical.bash foo` | ln -s `canonical.bash foo` bar |
split processed content of the file temp into pieces per 1 line named "tempNNN" with numeric suffix | sed 's/3d3d/\n&/2g' temp | split -dl1 - temp |
Find all directories in maximum 1 level down the current directory and remove the . entry from the output | find . -maxdepth 1 -type d | sed '/^\.$/d' |
Remove all Thumbs.db files from the current directory tree | find . -name Thumbs.db -exec rm {} \; |
Format bash array "${arr}" in columns | echo " ${arr[@]/%/$'\n'}" | sed 's/^ //' | column |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.