nl_command
stringlengths 14
387
| bash_code
stringlengths 0
532
|
---|---|
Print unique lines of sorted file "b" compared with sorted file "a" | comm -13 a b |
Log in using key file "./device_id.pem" as user "deviceuser" on host "middle.example.org" and port 2222 | ssh -i ./device_id.pem -p 2222 [email protected] |
Display machine architecture, ie. x86_64 | uname -m |
Write "ee" to standard output and as input to command "foo" | echo 'ee' | tee > |
Display each line in file.txt backwards | rev file.txt |
display all the html files in the current folder that have been modified in the last 7*24 hours | find . -mtime -7 -name "*.html" -print |
find all regex '\./[a-f0-9\-]\{36\}\.jpg' files | find . -regex '\./[a-f0-9\-]\{36\}\.jpg' |
Find files matching `.ssh*' and append their anmes to file `ssh-stuff' | find / -name .ssh* -print | tee -a ssh-stuff |
Find files under '/travelphotos' directory tree which are bigger than 200KB and do not have 2015 in their names | find /travelphotos -type f -size +200k -not -iname "*2015*" |
display list of all the regular/normal files in the home folder which are bigger than 512 kb | find /home/ -type f -size +512k -exec ls -lh {} \; |
display the contents of all the regular/normal files in the entire file system with the name dummy and discard all the errors | find / -type f -name dummy 2>/dev/null -exec cat {} \; |
Count non-blank lines in a file 'foo.c' | cat foo.c | sed '/^\s*$/d' | wc -l |
display all the files in the file system which belong to the group lighttpd | find / -group lighttpd -print |
Report file systems inode usage. | df -i |
Open a local SSH port on 1080 for application-level port forwarding | ssh -D1080 root@localhost -g |
Find files newer than start.txt but not newer than end.txt | find ./ -newer start.txt -and ! -newer end.txt |
Print lines in file 'filename' that do not match the regex 'pattern' | grep -v 'pattern' filename |
Create intermediate directories as required and directory /tmp/test/blah/oops/something | mkdir -p /tmp/test/blah/oops/something |
find all the links in the current folder which are broken | find /target -type l -xtype l |
Find all files/directories owned by user 'joebob' under '/some/directory' directory tree | find /some/directory -user joebob -print |
Save the user name of the current user to variable "whoami" | whoami=$ |
Find all python files in $topdir directory tree and search for 'Makefile' in all these folders and display all distinct folders having 'Makefile' | find "$topdir" -name '*.py' -printf '%h\0' | xargs -0 -I {} find {} -mindepth 1 -maxdepth 1 -name Makefile -printf '%h\n' | sort -u |
Find all Name* files under ../../$name-module and rename them by replacing 'Name' with $Name in their names | find ../../$name-module -name 'Name*' -type f -exec bash -c 'mv "$1" "${1/Name/$Name}"' -- {} \; |
Move the directory named "some-dir" and residing under the current one to x/ | find ./ -maxdepth 1 -name "some-dir" -type d -print0 | xargs -0r mv -t x/ |
find files in the current directory and sub-directories, that were accessed within last hour | find -amin -60 |
Find all directories named 'mydir' under 'local' and '/tmp' directory tree | find local /tmp -name mydir -type d -print |
create directory temp into home directory | mkdir ~/temp |
find all sqlite files in the current directory. | find ./ -name "*.sqlite" |
change the word "GHBAG" to "stream-agg" in all the file names in current folder which have the word "-GHBAG-" in their name | find . -name '*-GHBAG-*' -exec bash -c 'mv $0 ${0/GHBAG/stream-agg}' {} \; |
Create a symolic link in "/usr/local/" to "/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl" | ln -s /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl /usr/local/ |
Continuously output "y" at a rate of 10 bytes per second | yes | pv --quiet --rate-limit 10 |
Find all files under current directory with their size and paths, reverse sort them numerically, then print first 4 entries | find -type f -printf "%s %p\n" | sort -nr | head -n 4 |
Print "$PATH" variable as input to awk script "rem_dup.awk" and concatenate the result with ":" | echo $PATH | awk -F: -f rem_dup.awk | paste -sd: |
finds all directories named CVS, and deletes them and their contents. | find . -type d -name CVS -exec rm -r {} \; |
Find all regular files that were modified more than 60 days ago under '/path-to-directory' directory tree, sort them according to timestamp and print the filenames preceded with the timestamps | find /path-to-directory -type f -mtime +60 -printf "%T@ %p\n" | sort |
Find files larger than 50k | find . -size +50k |
Find all directories in maximum 2 levels down the /tmp/test directory | find /tmp/test/ -maxdepth 2 -mindepth 1 -type d |
Search the current directory tree for regular files that contain "string" | find . -type f -print0 | xargs -0 grep string |
Set permissions to 755 for every subdirectory of the current directory | find . -type d -mindepth 1 -print -exec chmod 755 {}/* \; |
Find all files/directories under $1 which have at least execute permission for their owner and set execute permission for group for these files/directories | find "$1" -perm -u+x -print0 | xargs chmod g+x |
find all the log files in the file system which are present in the current partition | find / -xdev -name "*.log" |
Find files that do not have a listing in the /etc/passwd or /etc/group in the file system | find / -nouser -o -nogroup |
Write the lines appended to "xxxx" as it appears to the console and append to "yyyy" in the background | tail -F xxxx | tee -a yyyy & |
Check if *RBENV* variable is defined in global environment | tmux show-environment -g | grep RBENV |
Find all files which have 211028 inode number in current directory then Locating and renaming unprintable directories | find . -inum 211028 -exec mv {} newname.dir \; |
search for the file test.txt in the folders /home and /opt | find /home /opt -name test.txt |
display all normal/regular files in the folder "$ORIG_DIR" | find "$ORIG_DIR" -name "*" -type f |
Find files under current directory without descending into other file systems and append a null character at the end of each paths | find -x . -type f -print0 |
Count the number of .java files in all folders rooted in the current folder | find . -name "*.java" | wc -l |
Check if "/path/to/dir" is a nfs mount point | mount -l | grep 'type nfs' | sed 's/.* on \ .*/\1/' | grep /path/to/dir |
Find all files/directories under /myfiles that were modified 2 days ago | find /myfiles -mtime 2 |
Add executable permission to "rr.sh" | chmod +x rr.sh |
Find all *.txt files/directories under your home directory | find ~/ -name '*.txt' |
Counts lines in each *.php file. | wc -l `tree -if --noreport | grep -e'\.php$'` |
display all files in the current folder | find . -print |
Search the current directory for HTML files whose names begin with "a" | find . -maxdepth 1 -name a\*.html |
Find all the Sticky Bit set files whose permission are 551 in the file system | find / -perm 1551 |
Print "#include" statements found in "file2" that are not in "file1" | comm -13 <(grep '#include' file1 | sort) <(grep '#include' file2 | sort) |
Find all files on the system that are larger than 600 MB | find / -size +600M -print |
find all the files in the current folder and display them in the sorted order of their name | find . | sort |
Find files that match the executable bit for owner or group | find -type f -perm /110 |
Print calendar for February, March and April of year 2009 side-by-side | paste < < < |
Creates temporary file with name formatted like '.script.XXXXXX' in '/tmp/' folder and saves path to it in 'script1' variable. | script1=`mktemp /tmp/.script.XXXXXX`; |
Compare the files in 'FOLDER1' and 'FOLDER2' and show which ones are indentical and which ones differ | find FOLDER1 -type f -print0 | xargs -0 -I % find FOLDER2 -type f -exec diff -qs --from-file="%" '{}' \+ |
Find files/directories with exactly read,write and execute permission for all (owner, group and others) under /path | find /path -perm 777 |
Find and print all PDF files in the current directory and its sub-directories except for any found in the ./pdfs directory. | find . -name "*.pdf" -print | grep -v "^\./pdfs/" |
Find files not matching shell pattern '*/vendor/*' | find . -not -wholename '*/vendor/* |
Find `string' in all *.java files ignoring the case of that string | find . -type f -name "*.java" -exec grep -il string {} \; |
recursively copy files by file extension, preserving directory structure | find -type f -name \*.txt -exec install -D {} /dest/path/{} \; |
Find all files/directories under /export/home/someone directory in a remote host and upload the files/directories to ftp://somehost/tmp/ | ssh someone@somehost "cd /export/home/someone && find . -name '*' -print| xargs -n1 curl -u someone:password ftp://somehost/tmp/ -vT" |
Search directories /path/to/directory/folder{1..50} for .txt files | find /path/to/directory/folder{1..50} -name '*.txt' 2>/dev/null |
List all variables (names only) with names containing X. | env | awk -F "=" '{print $1}' | grep ".*X.*" |
Print absolute path of "PATH" | readlink -f PATH |
Search all files in the current directory tree that are named "whatever" for "you_search_for_it" | find -name whatever -exec grep --with-filename you_search_for_it {} \; |
display a long listing of all files in the entire file system which are bigger than 1MB | find / -size +1000k -exec ls -l {} \; -print |
find js file which name is not 'glob-for-excluded-dir' under current directory. | find . -name '*.js' -\! -name 'glob-for-excluded-dir' -prune |
display all the "C" files in the current folder | find . -name "*.c" |
find all the regular/normal files in the current folder and do not search in the sub directories | find . -maxdepth 1 -type f |
Print the pathnames of all files from the /tmp/dir1 directory tree | find /tmp/dir1 -exec echo {} \; |
Find all SUID set files in the file system | find / -perm /u=s |
find the type of all the regular/normal files in the current folder (plus takes bulk of files as input to the file command) | find . -type f -exec file {} \+; |
display all the text files in the current folder | find . -name "*.txt" -print |
Sort the lines of the file 'inputfile', keep only the uniq lines and change it in-place | sort inputfile | uniq | sort -o inputfile |
Save standard input to variable "myVar" | myVar=$ |
Find grub.conf files in entire file system | find / -name grub.conf |
create a soft link of the files in the folder /media/movies which have been modified in the last 30 days | find /media/Movies -type f -mtime -30 -exec ln -s {} /media/Movies/New/ \; |
Print the list of files and directories of the /etc directory | find /etc ! -name /etc |
Inserts "new line" after last occurrence of ScriptAlias in a file | tac file | awk '/ScriptAlias/ && ! seen {print "new line"; seen=1} {print}' | tac |
Delete all matches to the regex '^.*iframe bla bla bla.*$' in all the php files under current directory tree and modify the files in-place | find ./ -type f -name \*.php -exec sed -i ’s/^.*iframe bla bla bla.*$//g’ {} \; |
display all the files in the current folder which are present in the path "./sr*sc" | find . -path './sr*sc' |
display the count of total number of non empty files in the current folder | find . -type f -not -empty | wc -l |
Remove last two underscore-delimited fields and following characters in "t1_t2_t3_tn1_tn2.sh" keeping only "t1_t2_t3" | echo t1_t2_t3_tn1_tn2.sh | rev | cut -d_ -f3- | rev |
Recursively changes group ownership on everything in the 'public_html' folder to 'website' group. | chgrp --recursive website public_html |
Display difference between one.txt and two.txt side-by-side. | diff -y one.txt two.txt |
search for all xml files in some directory | I'm assuming you only want to zip files that match names in $Namese. In your script, try replacing the find command with: export Namese find /var/tmp/ -type f -name '*.xml' |
Finds strings having text "searched-string" in all files recursively in a current folder. | find . | xargs grep "searched-string" |
Search the system for the file “testfile.txt” | find / -name "testfile.txt" |
Search for 'foo' in all regular files under 'sources' directory tree and show the matched lines with filenames | find sources -type f -exec grep -H foo {} + |
Save the physical current working directory to variable "END_ABS" | END_ABS=`pwd -P` |
Find all files in and below all subdirectories of the current directory | find . -mindepth 2 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.