nl_command
stringlengths 14
387
| bash_code
stringlengths 0
532
|
---|---|
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 |
find all empty files in /tmp directory . | find /tmp -type f -empty |
display all file in the home folder except ".c" files | find $HOME -not -iname "*.c" -print |
Find all directories under /home/mywebsite/public_html/sites/all/modules and set their permission to 750 | find /home/mywebsite/public_html/sites/all/modules -type d -exec chmod 750 {} + |
find all c, cpp files in current folder | find -name "*.cpp" -o -name "*.c" |
Find recursively the latest modified file in the current directory | find . -type f -printf '%TY-%Tm-%Td %TH:%TM: %Tz %p\n'| sort -n | tail -n1 |
Execute the 'echo' command on each file from the current directory tree individually | find . -exec echo {} \; |
Send one ping request to local machine. | ping -c 1 127.0.0.1 #ping your adress once |
Generate UUIDs for the files from the current directory tree | find -printf "%P\0" -exec uuid -v 4 \; | sort | awk -F'\0' '{ print $2 " " $1}' |
Search for file "file" with minimum depth set to 4 | find -mindepth 4 -name file |
Open a session-less connection to 'host' as user 'user' in master mode with a socket "/tmp/%r@%h:%p" to enable connection sharing | ssh user@host -M -S /tmp/%r@%h:%p -N |
List all leaf directories under current directory | saveIFS=$IFS; IFS=$'\n'; for dir in $; do [[ ! $prev =~ $dir ]] && echo "${dir}" ; prev="$dir"; done; IFS=$saveIFS |
Report file systems disk usage for file systems of type <type>. | df -kt<type> |
unsafed rm all file which name start with '#' | find / -name '#*' -atime +7 -print | xargs rm |
search for all the files in the current directory which have the group staff and have write permission enabled to the user and display them. | find . -group staff -perm -2000 -print |
Print crontabs of all users in system, skipping messages that some users don`t have crontab. | cat /etc/passwd | sed 's/^\([^:]*\):.*$/crontab -u \1 -l 2>\&1/' | sh | grep -v "no crontab for" |
Get a list of files and directories in the current directory tree | find . -print0 | xargs -0 echo |
count the total number of lines that are present in all the normal/regular files | find . -type f -exec wc -l {} \; | awk '{total += $1} END{print total}' |
Find and remove multiple *.mp3 files | find . -type f -name "*.mp3" -exec rm -f {} \; |
Print numbers from 1 to 10 using up to 4 processes | seq 10 | xargs -P4 -I'{}' echo '{}' |
Returns the number of modified files in a git repository, whitespaces stripped. | MYVAR=`git ls-files -m|wc -l|tr -d ' '` |
Execute "ps aux | grep php" every second | watch -n 1 'ps aux | grep php' |
Clean directories and subdirectories of the temporary files generated during normal use | find . \ -exec rm {} \; |
Run 'make' with parameter K_VERSION set to current kernel release. | make K_VERSION=`uname -r` |
Search for broken symlinks | find -L -type l |
Counts all files in a current folder and subfolders. | find `pwd` -type f -exec ls -l {} \; | wc -l |
Instantly kill all processes whose command is 'myprocess'. | kill -9 \`pgrep myprocess\` |
set alias "my_command" for command "$oldalias -option 3" | alias my_command="$oldalias -option 3" |
Run an awk program on every TXT file found in the current directory tree | find . -name "*.txt" -print -exec awk '$9 != "" {print; if exit; }' {} \; |
Join lines in file "aa" with lines in file "bb" if the lines share a common first word | join <(sort aa) <(sort bb) |
Sends current job to the background. | bg % |
Find all regular files in the current director and set their permissions to '644'. | find ./ -type f -exec chmod 644 {} \; |
Get a path name of a process id | ps -p 24297 -o comm --no-heading |
Copies file 'test' to each of directories like './fs*/*'. | echo ./fs*/* | xargs -n 1 cp test |
Search the entire system for SUID or SGID files | find / -path /proc -prune -o -type f -perm +6000 -ls |
Find all regular files undee '/usr/bin' directoryt tree that are less than 50 bytes in size | find /usr/bin -type f -size -50c |
find all text files in the current folder excluding those that are presenti n the folder "/svn" and search for a pattern. | find . -name '*.txt' \! -wholename '*/.svn/*' -exec grep 'sometext' '{}' \; -print |
Removes 'latest' folder if empty. | rmdir latest |
Find all *.c files in /usr/src bigger than 100k | find /usr/src -name '*.c' -size +100k -print |
Find all .c, .h files in the current directory tree and search them for string "expr" | find . -name '*.[ch]' | xargs grep -E 'expr' |
Find all directories in 1 level down the current directory | find . -mindepth 1 -maxdepth 1 -type d |
Find all files/directories with 'my key phrase' in their names under current directory, search for 'my key phrase' in all files under current directory and print a sorted and unique list of output | { find . -name '*my key phrase*'; grep -rl 'my key phrase' *; } | sed "s/^\.\///" | sort -u |
Remove files that are less than 1MB in size under current directory | find . -size -1M -exec rm {} \; |
Find all files/directories named 'file1' under current directory tree | find . -name file1 -print |
find all files in the current folder with the permission 777 and modify the permissions as 755. | find . -type f -perm 777 -exec chmod 755 {} \; |
display all the normal/regular files in a directory | find $dir -type f -name $name -print |
find all files in the file system which belong to no user or which have no user | find / -nouser |
Wrap each line in "file.txt" to fit in 80 characters | fold -w 80 file.txt |
find the biggest files only (but not directories) | find . -type f -exec du -Sh {} + | sort -rh | head -n 15 |
Copy directory hierarchy from "$sourceDir" to "$targetDir" | find "$sourceDir" -type d | sed -e "s?$sourceDir?$targetDir?" | xargs mkdir -p |
find all the regular/normal files in the /path folder and delete them | find /path -type f -print0 | xargs -0 rm |
Copy "*.cc", "*.h", and "SConstruct" to "rsync://localhost:40001/bledge_ce" using blocking IO | rsync --blocking-io *.cc *.h SConstruct rsync://localhost:40001/bledge_ce |
display a long listing of all files in the entire file system which are bigger than 1MB | find / -size +1000k -exec ls -l {} \; -print |
Read a line from standard input into variable "message" with prompt "Please Enter a Message: " followed by a newline | read -p "`echo -e 'Please Enter a Message: \n\b'`" message |
Search all variables and their values for "NAME" | env | grep NAME |
change the extension of all the ".abc" files in the folder "/the/path" to ".edefg" and do not change in the sub directories. execdir ensures that the command after it is executed only in the folder where the file is found | find /the/path -type f -name '*.abc' -execdir rename 's/\.\/\.abc$/version1_$1.abc/' {} \; |
Find all directories under current directory | find . -type d |
Query SRV records for domain '_kerberos._udp.foo.com' | dig -t SRV _kerberos._udp.foo.com |
Split "filename" into files of at most 200000 lines each | split -l 200000 filename |
Prints long listing of content in a root folder, including hidden files, with human-readable sizes, and stores output to '/root/test.out' file. | echo 'ls -hal /root/ > /root/test.out' | sudo bash |
create a hard link as directory named "new_hard_link" to the directory "existing_dir" as root | sudo ln -d existing_dir new_hard_link |
List files in the current directory and below that are exactly 1234 bytes in size | find . -size 1234c |
Print whether "$file" and "${file/${dir1}/${dir2}}" differ | diff -q "$file" "${file/${dir1}/${dir2}}" |
Print appended data in "file" that match "my_pattern" | tail -f file | grep --line-buffered my_pattern |
change user and group of the file bin to user and group root:wheel | sudo chown root:wheel bin |
find all the files in the current folder which which have been modified yesterday and day before yesterday and whose name is of length 1 | find . -name \? -daystart -mtime +0 -mtime -3 |
find all files in the a direcotry which have been modified in exactly 1 day back | find /home/bozo/projects -mtime 1 |
List subdirectories in the current directory | find . -maxdepth 1 -type d -print0 | xargs -0 ls -d |
Search /some/directory for files that are owned by the user "joebob" | find /some/directory -user joebob -print |
Send 5 pings to broadcast address "10.10.0.255" and print the unique IPs who responded | ping -c 5 -b 10.10.0.255 | grep 'bytes from' | awk '{ print $4 }' | sort | uniq |
Find *.java files under current directory and compress them to myfile.tar | find . -type f -name "*.java" | xargs tar rvf myfile.tar |
Find all files and directories whose names end in ".rpm", ignoring removable media, such as cdrom, floppy, etc. | find / -xdev -name \*.rpm |
Find all the files which are greater than 50MB and less than 100MB | find / -size +50M -size -100M |
set alias "prettify_json" for command "php -E '$o = json_decode; print json_encode;'" | alias prettify_json=php -E '$o = json_decode; print json_encode;' |
Search for the literal string 'v$process' in all files under current directory | find . -print|xargs grep v\$process |
Find all files under "/path" that do not contain a "." and append ".jpg" to their file name | find /path -type f -not -name "*.*" -print0 | xargs -0 rename 's/(.)$/$1.jpg/' |
Get domain name with 'google' from address $1 | dig -x "$1" | grep PTR | cut -d ' ' -f 2 | grep google | cut -f 5 |
Recursively change the user and group of all files in "/var/lib/jenkins" to "root" | chown -R root:root /var/lib/jenkins |
Resolve all symlinks in path to "firefox" binary if it exists in path, resulting in absolute path with no symlinks. | readlink -f $ |
Print the list of the subdirectories of the current directory | find . -mindepth 1 -maxdepth 1 -type d -printf "%P\n" |
Make a directory in the current working directory with a random 32 alphanumeric character name | mkdir $ |
Execute commands from "$file" in the current shell. | source "$file" |
find all files in the file system which belong to the group users and having the word "filename" in their name. | find / -group users -iname "filename" |
find all javascript files under the current folder | find . -name '*.js' |
Search for ERROR in all btree*.c files under current directory | grep ERROR $ |
Find all directories under current directory | find . -type d |
Finds all user session in system, and shows sorted user names with number of sessions of each user. | w | sed '1,2d' | cut -f1 -d' ' | sort | uniq -c |
find the MyCProgram.c (case insensitive find) under the current directory and run the md5sum command against it | find -iname "MyCProgram.c" -exec md5sum {} \; |
Copy %PATH% variable on Windows to clipboard | set %PATH% | clip |
list all regular files which path is not dir1 or dir2 | find ! -path "dir1" ! -path "dir2" -type f |
Find all *.txt files under /foo and print their total size | find /foo -name "*.txt" -exec du -hc {} + | tail -n1 |
search for all the files in the current directory which have size greater than 10KB (approx) and less than 32KB(approx). | find . -size +10000c -size -32000c -print |
Run your_command_here for each file found under /target/path with the file path as argument | find /target/path -type f -exec your_command_here \{\} \; |
Remove "-" from the contents of "/proc/sys/kernel/random/uuid" and save output to variable "comment" | comment=$(cat /proc/sys/kernel/random/uuid | sed 's/\-//g') |
Change permission to 000 of all directories named '.texturedata' under '/path/to/look/in/' directory tree | find /path/to/look/in/ -type d -name '.texturedata' -exec chmod 000 {} \; -prune |
Find files owned by no user | find / -nouser |
Rename all files in current directory to lowerase. | rename 'y/A-Z/a-z/' * |
Search for the regex ... in the manual of the find command | man find | grep ... |
create directory /tmp/new | mkdir /tmp/new |
Search the current directory tree for a regular file named "file_name" | find . -type f -name file_name |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.