nl_command
stringlengths 14
387
| bash_code
stringlengths 0
532
|
---|---|
find all the mp3 files in the file system | find / -iname "*.mp3" -print |
Find files/directories named 'foo.bar' under './dir1' and './dir2' directory tree | find ./dir1 ./dir2 -name foo.bar -print |
List files larger than 10MB in the /var directory recursively | find /var/ -size +10M -ls |
Search for the regex $greppattern in all files with '.c' or '.h' extension under $searchpath with name pattern $filepat and show the matched line numbers, file names and matched lines | find "$searchpath" -name "$filepat.[ch]" -exec grep --color -aHn "$greppattern" {} \; |
Search /var/tmp for files larger than 30 MB modified 31 days ago | find /tmp /var/tmp -size +30M -mtime 31 -ls |
Find all *fink* files/directories in entire file system | find / -name "*fink*" -print |
Search for all the directories named 'm?' under current directory tree, add the extension ".mbox" to all, create a 'Messages' directories inside them and move all files with .emlx extension to 'Messages' directory | find . -name 'm?' -type d -exec mv '{}' '{}.mbox' ';' -exec mkdir '{}.mbox/Messages' ';' -exec sh -c 'mv {}.mbox/*.emlx {}.mbox/Messages' ';' |
find all the text files in current folder and force delete them | find . -name "*.txt" | xargs rm -rf |
Print reverse lookup for adress 127.0.0.1 | dig -x 127.0.0.1 |
Removes '/var/lib/mongodb/mongod.lock' in 'sudo' mode. | sudo rm /var/lib/mongodb/mongod.lock |
Split "file" into 10 files of about equal size without splitting lines | split -n l/10 file |
Find & calculate total number of worlds in all .txt file from current directory | find . -type f -name '*.txt' -exec wc -w {} \; | awk '{total += $1} END{print total}' |
Recursively change the owner of all files in "/usr/local/lib/node_modules" to the current user | sudo chown -R $USER /usr/local/lib/node_modules |
Remove files that are less than 1MB in size under <directory> | find <directory> -type f -size -1M -delete |
find all the files in the home folder which have been modified today | find ~ -type f -mtime 0 |
Write standard output of "command" to console and append to "stdout.log", and write standard error of "command" to console and append to "stderr.log" | command > > 2> > |
Print common files of directory "one" and "two" | comm -12 < < |
Find all the files without permission 777 | find / -type f ! -perm 777 |
Remove all .txt files with spaces in names in and below the current directory | find -name "*\ *.txt" | xargs rm |
Use the uncompressed contents of "blah.gz" as input to "some_command" | gunzip -c blah.gz | some_command |
search for a regular/normal file myfile in the folder "/home/weedly" | find /home/weedly -name myfile -type f -print |
Find all files/directories with '.mp4' extension and all regular files with '.flv' extension, sort them according to their names and display the first 500 of them | find /storage -name "*.mp4" -o -name "*.flv" -type f | sort | head -n500 |
List first 20 files under current directory | find . -type f |xargs ls -lS |head -20 |
Print the content of file | sed 's/\n//' file |
Find files/directories modified within the last day under /etc | find /etc -type f -ctime -1 |
Calculate md5 sum of file $ecriv | md5sum "$ecriv" |
Create a tar archive of files from directory tree "data" | find data/ -print0 | tar -T - --null --create -f archive.tar |
reverse a file with comma deliminators instead of newline deliminators | tac -s "," parse.txt > newparse.txt |
Search all regular files from the current directory tree for lines containing "California" and "surfboard", and save the output as SurfsUp.txt | find . -type f -exec grep California {} \; -print | grep surfboard > SurfsUp.txt |
find files which modification time is one day ago | find . -mtime 1 |
Join lines in file "A" with lines in file "B" if the lines share a common first word | join <(sort -n A) <(sort -n B) |
Finds more than 5 days old files in two directories and compresses them. | find /home/folder1 /home/folder2 -type f -mtime +5 -exec compress {} \; |
Saves command execution output to a file 'outfile' together with time report. | > outfile 2>&1 |
Read the history file $HISTFILE and append the contents to the history list | history -r "$HISTFILE" #Alternative: exec bash |
delete all the text files from the current folder after user confirmation | find . -name "*.txt" -ok rm {} \; |
Search for all *.conf files in entire file system | find / -type f -name "*.conf" |
dsisplay all files inthe current folder | find . |
Find all the files in file system which are modified in last 1 hour | find / -mmin -60 |
insert "e" when it's pressed | bind '"e":self-insert' |
Find all 400 permission files under /data directory, print 'Modifying ' appended with file path for each of them and change their permission to 755 | find /data -type f -perm 400 -exec echo Modifying {} \; -exec chmod 755 {} \; |
Delete all files/directories under current directory tree with '.$1' extension where $1 expands as the first positional parameter | find . -name "*.$1" -delete; |
Print the file content of command "f" | cat "$" |
List all directories found in the current directory and below. | find . -type d |
Change file owner and group of "/path/to/yourapp" to root and print a diagnostic | chown -v root:root /path/to/yourapp |
Search in current directory downwards all files whose owner is aa1 and grop is grp . | find . \( -user aa1 - group grp \) -print |
search for all "tif" images in the entire file system | find / -name '*.tif ' –print |
Print command with PID 11383 | ps | egrep 11383 | tr -s ' ' | cut -d ' ' -f 4 |
Copy file linked to by "bar.pdf" to "bar.pdf" | cp --remove-destination `readlink bar.pdf` bar.pdf |
find all the files ending with ".foo" in the folder /usr | find /usr -name '*.foo' -print |
List all files under current directory matching the regex '.*(c|h|cpp)$' | find -E . -type f -regex '.*(c|h|cpp)$' -exec ls {} \; |
Find every JavaScript file in the wordpress directory tree | find wordpress -name '*js' |
display the count of all the normal/ regular files in the current directory | find . -type f |wc -l |
Search for the regex '^ERROR' in all *.log files under current directory | find . -name "*.log" -exec egrep -l '^ERROR' {} \; |
Append the current date in '%Y%m%d_%H%M' format with the basename of $0 and save it to variable 'LOGNAME' | LOGNAME="`basename "$0"`_`date "+%Y%m%d_%H%M"`" |
print apparent size rather than disk usage | du -B1 --apparent-size /tmp/foo.txt |
Prints week day of a 31 day in a current month. | cal | awk 'NR==2 {split} {for if print a[i]}' FIELDWIDTHS="3 3 3 3 3 3 3 3" date=31 |
Set timestamp of B to the timestamp in stat format specified by variable "old_time" | touch -d"$(date --date="@$old_time")" B |
Find all *.ogg (case insensitive) files/directories under your home directory that are greater than 100MB in size | find $HOME -iname '*.ogg' -size +100M |
Save the user name in all capitals of the current user to variable "v" | v=$ |
Find all .mp3 files starting from the current directory and delete them | find . -type f -iname *.mp3 -delete |
create the compressed tar archive images.tar.gz containing all jpg files found under / | find / -name *.jpg -type f -print | xargs tar -cvzf images.tar.gz |
verbosely create intermediate directoriy tmp as required and directory boostinst | mkdir -pv /tmp/boostinst |
Read a line of standard input with prompt "My prompt: " and save it to variable "varname" | read -e -p "My prompt: " varname |
Silently read exactly 1 character ignoring any delimiters into variable "SELECT" | read -s -N 1 SELECT |
display the filename and size of all the files in the file system which are bigger than 20MB | find / -type f -size +20000k -exec ls -lh {} \; | awk '{ print $8 ": " $5 }' |
Find files starting with the word "file" in the current directory tree | find . -name "file*" |
change the permissions of all regular/normal files in the current directory, print0 is used for handling files with newlines in their file name | find . -type f -print0 | xargs -0 chmod 664 |
Change every file under "/var/www/html/" to have permissions 664 | sudo find /var/www/html/ -type f -exec chmod 664 {} \; |
Find all the regular files with '.tgz' and '.gz' extensions and delete the oldest file under '/home/backups' directory tree | find /home/backups -type f \ -print0 | xargs -0 ls -t | tail -1 | xargs rm |
Find directories in the current directory tree that were modified within the last 24 hours and move them to /path/to/target-dir | find . -type d -mtime 0 -exec mv {} /path/to/target-dir \; |
Find all files/directories under /usr/tom which matches the extended regex '*.pl| *.pm' in their names | find /usr/tom | egrep '*.pl| *.pm' |
Print the hexadecimal bytes and printable characters of "Hello world" | echo Hello world | od -t x1 -t c |
Archive "source" to "root@remote_server_name:/opt/backups" via ssh on port 3382 and compress data during transmission | rsync -avz --rsh='ssh -p3382' source root@remote_server_name:/opt/backups |
Sets shell option 'nounset'. | shopt -s -o nounset |
Recursively removes all empty folders under current path, printing info message on each operation, and suppressing error messages if folder is not empty. | find -type d -empty -exec rmdir -vp --ignore-fail-on-non-empty {} + |
Removes only lowest level subfolders from current directory tree (folders without files and another folders within). | find . -type d | xargs rmdir |
Find all files/directories 1 level down the ~/bin/FilesDvorak/ directory and redirect the sorted output to file b | |
find all the files in the current folder that have a single letter in their name which have been modified in the last 3 days but not today | find . -name \? -daystart -mtime +0 -mtime -3 |
Creates temporary folder and saves path to it in 'other' variable. | other="$(mktemp --directory)" |
show all the files in the entire file system which are bigger than 1.1GB | find / -size +1.1G |
remove all the files in the current folder which have not been changed in the last 30*24 hours | find ./ -ctime +30 -type f -exec rm -f {} \; |
Remove all *.tmp files from the /tmp directory tree | find /tmp -name "*.tmp" | xargs rm |
Measure the execution time of the command: find /usr/src -name "*.html" | xargs grep -l "foo" | wc -l | time find /usr/src -name "*.html" | xargs grep -l "foo" | wc -l |
find Texinfo source files in /usr/local/doc | find /usr/local/doc -name '*.texi' |
Case-insensitive search all existing environment variables and their values for "shell". | env | grep -i shell |
Output all lines that have a common first colon-separated field in files 'selection2.txt' and 'selection1.txt' by displaying the common (first) field of each line, followed by the extra fields in both lines. | join -t: selection2.txt selection1.txt |
Converts all windows line endings to unix line endings | find $(pwd) -type f | xargs -I xxx sed -i 's/\r//g' xxx |
Force delete all jpg files in current directory which are less than 50KB and do not search in the sub directories | find . -maxdepth 1 -name "*.jpg" -size -50k -exec rm {} \; |
Search all files in the current directory tree that are named "whatever" for "whatever" | find . -name whatever -print | xargs grep whatever |
Find all regular files in the current directory tree and print a command to move them to the current directory | find . -type f -exec echo mv -t . {} + |
Execute all commands in "/path/to/commands-inc.sh" on server "remote" as user "user" | ssh user@remote 'bash -s' < /path/to/commands-inc.sh |
Find all regular files in the current directory tree last modified between 1 and 3 days ago and list them using format '%TY %p\n' | find ./ -daystart -mtime -3 -type f ! -mtime -1 -printf '%TY %p\n' |
Recursively change the owner to "user" and group to "www-data" of "yourprojectfoldername" | chown -R user:www-data yourprojectfoldername |
Exit the shell on the first error encountered | set -e |
Find *.conf files/directories only upto 2 levels down under /etc directory and show a few lines of output from the end | find /etc -maxdepth 2 -name "*.conf" | tail |
Search the files residing in the current directory tree whose names contain "bills" for "put" | find . -name '*bills*' -exec grep put {} \; |
Saves location of file $1 in 'dir_context' variable. | dir_context=$(dirname -- "$1") |
Archive all directories in /path/to/directory/* (only command line arguments, no sub-directories) to files with .tar.gz extension | find /path/to/directory/* -maxdepth 0 -type d -printf "%P\n" -exec sudo tar -zcpvf {}.tar.gz {} \; |
Installs 'firefox' package without using 'sublime2' repository. | yum --disablerepo=sublime2 install firefox |
Report file systems disk usage human-readable using POSIX output format. | df -Ph |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.