nl_command
stringlengths 14
387
| bash_code
stringlengths 0
532
|
---|---|
Rename file with inode number 31467125 to new_name.html | find . -type f -inum 31467125 -exec /bin/mv {} new_name.html \; |
Remount "/dev/block/mtdblock3" on "/system" with read and write permission | mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system |
List all files named "filename" from the current directory tree, ignoring directory "FOLDER1" | find . -name FOLDER1 -prune -o -name filename -print |
move all the files in the current folder to temp folder and search atleast in one subfolder | find . -mindepth 1 -exec mv -t /tmp {} + |
Calculate md5 checksum of $KEY, take the 1st to 10th character, append them with the string '/tmp/command_cache.' and save the rsultant string to variable FILE | FILE="/tmp/command_cache.`echo -n "$KEY" | md5sum | cut -c -10`" |
Sort numerically and compare files "ruby.test" and "sort.test" | diff <(sort -n ruby.test) <(sort -n sort.test) |
Find all files/directories case insensitively containing 'xt' in their names under '/etc' directory tree | find /etc -iregex '.*xt.*' |
find all the files that have been modified in the last 60 minutes | find -mmin -60 |
Forcibly removes all files like '*.bak' and '*~' | rm -f *.bak *~ |
display the contents of all the regular/normal files in the entire file system with the name dummy and discard all the errors and save the output to the files tesst.txt | find / -type f -name dummy 2>/dev/null -exec cat {} \; >tesst.txt |
Removes all files but $1 newest ones from current folder. | ls -tp | grep -v '/' | tail -n +"$1" | xargs -I {} rm -- {} |
search for the regular/normal file "Dateiname" in the entire file system | find / -type f -iname "Dateiname" |
Delete all files/directories under current directory tree excluding '.gitignore' files/directories and files/directories matching the patterns '.git' or '.git/*' in their paths | find . ! -name '.gitignore' ! -path '.git' ! -path '.git/*' -exec rm -rf {} \; |
Search the current directory recursively for files containing "needle text" | find . -type f -print0 | xargs -0 grep -I "needle text" |
Finds binaries names in a list of running processes and prints containing folder of first 10 binaries. | ps aux | awk '{print $11}' | grep -x -e "/.*" | xargs dirname | head |
Try to determine the type of contents in "myfile" located in user's home directory. | file ~/myfile |
Execute "1" and write output to standard output and file "${LOG_FILE}" | exec 1 | tee ${LOG_FILE} |
Find all regular files under ./Desktop directory | find ./Desktop -type f |
Find files/directories named 'document' in 'ext2' partitions in entire filesystem | find / -fstype ext2 -name document -print |
Find all 50MB files | find / -size 50M |
find all jar files in current folder and search for a file in all these jar's and display the jar names along with searched file | find . -name "*.jar" -print -exec jar -tf {} \;|egrep "jar$|message_track.properties" |
Find all *.m4a files/directories under /home/family/Music directory | find /home/family/Music -name '*.m4a' -print0 |
create directory aaa | mkdir aaa |
Show the list of files modified more than 31 days ago | find / -mtime +31 -print |
Find all files named 'file' in 1 level down the current directory whose status were changed more than 1 day ago | find . -maxdepth 1 -ctime +1 -name file |
search for the word "foo" in all the regular/normal files in the directory "/path/to/dir" | find /path/to/dir -type f -print0 | xargs -0 grep -l "foo" |
Removes 'foo' file. | rm foo |
Find all files/directories greater than 100MB and print their list along with their size in /root/big.txt file | find \ |
Find all files in the current directory tree ignoring the ".git" directory | find . -type d -name '.git*' -prune -o -type f -print |
list any files modified since /bin/sh was last modified | find . -newer /bin/sh |
Takes first text field from file 'file.txt' as a domain name and gets short A record for this one. | awk '{print $1}' file.txt | xargs dig +short |
Print the number of 'processors' less 1. | cat /proc/cpuinfo | awk '/^processor/{print $3}' | tail -1 |
Run the Java archive "program.jar" in the background and immune to SIGHUP sent to it. | nohup java -jar program.jar & |
Gets MAC address of eth0 network interface. | ifconfig eth0 | awk '/HWaddr/ {print $5}' |
Remove all files/directories in the current directory without '.git' and '.gitignore' | find -mindepth 1 -depth -print0 | grep -vEzZ '(\.git(/|$)|/\.gitignore$)' | xargs -0 rm -rvf |
Find all regular files starting from the current directory | find . -type f |
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 {} |
Exclude directory from find . command | find -name "*.js" -not -path "./directory/*" |
list the regular files in your home directory that were modified yesterday | find ~/ -daystart -type f -mtime 1 |
Turns on network interface eth0. | ifconfig eth0 up |
display all the files in the home folder which have not been modified in the last 365*24 hours | find $HOME -mtime +365 |
Archive "src-dir" to "dest-dir" on "remote-user@remote-host" and delete any files in "dest-dir" not found in "src-dir" | rsync -av --delete src-dir remote-user@remote-host:dest-dir |
Count the number of areas that differ in "file1" and "file2" with 0 lines of unified context | diff -U 0 file1 file2 | grep ^@ | wc -l |
Print the path to the pipe created for process substitution | echo < |
Find the "param1" string in regular files under and below /var | find /var -type f -exec grep "param1" {} \; -print |
find all the files that have the word "fstab" in their name in a folder | find /etc -name *fstab* |
find all files in the current folder that are modified exactly 2 minutes ago | find -mmin 2 -print |
Create 5 empty .txt files | echo "a.txt b.txt c.txt d.txt z.txt" | xargs touch |
Print IP addresses of the host name | hostname -i |
Delete all hard links to the physical file with inode number 2655341 | find /home -xdev -inum 2655341 | xargs rm |
Archive all files specified on standard input under "/path/to/files" to "/path" on host "targethost" as user "user" with escalated privileges | rsync -av --files-from=- --rsync-path="sudo rsync" /path/to/files user@targethost:/path |
Calculate the SHA1 sum for the contents of the path/to/folder directory tree, including permissions | find path/to/folder -type f -print0 | sort -z | xargs -0 sha1sum; find path/to/folder \ -print0 | sort -z | xargs -0 stat -c '%n %a' | sha1sum |
Backup all PHP files under the current directory tree | find -name "*.php" –exec cp {} {}.bak \; |
Print the last 10 commands in history | history | tail -10 |
Display the contents of 'your_file' wrapping lines to maximum 80 characters, and waiting for user interaction after each page. | fold -80 your_file | more |
Remove files matching pattern '*-*x*.*' from the current directory tree | find -name '*-*x*.*' | xargs rm -f |
Sort a file 'file' preserving only unique lines and change the file in-place | sort -u -o file !#$ |
Find all directories under minimum 1 level down the current directory excluding directories (along with their contents) that start with a . (dot) in their names | find . -mindepth 1 -name '.*' -prune -o \( -type d -print \) |
Enables shell option 'lastpipe'. | shopt -s lastpipe |
Recursively change owner and group to "tomcat7" of "webapps", "temp", "logs", "work", and "conf" | chown -R tomcat7:tomcat7 webapps temp logs work conf |
find files which full path name like '*/*config' at current directory and print | find . -path '*/*config' |
Use "/var/log/wtmp" and print IPs and search for "^msw.*127.0.0.1" | who --ips /var/log/wtmp | grep '^msw.*127.0.0.1' |
sort based on size and display top ten small normal/regular files in the current folder | find . -type f -exec ls -s {} \; | sort -n | head -10 |
Remove all files from the current directory tree whose names contain whitespaces | find . -name "* *" -exec rm -f {} \; |
Execute "${MD5}" on all files found under "${1}", numerically sort the results, and save to variable "DATA" | DATA=$( find "${1}" -type f -exec ${MD5} {} ';' | sort -n ) |
Find *.txt files in the current directory tree, ignoring paths ./Movies/*, ./Downloads/*, and ./Music/* | find . -type f -name "*.txt" ! -path "./Movies/*" ! -path "./Downloads/*" ! -path "./Music/*" |
Remove containing directories and suffix ".wiki" from specified path, output the result. | basename /home/jsmith/base.wiki .wiki |
Move all files that contain "Subject: \[SPAM\]" to "your_file" | mv $ your_file |
Find all files in the /myfiles directory tree following symbolic links | find -L /myfiles |
Numerically sort each line in file "out" and print the result to console | sort -n out |
find all the files in the current folder which are writable | find . -writable |
Print all filenames under /proc and below | find /proc | xargs |
Find the directories whose names contain "New Parts" at level 3 of the current directory tree and create symlinks to them in /cygdrive/c/Views | find -mindepth 3 -maxdepth 3 -type d -name "*New Parts*" -exec ln -s -t /cygdrive/c/Views {} \; |
Recursively search for all files with names ending with "_test.rb", renaming them to end with "_spec.rb", using at most 4 concurrent processes. | find . -name "*_test.rb" | xargs -P 4 rename s/_test/_spec/ |
Find all regular files in the the user's home/mail directory and search for the word "Linux". | find ~/mail -type f | xargs grep "Linux" |
Removes all listed folders with content in sudo mode. | sudo rm -rf /usr/local/bin/npm /usr/local/share/man/man1/node* /usr/local/lib/dtrace/node.d ~/.npm ~/.node-gyp /opt/local/bin/node opt/local/include/node /opt/local/lib/node_modules |
Create a copy of index.html in all directories in current directory whose name contains Va, pausing for confirmation before overwriting any existing files - names may not contain spaces. | find . -mindepth 1 -maxdepth 1 -type d| grep \/a |xargs -n 1 cp -i index.html |
Find all files in the current directory tree whose names begin with '-' | find . -name '[-]*' |
Search the specified user for the given "filename" | find / -user pat -iname "filename" |
Creates temporary folder and saves path to it in 'td' variable. | td=$( mktemp -d ) |
Find all files/directories under '/usr/local/games' directory tree that contain the string 'xpilot' in their names | find /usr/local/games -name "*xpilot*" |
Compute difference between two dates | date -ujf%s $(($ - $)) +%T |
search for the word "foo" in all the regular/normal files with the name "file-pattern" in the directory "/path/to/dir" | find /path/to/dir/ -type f -name "file-pattern" -print0 | xargs -I {} -0 grep -l "foo" "{}" |
find all the files in the file system which are bigger than 3 bytes | find / -size +3 -print |
Counts the number of lines in each file in a git repository. | wc -l $ |
Lookup information for user "vivek" | finger vivek |
Recursively prints .txt files in current directory | find $(pwd) -name \*.txt -print |
Delete the text matched by the regex '<script>if(window.*<\/script>' in all index.html files under current directory | find index.html | xargs -rt sed -i 's/<script>if(window.*<\/script>//g' |
Find all files/directories under current directory tree excluding hidden files/directories | find . -not -path '*/\.*' |
Print a NULL-separated list of all directories of the current directory tree | find . -type d -print0 |
Rename all *.jpg files to *_MED.jpg files under temp/medium directory | find temp/medium -iname "*.jpg" -printf 'mv %p %p\n' | sed 's/\.jpg$/_MED\.jpg/' | while read l; do eval $l; done |
Find all files/directories with '.tar.gz' extension under $DIR/tmp/daily/ directory tree, sort them numerically and show the last 3 of them | find $DIR/tmp/daily/ -name '*.tar.gz' | sort -n | tail -3 |
find all files in home folder which have been modified exactly 1 day before | find ~ -mtime 1 -daystart |
Unzip every ".gz" file in the current directory tree | find . -name '*.gz' -exec gunzip '{}' \; |
Prints list of user 'myuser' groups in a format: 'groups: [comma-separated groups list]'. | echo "groups: [ $(groups myuser | sed -e 's/.\+\s\+:\s\+\/\1/g' -e 's/\/, /g') ]" |
Print the list of files in the current directory tree skipping Git files | find . -path './.git' -prune -o -type f |
list all files under .performance_test directory except .performance_test/prune_me directory | find ".performance_test" -not \ -exec bash -c 'echo "$0"' {} \; |
find all the files ending with "rb" and display the first 10000 lines from these files. | find . -name "*rb" -print0 | xargs -0 head -10000 |
find all the files in the current folder which have been modified in the 10 minutes ago | find -mmin +15 -mmin -25 |
Change all files with no user under "/var/www" to have owner "root" and group "apache" | sudo find /var/www -nouser -exec chown root:apache {} \; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.