nl_command
stringlengths 14
387
| bash_code
stringlengths 0
532
|
---|---|
display a long listing of the files in current folder which have been modified in the last 60 minutes | find . -mmin -60 -type f -exec ls -l {} + |
Find *.java files under current directory and compress them to myfile.tar | find . -type f -name "*.java" | xargs> tar rvf myfile.tar |
Subtract each column in File2 from matching column in File1, output the result in a similarly formatted table | awk 'FNR==NR { for(i=2;i<=NF;i++) a[$1][i]=$i; next } { for(j=2;j<=NF;j++) $j-=a[$1][j] }1' File2 File1 | rev | column -t | rev |
Counts all files in a current folder and subfolders. | find `pwd` -type f -exec ls -l {} \; | wc -l |
find all the files in the file system which have been modified in the last 10 minutes | find / -mmin -10 |
Find all regular files named postgis-2.0.0 under current directory | find . -type f -name "postgis-2.0.0" |
Raise an error for using uninitialized variables | set -u |
Print numbers from 1 to 30 with 0 padding to a width of 2 | seq -f "%02g" 30 |
Lists long format information about file '/bin/echo'. | ls -l /bin/echo |
List files in the current directory and below that are exactly 1234 bytes in size | find . -size 1234c |
Print 'file' file, splitting lines into pieces with no more that 3 words in each one. | cat file | xargs -n3 |
Write "deb blah ... blah" to standard output and append to "/etc/apt/sources.list" as root | echo 'deb blah ... blah' | sudo tee --append /etc/apt/sources.list |
Search the /etc directory tree for symbolic links | find /etc -type l -print |
Find regular files under '/somefolder' directory tree satisfying the options/conditions/operations provided in ${ARGS[@]} array with find command | find /somefolder -type f '(' "${ARGS[@]}" ')' |
Number every line of standard input as zero padded to 6 characters followed by "-" | nl -s- -ba -nrz |
Recursively copy all regular files below current directory to directory /tmp on hostname, connecting as ssh user matching current username on local host. | find . -type f -exec scp {} hostname:/tmp/{} \; |
display the contents of all the files in the current folder which start with test | find . -iname '*test*' -exec cat {} \; |
Find all files/directories under current directory and print their paths | find . -exec echo {} ";" |
Remove all files from the current directory tree whose names do not match regular expression "excluded files criteria" | find . | grep -v "excluded files criteria" | xargs rm |
Display standard input as printable characters or backslash escapes with no addressing radix | od -cAn; |
display the count of total number of non empty files in the current folder | find . -type f -not -empty | wc -l |
Find a single file called FindCommandExamples.txt under current directory and remove it | find . -type f -name "FindCommandExamples.txt" -exec rm -f {} \; |
find all the text files in the current folder starting with "somefiles-" and prepend the first line | find . -name "somefiles-*-.txt" -type f -exec sed -i 'iText that gets prepended (dont remove the i)' -- '{}' \; |
Search through the /usr/local directory for files that end with the extension .html, and print the file locations. | find /usr/local -name "*.html" -type f |
Find regular files in the current directory that are writable by their owner | find -maxdepth 1 -type f -perm /200 |
Change the ownership of "file.sh" to "root" | sudo chown root file.sh |
Create symbolic links in the current directory for all files excluding "CONFIGFILE" located in "/your/project" | find /your/project -maxdepth 1 ! -name "CONFIGFILE" -exec ln -s \{\} ./ \; |
Search the *.cc files in the current directory tree for string "xxx" | find . -name "*.cc" | xargs grep "xxx" |
Print only second from the end field from slash-separated string in file 'datafile' | cat datafile | rev | cut -d '/' -f 2 | rev |
List all regular file owned by root with permissions 4000 | find / -type f -user root -perm -4000 -exec ls -l {} \; |
List all files/directories under current directory using comma (,) as the delimiter for different fields in the output | find . -ls | awk '{printf( "%s,%s,%s,%s,%s,%s,%s,%s %s %s,%s\n", $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11 )}' |
set alias "vv" for command "$" | alias -g vv="$" |
Search through the /usr/local directory for files that end with the extension .html, and print the file locations. | find /usr/local -name "*.html" -type f |
Go into the first directory whose name contains 1670 | cd `find . -maxdepth 1 -type d | grep 1670` |
Find files/directories under current directory and print them as null terminated strings. | find -print0 |
Dump "/dev/ttySomething" in both hex and text | od -t x1 -t a /dev/ttySomething |
Counts sum of non-empty lines from all .php files in a current folder. | find . -name "*.php" | xargs grep -v -c '^$' | awk 'BEGIN {FS=":"} { cnt = cnt + $2} END {print cnt}' |
search for the files in the current folder which begin with the word "kt" followed by a digit | find . -name 'kt[0-9] ' |
Find the passwd file in the current directory and one level down | find -maxdepth 2 -name passwd |
Execute all commands in "commands-to-execute-remotely.sh" on server "blah_server" | cat commands-to-execute-remotely.sh | ssh blah_server |
Move all files matching patterns "*.old", ".old", ".*.old" from the current directory to directory "../old/" | find . ! -name . -prune -name '*.old' -exec sh -c 'mv "$@" ../old/' sh {} + |
Rename '.mkv' extension to '.avi' for all files/directories under '/volume1/uploads' directory tree | find /volume1/uploads -name "*.mkv" -exec rename 's/\.mkv$/.avi/' \{\} \; |
Prints total number of lines of all *.php files in a current folder and subfolders. | cat `find . -name "*.php"` | wc -l |
Search for 'example' in all regular files from the current directory tree | find -type f -print0 | xargs -r0 grep -F 'example' |
Delete all files throughout the entire filesystem that are no longer owned by a valid user. | find / -nouser | xargs -0 rm |
find all text files in the folder "FFF" and find the md5sum for them | find FFF -name "*.txt" -exec md5sum '{}' \; |
Gets IP address of 'en0' network interface. | ifconfig en0 | awk '$1 == "inet" {print $2}' |
Print the top 10 commands with their use count | history | awk '{ print $2 }' | sort | uniq -c |sort -rn | head |
Find all file1 and file9 files/directories under current directory | find . -name file1 -or -name file9 |
Replace all occurrences of "StringA" with "StringB" in the *.php and *.html files residing in the current directory tree | find . \( -name "*.php" -or -name "*.html" \) | xargs grep -l StringA | xargs sed -i -e 's/StringA/StringB/g' |
Source executable "virtualenvwrapper.sh" found in $PATH | source `which virtualenvwrapper.sh` |
Find all subdirectories of the current directory except hidden ones | find -maxdepth 1 -type d ! -name ".*" |
find md5sum of content from "www.google.com" | curl -s www.google.com | md5 |
find directories in the folder /usr/spool/uucp | find /usr/spool/uucp -type d -print |
Filters out strings, using the extended regexp pattern '^#|^$|no crontab for|cannot use this program' from "$USERTAB" | echo "$USERTAB"| grep -vE '^#|^$|no crontab for|cannot use this program' |
change the permissions of all regular/normal files in the current directory | find . -type f -exec chmod 664 {} \; |
Find all HTML files starting with letter 'a' in the current directory and below | find . -name a\*.html |
Save the user name of the current user to variable "me" | me=$ |
Print each unique entry in "ip_addresses" followed by a count | cat ip_addresses | sort | uniq -c | sort -nr | awk '{print $2 " " $1}' |
Print type of the file system containing path $dir. | df -T $dir | tail -1 | awk '{print $2;}' |
Split the sorted and unique lines in files "emails_*.txt" into files with at most 200 lines each with numeric suffixes of length 4 | sort --unique emails_*.txt | split --numeric-suffixes --lines=200 --suffix-length=4 --verbose |
Counts lines with all-cased word 'null' in file 'myfile.txt'. | grep -n -i null myfile.txt | wc -l |
Change permissions to 755 for all subdirectories of the current directory | find . -type d -print | sed -e 's/^/"/' -e 's/$/"/' | xargs chmod 755 |
Search the current directory recursively for files last modified within the past 24 hours ignoring .swp files and "en" and "es" directories | find . \ -prune , -mtime 0 ! -name "*.swp" |
Read yesterday's date with format "%a %d/%m/%Y" into variable "dt" in a subshell | date --date yesterday "+%a %d/%m/%Y" | read dt |
find all directory list which have empty list in /tmp directory | find /tmp -type d -empty |
show a count of the number of filenames ending in .txt in the current directory, without descending into sub-directories | find . -maxdepth 1 -name \*.txt -print0 | grep -cz . |
List all files in the current directory tree that were last modified in March 2007 | find ! -newermt "apr 01 2007" -newermt "mar 01 2007" -ls |
Find all executables under /path directory | find /path -perm /ugo+x |
display list of all the hidden files in the directory "/dir/to/search/" | find /dir/to/search/ -name ".*" -ls |
Find text files modified less than 5 days ago | find . –name "*.txt" –mtime 5 |
search all the files in the current folder excluding those that are present in the folder test and using regex | find . -name test -prune -regex ".*/my.*p.$" |
Display a list of files with sizes in decreasing order of size of all the regular files under $dir directory tree that are bigger than $size in size | find $dir -type -f size +$size -print0 | xargs -0 ls -1hsS |
find case-insentive example.com file, and whole dose not contain beta | find -iname example.com | grep -v beta |
Lookup information for user "vivek" | finger vivek |
Change the owner and group of "uid_demo" to "root" | sudo chown root:root uid_demo |
Find files/directories modified within the last hour under current directory | find . -mtime -1 |
find all the files in the home folder which have been modified in 1 year or more ( which are not modified in the last 1 year ). | find $HOME -mtime +365 |
Replace newline with "_" in "file" then search for "_foo_" and output with "_" characters deleted | grep -o "_foo_" <(paste -sd_ file) | tr -d '_' |
Append all regular files modified in the last 24 hours to the "$archive.tar" tar archive | find . -mtime -1 -type f -exec tar rvf "$archive.tar" '{}' \; |
Find all files/directories under current directory that were modified exactly 30 minutes ago | find . -mmin 30 |
Change the file extension from '.txt' to '.bak' for all files/directories under current directory tree | find . -name "*.txt" | sed "s/\.txt$//" | xargs -i echo mv {}.txt {}.bak | sh |
Find all files under $1 directory excluding hidden files and append a null character at the end of each of their paths | find "$1" -path "*/.*" -prune -o \ |
find all the files that have not been modified in the last hours. | find . -mtime +7 |
Find all regular files in the current directory tree that do not contain a whitespace | find . -type f \ |
find files that were accessed within the last 24 hours | find / -atime -1 |
Rotates the dirs stack so that the second directory (counting from the right of the list shown by `dirs', starting with zero) is at the top. | pushd -2 |
display all the ".c" files in the folder "/home/david" which have been accessed in the last 48 hours | find /home/david -atime -2 -name '*.c' |
Find all directories that have been modified in the last seven days. | find . -mtime -7 -type d |
Search for first match of the case insensitive regex 'oyss' in all *.txt files under current directory and print the file paths along with the matches | find . -name '*.txt'|xargs grep -m1 -ri 'oyss' |
display all the files in the current folder and do not search in sub directories and move them to the directory /directory1/directory2. | find . -maxdepth 1 -type f | xargs -I ‘{}’ sudo mv {} /directory1/directory2 |
Copies 'libgtest_main.so' and 'libgtest.so' to '/usr/lib/', preserving all attributes, and copying symlinks as symlinks, without following in source files. | sudo cp -a libgtest_main.so libgtest.so /usr/lib/ |
Find all files under var/ directory and change their permission to 600 | find var/ -type f -exec chmod 600 {} \; |
list files that the user does not have permissions to read, do not try to descend into directories that cannot be read. | find . ! -perm -g+r,u+r,o+r -prune |
Find all files named 'foo' under current directory tree without descending into directories named 'foo' | find . -name foo -type d -prune -o -name foo -print |
Write "ee" to standard output on "/dev/pty/2" and as input to command "foo" | echo ee | tee /dev/pty/2 | foo |
Replace all ' ' with '-' from standard input | tr ' ' '-' |
Find all the files recursively in directories or files taken from the glob pattern /tmp/test/* that have been modified today | find /tmp/test/* -mtime -0 |
display all soft links in current folder | find . -type l |
Find the process id of mysql | ps aux | grep mysql | grep -v grep |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.