nl_command
stringlengths 14
387
| bash_code
stringlengths 0
532
|
---|---|
Change all directories under "./bootstrap/cache/" to owner "apache" and group "laravel" | sudo find ./bootstrap/cache/ -type d -exec chown apache:laravel {} \; |
Find 10 largest files in the current directory and its subdirectories | du -hsx * | sort -rh | head -10 |
Remove all CVS directories from the current directory tree | find . -name 'CVS' -type d -exec rm -rf {} \; |
Insert the current host name on line 15 of "test.html" | sed -i "15i `hostname`" test.html |
Search level 3 of the current directory tree for the directories whose pathnames contain "New Parts" | find -mindepth 3 -maxdepth 3 -type d | grep "New Parts" |
Search the current directory tree for *.c and *.asm files, ignoring the case | find . -type f \ |
Show the number of lines for each .php and .phtml file in the current directory tree | find . -type f \( -name "*.php" -o -name "*.phtml" \) -exec wc -l {} +; |
display all the regular/normal files in the current directory | find . -type f |
Search /var/log for logs larger than 10 megabytes | find /var/log -size +10M -ls |
Remove "\n" from "test1\ntest2\ntest3" and search for "test1.*test3" | echo -e "test1\ntest2\ntest3" |tr -d '\n' |grep "test1.*test3" |
Read a single character from standard input into variable "ans" | read -n1 ans |
Copy the entire contents of the current directory preserving ownership, permissions, and times | find . | cpio -pdumv /path/to/destination/dir |
Prints file.txt without the last N bytes | head -c -N file.txt |
Find all files in the current directory tree whose names are "YourProgram", change to the directories they are in, and execute them | find $ -name YourProgram -exec dirname {} \; | while read d; do cd "$d" && ./YourPrgram; done |
search all block spacial files called backup from /usr directory downwards and print them . | find /usr -type b -name backup -print |
Search the /usr/ directory tree for files newer than file /tmp/stamp | find /usr -newer /tmp/stamp |
find all files ending with "js.compiled" in current folder | find . -type f -name "*.js.compiled" |
Search core files in current direcory and delete . | find . -name core -exec rm {} \; |
Print the full path of command "cc" | which cc |
Show the subdirectories of the current directory | find . -maxdepth 1 -type d -print | xargs echo Directories: |
Change permissions to 0755 for all directories in the /path directory tree | find /path -type d -exec chmod 0755 "{}" \; |
Mount remote "smbfs" filesystem "//username@server/share" on "/users/username/smb/share" as soft | mount -t smbfs -o soft //username@server/share /users/username/smb/share |
List all *.txt files under current directory that contains the regex 'pattern' | find . -type f -name '*.txt' -exec egrep -l pattern {} \; |
display all the files in the current folder which are present in the path "./sr*sc" | find . -path './sr*sc' |
Rename absolute path of symbolic link "dirln" to "dir2" | mv "$(readlink -f dirln)" dir2 |
Log in as "middleuser" with key "./middle_id.pem" and forward port 22 on host "middle.example.org" to port 2222 on localhost | ssh -i ./middle_id.pem -R 22:localhost:2222 [email protected] |
Print the file content of command "f" | cat "$(which f)" |
Find all *.m4a files under /home/family/Music directory | find /home/family/Music -type f -name '*.m4a' -print0 |
Print the first 10 files or directories found in the /tmp directory tree by `find' | find /tmp | head |
Set 644 permission to all regular files under current directory | find . -type f -print0 | xargs -0 chmod 644 |
display all the regular/normal files in the current folder excluding the files with the name mmm | find . -name mmm -prune -o -type f -print |
Remove files in the current directory tree whose names match pattern "file?" | find . -name "file?" -exec rm -vf {} \; |
Collapse double slashes in variable "dir" into a single one. | dir="`echo $dir | sed s,//,/,g`" |
Find all python files under current directory tree, save the list to 'output.txt' and search for 'something' in those files | find . -name '*.py' | tee output.txt | xargs grep 'something' |
Find all empty directories in minimum 2 levels down the root directory | find root -mindepth 2 -type d -empty |
sleep for 1 second | sleep 1 |
Find all directories under minimum 1 level down the current directory excluding directories that start with a . in their names | find . -mindepth 1 -name '.*' -prune -o \ |
Search the current directory tree for files matching sed regular expression '.*myfile[0-9]\{1,2\}' | find . -regextype sed -regex '.*myfile[0-9]\{1,2\}' |
Swap "new" and "old" files or directories | mv new old -b && mv old~ new |
change the permissions of all regular/normal files in the current directory | find . -type f -exec chmod 664 {} \; |
Print the grand total disk usage of all files listed in "files.txt" | cat files.txt | xargs du -c | tail -1 |
Format tab separated fields in "FILE" as a table | column -t -s $'\t' FILE |
Find files under /tmp that are larger than 10KB and smaller than 20KB | find /tmp -size +10k -size -20k |
display the name and size of all the regular/normal files in the current folder which are bigger than 50MB | find . -type f -size +50000k -exec ls -lh {} \; | awk '{ print $9 ": " $5 }' |
Compose filepath as folder path where file $SRC is located, and lowercase filename of $SRC file, and save it in 'DST' variable | DST=`dirname "${SRC}"`/`basename "${SRC}" | tr '[A-Z]' '[a-z]'` |
Request A record from nameserver $ns for domain name $d, filter strings with domain name and exclude lines matching 'DIG' | dig @$ns $d A | grep $d | grep -v "DiG" |
Prints groups list that user 'el' belongs to. | groups el //see that el is part of www-data |
Search the current directory tree for files containing "sh" in their names | find . -name "*sh*" |
rename all the spaces in mp3 files to underscore | find . -type f -iname “*.mp3″ -exec rename “s/ /_/g” {} \; |
List all files in /home/bozo/projects directory tree that were modified exactly one day ago | find /home/bozo/projects -mtime 1 |
Eliminates partially duplicate lines by column, keeping the last occurrence | tac temp.txt | sort -k2,2 -r -u |
Delete all empty directories and directories that contain only empty directories under current directory | find -type d -empty -exec rmdir -vp --ignore-fail-on-non-empty {} `;` |
Gets IP address of first network interface which name matches pattern "venet0:0\|eth0". | ifconfig | grep -A2 "venet0:0\|eth0" | grep 'inet addr:' | sed -r 's/.*inet addr:.*/\1/' | head -1 |
Remove files from the file system that are owned by nobody | find / -nouser -exec rm {} + |
Find all empty files in the current directory and delete them | find . -maxdepth 1 -type f -empty -delete |
Archive "/my/dir" on host "server" as user "user" to the current local directory excluding files ending in ".svn" | rsync -av --exclude '*.svn' user@server:/my/dir . |
display all the .sh scripts in the folder /usr | find /usr -name '*.sh' |
Print a hex dump of "$DIREC" as characters | echo "$DIREC" | od -c |
Search the /dir directory tree for files whose names match regular expression '.*2015.*\' | find /dir -regex '.*2015.*\' |
display all files in current folder excluding current folder | find . \! -name '.' |
Copy all files named 'script.sh' in directory 'olddir' to directory 'newdir' | find olddir -name script.sh -printf "%p\0" -printf "newdir/%P\0" | xargs -0L2 cp -n |
Find all *.mp4 files under /foo/bar and move them to /some/path | find /foo/bar -name '*.mp4' -print0 | xargs -I{} -0 mv -t /some/path {} |
Search the current directory and all of its sub-directory for any PDF files being careful to prevent the shell from expanding anything in '*.pdf' before it'ss passed to find. | find . -name '*.pdf' -print |
Search for files which have read and write permission for their owner, and group, but which other users can read but not write to. | find . -perm 664 |
Update the timestamp of 'filename', or create an empty file if it doesn't exist. | touch filename |
Find all files in the `work' directory tree, pass them to grep and search for "profit" | find ./work -print | xargs grep "profit" |
Find all directories under minimum 1 level down the current directory and set their permission to 755 | find . -type d -mindepth 1 -print -exec chmod 755 {}/* \; |
display all files in the current folder | find . |
List .log files from the current directory tree | find . -name "*.log" -exec echo {} \; |
Strips two last sections from the path $pathname, and prints basename of the rest part. | echo $(basename $(dirname $(dirname $pathname))) |
Print whether "$file" and "${file/${dir1}/${dir2}}" differ | diff -q "$file" "${file/${dir1}/${dir2}}" |
Delete files in /var/tmp/stuff and below that have not been modified in over 90 days | find /var/tmp/stuff -mtime +90 -print | xargs /bin/rm |
find all the *.conf files under / redirecting error messages to /dev/null | find / -name "*.conf" 2>>/dev/null |
View the bash manpage, starting with the view positioned at the first occurrence of the expression "BASH_SOURCE". | man bash | less -p BASH_SOURCE |
renames all ".htm" files to ".html" files | find . -name "*.htm" -exec mv '{}' '{}l' \; |
Find all .jpg files in the current directory and below | find -name '*.jpg |
Counts the number of lines in each file in a git repository. | git ls-files | xargs wc -l |
Delete all empty directories in minimum 1 level down the directory 'directory' | find directory -mindepth 1 -type d -empty -delete |
Write output of "whatever" to standard output and to "logfile.txt" | whatever | tee logfile.txt |
find all the fles that have .ssh in the end and redirect the output to ssh-stuff | find / -name .ssh* -print | tee -a ssh-stuff |
Remove all files under $DIR that were accessed more than 5 days ago | find "$DIR" -type f -atime +5 -exec rm {} \; |
Find all your jsp's, map them to your localhost webserver, and invoke a wget (fetch) on them | find -name \*.jsp | sed 's/^/http:\/\/127.0.0.1/server/g' | xargs -n 1 wget |
Search the current directory tree recursively for the regular file named "myfile" ignoring "work" and "home" directories | find . \ -prune -o -name myfile -type f -print |
Prepend date to ping output to google.com | ping google.com | xargs -L 1 -I '{}' date '+%+: {}' |
force delete all the directories the folder "test folder" | find 'Test Folder' -type d -print0 | xargs -0 rm -rf |
Search the ~/Books directory recursively for files named "Waldo" | find ~/Books -name Waldo |
change the permissions of the directories from 777 to 755 in the folder "/var/www/html" | find /var/www/html -type d -perm 777 -print -exec chmod 755 {} \; |
Download "Louis Theroux's LA Stories" using rsync over ssh | rsync -ave ssh '"Louis Theroux"''"'"'"'"''"s LA Stories"' |
Find files/directories modified within the last hour under current directory | find . -mtime -1 |
Enables shell option 'promptvars'. | shopt -s promptvars |
Print the ping time of a single request to "8.8.8.8" | ping -c 1 8.8.8.8 | awk 'FNR == 2 { print $(NF-1) }' |
Print the first 32 hexadecimal characters from "/dev/urandom", determining C locale for character handling functions | cat /dev/urandom | env LC_CTYPE=C tr -cd 'a-f0-9' | head -c 32 |
find all files in current folder which are more than 300MB | find . -size +300M |
List all environment variables whose name contains 'ipo', showing only the names of the variables and not their values. | env | grep ipo | awk 'BEGIN {FS="="} ; { print $1 } ' |
find all js files under the build direcotry except build/external and build/log directory. | find build -not \ -not \ -name \*.js |
Find all files under current directory and make them read-only for owner, read & writable by group and remove read-write-execute permission | find . -type f -exec chmod u+r-wx,g+rw-x,o-rwx {} \; |
Save the FQDN host name of the system in variable "hnd" | hnd=$ |
download contents of a website "http://example.com/" | curl http://example.com/ |
Count the number of times each person is logged in on the system | who | awk '{print $1}' | sort | uniq -c | sort -n |
Report only total size of file systems in 1T blocks. | df --total -BT | tail -n 1 | sed -E 's/total *.*/\1/' |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.