nl_command
stringlengths 14
387
| bash_code
stringlengths 0
532
|
---|---|
Count the number of files in the /usr/ports directory tree whose names begin with 'pkg-plist' and which contain 'unexec.rmdir%D' | find /usr/ports/ -name pkg-plist\* -exec grep 'unexec.rmdir %D' '{}' '+' | wc -l |
Update the archived copy of the home directory, "alldata.tar" | find ~/ -newer alldata.tar -exec tar uvf alldata.tar {} ; |
Removes empty folder 'symlink'. | rm -d symlink |
Find and print the names of all files found in the current directory and all of its sub-directories. | find . -print |
Locate all files named 'restore.php' in the current directory and 3 levels below | find . -maxdepth 4 -name 'restore.php' |
Prints newline, word, and byte count for each *.py in a current folder. | wc *.py |
find all the html files in the current folder and replace the end of each line with a pattern | find ./ -type f -name '*.html' | xargs sed -i '$s/$/<\/description>/' |
Find all *.mp4 files under /foo/bar and move them to /some/path | find /foot/bar/ -name '*.mp4' -exec mv -t /some/path {} + |
Find `string' in all *.java files ignoring the case of that string | find . -type f -name "*.java" -exec grep -il string {} \; |
Find broken symlinks | find ./ -follow -lname "*" |
Read standard input until a null character is found and save the result in variable "line" | read -d '' line |
Create a symbolic link named "/usr/bin/my-editor" to "/usr/share/my-editor/my-editor-executable" and attemp to hard link directories | ln -sF /usr/share/my-editor/my-editor-executable /usr/bin/my-editor |
Start 'top' to monitor all processes with the default settings. | top |
Search the current directory tree for regular files lacking read permissions for user, group, or others | find . -type f ! -perm -444 |
Find the files that have "644" permissions and modify them to have "664" permissions | find . -type f -perm 644 -exec chmod 664 {} \; |
Prints path to folder that contains file "/path/to/vm.vmwarevm/vm.vmx". | dirname "/path/to/vm.vmwarevm/vm.vmx" |
display a long listing of all the directories in current directory | find . -type d -ls |
Save long listing of all running processes in the 'log' file, and save number of process strings that contain 'cntps' in the 'cnt' variable. | cnt=`ps -ef| tee log | grep "cntps"|grep -v "grep" | wc -l` |
Set the executable bit for all users on all regular files from directories arch/x86/usr/sbin, arch/x86/usr/X11R6/bin, usr/sbin/ | find arch/x86/usr/sbin arch/x86/usr/X11R6/bin usr/sbin/ -type f | xargs chmod a+x |
Get a two column list of all regular .rb files residing in the current directory tree | find . -name "*.rb" -type f -print0 | xargs -0 -n 2 echo |
Gets IP address of 'eth0' network interface. | ifconfig eth0 | grep -oP '[^ ]+' |
Find all the regular files in $DIR directory tree which have not been modified in the last 450 days and delete them | find $DIR -type f -mtime +450 -exec rm {} \; |
Edit the cron job list for user 'wwwrun' using default editor specified by the EDITOR environment variable, or /usr/bin/editor if no default editor is specified. | sudo crontab -u wwwrun -e |
Delete all files under $DESTINATION directory tree that were modified more than 7 days ago | find $DESTINATION -mtime +7 -exec rm {} \; |
Count number of occurences of "123" in the string "123 123 123" | echo "123 123 123" | grep -o 123 | wc -l |
List all broken symlinks under the current directory with info on whether the links exist or not | find -L . -type l |xargs symlinks |
Allow all users to execute '$pathToShell"myShell.sh"' | chmod a+x $pathToShell"myShell.sh" |
Report file system disk space usage in human readable format | df -h |
Recursively finds 'pattern' in files from current folder, and prints matched string with number only if matching whole word. | grep -rnw "pattern" |
find all the directories in the entire file system whose size is greater than 50KB | find / -type d -size +50k |
find all the files in current folder which end with a speicifc regular expression and display their count | find ./ -type f -regex ".*\.[JPGjpg]$" | wc -l |
Find all files/directories ignoring *~ files/directories without descending into .snapshot directory with null character as the delimiter | find . -name .snapshot -prune -o \ |
Copy all files in current directory that do not match */exlude-path/* in their paths to /destination/ preserving directory structure | find . -type f -not -path '*/exlude-path/*' -exec cp --parents '{}' '/destination/' \; |
Find regular files under / that contain "stringtofind" and clear out their contents | find / -maxdepth 1 -xdev -type f -exec grep -i "stringtofind" -l {} \; -exec sed -i '/./d' {} \; |
search for all the ".pyc" files inthe current folder and remove them | find . -name "*.pyc" | xargs -i rm '{} |
Displays status of currently active network interfaces. | ifconfig |
Find all the files that were modified exactly one day ago | find . -mtime 1 |
Delete all files in the /myDir directory tree that were last modfied 7 days ago | find /myDir -mindepth 1 -mtime 7 -exec rm -rf {} \; |
display all the files in the folder "/dev" which belong to the user "peter" | find /dev -user "peter" |more |
Search directory /Users/david/Desktop/ recursively for regular files with extensions .txt, .mpg, .jpg | find /Users/david/Desktop -type f \( -name '*.txt' -o -name '*.mpg' -o -name '*.jpg' \) |
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 files under $dir | find $dir -type f |
Delete newlines from output of 'hg st -R "$path"' and save to variable "var" | var=`hg st -R "$path" | tr -d '\n'` |
Search the current directory recursively for files containing "needle text" | find . -type f | xargs grep -I "needle text" |
Find all executable upvoter-* files/symlinks under maximum 1 level down the {} directory | find {} -name 'upvoter-*' \ -maxdepth 1 -perm +111 |
Forcefully delete all files in the current directory | find . -name '*' | xargs rm |
Count all the lines of all files with names ending with 'php' in current directory recursively | find -name '*php' | xargs cat | wc -l |
Split "file.txt" excluding the first line into files of at most 4 lines each and with a prefix "split_" | tail -n +2 file.txt | split -l 4 - split_ |
Change directory to the directory containing the "oracle" executable | cd $(dirname `which oracle`) |
Print the first 32 hexadecimal characters from "/dev/urandom" | cat /dev/urandom | tr -cd 'a-f0-9' | head -c 32 |
find all text files in current folder and display all files that have the alphabet a in their name | find . -name ".txt" | grep a |
Print a list of symbolic links reachable from the current directory that do not resolve to accessible files | find -L. -type l |
Print 'echo 'hello, world' | echo 'hello, world' | cat |
find all files in the current folder which have been accessed in the last 30 minutes | find . -amin -30 |
find all sqlite files in the current directory. | find ./ -name "*.sqlite" |
Counts number of occurences of all ip addresses in 'ip_addresses' file, and prints all addresses with number of occurences in a descending order. | cat ip_addresses | sort | uniq -c | sort -nr | awk '{print $2 " " $1}' |
For each .def file under the current directory, create an empty .def.out file with current timestamp. | find . -name '*.def' | sed 's/\/\1.out/' | xargs touch |
Prefix all files and directories in the current directory with "unix_" | ls | xargs -i mv {} unix_{} |
List .conf files residing in the /etc/nginx/ directory tree | find /etc/nginx -name '*.conf' -exec echo {} ; |
Recursively change the owner of all files in "testproject/" to "ftpuser" | chown ftpuser testproject/ -R |
Interpret in the current shell all lines in config.sh which contain the word "marker" | source < |
Delete all empty directories in the "test" directory tree | find test -depth -type d -empty -delete |
Search for 'text' in all regular files under current directory tree | find . -type f -exec grep "text" {} /dev/null \; |
Remove all vmware-*.log files under current directory ensuring white space safety in filename | find . -name vmware-*.log -print0 | xargs -0 rm |
Find and remove the file with inode number 782263 in the current directory tree | find . -inum 782263 -exec rm -i {} \; |
display all the regular/normal files in the current directory which are atleast 2 levels deep | find . -mindepth 2 -type f |
Connect to host "remotehost" as ssh user "user" to copy remote file "/location/KMST_DataFile_*.kms" to current directory on local host. | scp -v user@remotehost:/location/KMST_DataFile_*.kms |
find all the regular files in current folder, that have been changed in the last 3 days and display last 5 files | find . -type f -ctime -3 | tail -n 5 |
List the unique parent directories of all .class files found under "/root_path" | find /root_path -type f -iname "*.class" -printf "%h\n" | sort -u |
Removes all empty folders under path '/thepath', printing info message on each operation. | find /thepath -type d -empty -print0 | xargs -0 rmdir -v |
Find all directories under current directory and change their permission to 500 | find . -type d -exec chmod 500 {} \; |
Print "Cannot acquire lock - already locked by " followed by content of $lockfile file | echo "Cannot acquire lock - already locked by $(cat "$lockfile")" |
List all .svn files/directories under current directory | find . -name .svn -exec echo {} \; |
Find *2011* files and grep for the string 'From: Ralph' in those files | find . -name '*2011*' -print | xargs -n2 grep 'From: Ralph' |
Find broken links using the file command on each symlinks in the system and searching for the keword 'broken' with grep | find / -type l -print0 | xargs -0 file | grep broken |
search for all html files in a folder and create a zip file of all these files | find /your/path/ -type f -name "*.html" | xargs zip all_html_files.zip |
Find all files under /path and below writable by `group' or `other' | find /path -perm /g+w,o+w |
Find all files/directories with 'my key phrase' in their names under current directory and redirect the output to mylist.txt | find -name '*my key phrase*' > mylist.txt |
Removes any empty folder that matches pattern ed*. | rmdir ed* |
display all the files in the current folder which have been modified between two dates | find . -newermt “Sep 1 2006” -and \! -newermt “Sep 10 2006” |
display all the files in the current folder which have the permissions 777 and which have been modified in the last 24 hours. | find . -perm 777 -mtime 0 -print |
Remove everything in a current folder without prompting. | rm -rf * |
Print yesterday's date as yyy:mm:dd | date +%Y:%m:%d -d "yesterday" |
Get a sorted list of the longest line with line number for each file under current directory | find . -iname '*.page' -exec awk '{if(length($0) > L) { LINE=NR;L = length($0)}} END {print L"|"FILENAME":"LINE}' {} \; | sort |
Find things changed today | find /path/to/search -daystart -ctime -1 |
Print a minimal set of differences between files in directories "a" and "b", ignore the first 3 lines of output, and print any line starting with "-" with the first character removed | diff -dbU0 a b | tail -n +4 | grep ^- | cut -c2- |
Mount the directory "/etc" on "/tmp/sarnold/mount_point/" | mount -obind /etc /tmp/sarnold/mount_point/ |
set alias "cdl" for command 'cd -- "$"' | alias cdl='cd -- "$"' |
find all the normal/regular files in the current folder which have been modified two days ago and display a long listing of them | find . -type f -mtime 2 -mtime -3 -daystart -exec ls -l {} \; |
find al the files which have been accesed in the last 6 days and display their details | find . -atime +6 -exec ll | more |
Count the number of lines in the current git repository | git ls-files | xargs cat | wc -l |
File 'mydatafile' has a number on each line, display the sum of these numbers. | awk '{s+=$1} END {print s}' mydatafile |
display all files ending with "ini" in current folder | find . -type f -name '*.ini' |
Delete the 4th tab separated column from the output of "finger" | finger | awk -F"\t" -v 'OFS=\t' '{ $4=""; print $0}' | sed 's/\t\{2,\}/\t/' |
Reports time consumed by command 'sleep 1'. | time sleep 1 |
find all the normal/regular files in the folder "pathfolder" which are 2 levels deep, excluding all hidden files and display the count | find pathfolder -mindepth 2 -maxdepth 2 -type f -not -path '*/\.*' | wc -l |
Look for files that have SUID or SGID set | find / -perm +6000 -type f |
Find directories named `build' | find . -type d -name build |
Print the 2nd white space separated fields in "file.txt" as a comma separated list | awk '{print $2}' < file.txt | paste -s -d, - |
show all the ".acc" files in the folder /home | find /home -type f -name '*.aac' |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.