nl_command
stringlengths 14
387
| bash_code
stringlengths 0
532
|
---|---|
Find all foo.mp4 files in the current directory tree | find ./ -name "foo.mp4" -exec echo {} \; |
List all ".txt" files with a unique md5 hash | md5sum *.txt | sort | perl -ne '=split; print "$f\n" unless $y eq $x; $x=$y' |
Find files in two different directories having the "test" string and list them | find esofthub esoft -name "*test*" -type f -ls |
Split "list.txt" into files with at most 600 lines each | split -l 600 list.txt |
Show all values of variables whose name or value contains "VARIABLE_NAME" | set | grep VARIABLE_NAME | sed 's/^.*=//' |
Calculate MD5 sums for all regular files in the current directory tree | find . -type f | while read f; do g=`md5sum $f` > $f.md5; done |
display the count of all the directories in the current folder | find . -type d –print | wc -l |
Print line, word and byte count for each file recursively and also show the total counts | wc `find` |
Find all the files on the system that have been modified within the last hour | find / -mmin -60 |
Find directories that have "755" permissions and modify them to have "700" permissions | find . -type d -perm 755 -exec chmod 700 {} \; |
Recursively finds all files with any cased text "Text" in a current folder, and precedes found string with its number in file. | grep -inr "Text" folder/to/be/searched/ |
Execute "ps -C java -o pcpu,state,cputime,etimes" every second | watch -n 1 ps -C java -o pcpu,state,cputime,etimes |
search in the current folder for the file with the name "test" | find . -iname test |
Find files that are writable by both the “other” and the group | find plsql -type f -perm -ug=rw -exec ls -l {} \; 2>/dev/null |
list all files under the current directory called cookies.txt | find -name cookies.txt |
Print full path of command "python2.7" | which python2.7 |
Replace all the mathes to regex '<script type="text\/javascript" charset="utf-8" src="file.js"><\/script>.*' with '<script type="text\/javascript" charset="utf-8" src="file2.js"><\/script>' in all HTML files under $DIR directory tree modifying the files in-place | find $DIR -type f -name '*.html' -exec sed -i 's/.*<script type="text\/javascript" charset="utf-8" src="file.js"><\/script>.*/<script type="text\/javascript" charset="utf-8" src="file2.js"><\/script>/g' {} \; |
Find largest file in linux with find command | find . -type f -printf "%s\t%p\n" | sort -n | tail -1 |
Page interactively through the output of running 'command' - the arrow keys move the view around, the < and > keys go to the beginning/end of the output, the / key initiates a search, the Q key quits, etc. | command | less |
Remove all files 'a.out' and *.o in the home directory tree that were accessed more than 7 days ago | find $HOME \ -atime +7 -exec rm {} \; |
find all files read less than 1 minute ago | find . -amin -1 |
Find any file that has "disc" somewhere in its name in the current directory and all of its sub-directories. | find . -name *disc* |
List the MD5 digest of all files under "teste1" and "teste2" sorted alphabetically | find teste1 teste2 -type f -exec md5 -r {} \; | sort |
Archive "path/subfolder" to "path", skipping files that are newer at the destination. | rsync -vuar --delete-after path/subfolder/ path/ |
Print file type of the executable file of command "foo" | file $(which foo) |
Display all lines containing PROBES in the current kernel's compile-time config file. | grep PROBES /boot/config-$(uname -r) |
search for a word in all the php files in the current folder and display the count of all matching lines. | find . -name \*.php -type f -exec grep -Hn '$test' {} \+ | wc -l |
Copy file in current directory of local host to host "remote", connecting as ssh user matching current local username, and copying the file in home directory on remote host - enable compression during transfer. | scp -C file remote: |
Find all files in /var/www/html/zip/data/*/*/*/*/* that are older than 90 days | find /var/www/html/zip/data/*/*/*/*/* -type f -mtime +90 |
Sets shell options 'globstar' and 'nullglob'. | shopt -s globstar nullglob |
Find all the files whose name is FindCommandExamples.txt and contains both capital and small letters in / directory | find / -iname findcommandexamples.txt |
Print IP addresses of the host name | hostname -I | awk '{print $1}' |
Append " | COUNTRY" to every line in "file" | yes '| COUNTRY' | sed $q | paste -d ' ' file - |
Print all lines of "seq 10" except the last 3 | seq 10 | tac | sed '1,3d' | tac |
Calculate md5 sums for each files matching 'main.cpp*' | md5sum main.cpp* |
Prints full path to files in a current folder. | ls -1 | awk -vpath=$PWD/ '{print path$1}' |
Delete all files under /path/to/files that are not newer than dummyfile | find /path/to/files -type f ! -newer dummyfile -delete |
find all the file which name end with c or h and content contain 'thing' | find . -name '*.[ch]' | xargs grep -l thing |
find all the files that have been modified on a specific day and copy them to another directory | find . -type f -daystart -mtime $date_dif -exec copy_it.sh $verbose -s {} -t $to_dir \; |
find all normal/regular files in current folder and display them in sorted order | find . -type f -ls | awk '{print $(NF-3), $(NF-2), $(NF-1), $NF}' |
find all the empty directories in the current folder and all its sub directories too | find . -depth -empty -type d |
Find files/directories under /users/tom that matches both the pattern "*.pl" and "*.pm" | find /users/tom -name "*.pl" -name "*.pm" |
Serves minimal HTTP response with netcat | while true ; do nc -l -p 1500 -c 'echo -e "HTTP/1.1 200 OK\n\n $"'; done |
Find PHP files containing 2 or more classes | find . -type f -name "*.php" -exec grep --with-filename -c "^class " {} \; | grep ":[2-99]" | sort -t ":" -k 2 -n -r |
Print the size for every *.ogg file found under the home directory | find $HOME -name '*.ogg' -type f -exec du -h '{}' \; |
Recursively copies /mnt/usr/lib to the '/usr/' directory, creating symbolic links on each file instead of real copying them. | cp -rs /mnt/usr/lib /usr/ |
Unzip "path/to/test/file.gz" to standard output and save all lines matching "my regex" to files with a 1000000 limit | gzip -cd path/to/test/file.gz | awk 'BEGIN{global=1}/my regex/{count+=1;print $0 >"part"global".txt";if (count==1000000){count=0;global+=1}}' |
Search for " 840" in history | history | grep " 840" |
search in root directory downwards all files which have exactly 2 links. | find / -links 2 -print |
Create a symbolic link in the current directory to "../config/init" | ln -s "../config/init" |
Find all *.mov files under current directory and run an echo command with the path and the name for each file | find . -iname "*.mov" -printf "%p %f\n" | while read -a HR ; do echo ffmpeg -i ${HR[0]} -f flv ${HR[1]} ;done |
create a zip of log files in the current directory which have not been accessed in the last 3 days (-p is for parallel processing for a 4 cpu machine) | find . -name '*.log' -mtime +3 -print0 | xargs -0 -P 4 bzip2 |
Print first field from semicolon-seprated line $string. | echo $string | cut -d';' -f1 |
Force pseudo tty allocation on connection to "somehost" and execute "~/bashplay/f" | ssh -t somehost ~/bashplay/f |
Remove all .mpg files in the /home/luser directory tree | find /home/luser -type f -name ‘*.mpg’ | parallel rm -f |
find all files with pattern` '*.mp3' and send output into nameoffiletoprintto file | find / -name *.mp3 -fprint nameoffiletoprintto |
Split the output of "my_program" into files of at most 100000 bytes each and use numeric suffixes | my_program | split -d -b 100000 - |
Find all the files/directories in the entire filesystem that do not belong to user 'wnj' and are not newer than the file/directory 'ttt' by modification time | find / \! \ -print |
Remove newline characters from "file.txt" | paste -sd "" file.txt |
Search the current directory for files whose names start with "messages." ignoring SVN files | find \ -exec grep -Iw uint {} + |
Create a named screen session | screen -x main -X title blah |
Find all regular files or symlinks in the entire file system | find / -mount -depth \( -type f -o -type l \) -print |
Execute "cat /tmp/iostat.running" every 10 seconds | watch -n10 cat /tmp/iostat.running |
Make $WEEKS_TO_SAVE+1 directories named "weekly.N" where N ranges from 0 to "$WEEKS_TO_SAVE" | mkdir -p $(seq -f "weekly.%.0f" 0 $WEEKS_TO_SAVE) |
Save the user name of the current user to variable "whoami" | whoami=$(whoami) |
Find all regular files in the current directory tree that are not readable by all | find -type f ! -perm -444 |
Display human-readable file type description of utf8.txt | file utf8.txt |
Change all directories under "./bootstrap/cache/" to owner "apache" and group "laravel" | sudo find ./bootstrap/cache/ -type d -exec chown apache:laravel {} \; |
Delete and count files in $DIR_TO_CLEAN that are older than $DAYS_TO_SAVE days | find "$DIR_TO_CLEAN" -type f -mtime +$DAYS_TO_SAVE -print0 | awk -v RS='\0' -v ORS='\0' '{ print } END { print NR }' | xargs -0 rm |
Finds all the log* files in /myDir recursively that are more than 7 days older, skipping already created .bz2 archives and compresses them. | find /myDir -name 'log*' -and -not -name '*.bz2' -ctime +7 -exec bzip2 -zv {} \; |
find all the html files in the current folder which have been modified in the last 7 days | find . -mtime -7 -name "*.html" -print |
Find all *.ogg files on the system ignoring the case | find / -iname '*.ogg' |
Prints directory where the executing script ($0) is located. | `dirname $0` |
Find all hidden regular files starting from the current directory | find . -type f -name ".*" |
Find all files in /dir1 and print only the filenames (not paths) | find ./dir1 -type f -exec basename {} \; |
Create symbolic links in the current directory for all files under "bar1" that are not directories and do not end in ".cc" | find bar1 -name '*foo*' -not -type d -not -name '*.cc' -exec ln -s $PWD/'{}' bar2/ \; |
find all the text files in current folder and move all these to another folder appending ".bar" at the end of these files | find . -name "*.txt" | xargs -I '{}' mv '{}' /foo/'{}'.bar |
display all the .sh scripts and perl files in the current folder | find . -type f \( -name "*.[sS][hH]" -o -name "*.[pP][lL]" \) |
find all *.java files/directories under current directory | find . -name "*.java" |
Find all *.wav files under current directory that match 'export' in their names and pipe the output to ./calc_space | find -type f -name "*.wav" | grep export | ./calc_space |
Search for the extended grep regex 'expr' in all files with '.c' and '.h' extension under current directory tree | find . -name '*.[ch]' | xargs grep -E 'expr' |
change the permissions of all the regular/normal files in the current folder | chmod 640 `find ./ -type f -print` |
find all files in etc which have been changed in the last 25 hours | find /etc -ctime -1 |
Find all the regular files under directory 'dir1' that are at least N levels deep | find dir1 -mindepth N -type f |
List all regular files under the current directory and below it | find . -type f -print0 | xargs -0 ls -l |
Remove all *.swp files under current directory ensuring white space safety | find . -name "*.swp" -print0|xargs -0 rm |
find all the files from root folder which have nogroup or noname and dispaly their details. | find / \ -ls |
Search for files only that end with .php and look for the string $test inside those files | find . -name \*.php -type f -print0 | xargs -0 grep -Hn '$test' |
Find all regular files under current directory tree and replace all '1.2.3.4' with '5.6.7.8' in these files modiying the files in-place | find . -type f -exec sed -i "s/1\.2\.3\.4/5.6.7.8/g" {} \ |
Prints real path of the folder containing $0 file. | $(readlink -f $(dirname "$0")) |
Report file system containing path-to-file disk usage human-readable. | df -h path-to-file |
find all the files in the home folder which have been modified in the last 30 minutes | find $HOME -mmin -30 |
Change permissions of "/usr/bin/wget" to 777 | chmod 777 /usr/bin/wget |
Print the full name of the current user | finger `id -un` | head -1 | cut -d: -f3- |
Search the current directory tree for symlinks pointing at other symlinks | find . -type l -xtype l |
List each unique character in "file" prefixed by number of occurrences | grep -o . file | sort | uniq -c |
Print the current directory tree with file sizes | tree -s |
Report file system inodes usage in human readable format | df -ih |
Search all regular files in the current directory tree for "string" | find . -type f | xargs -d '\n' grep string |
Find all files in your home directory and below that are larger than 100M. | find ~ -size +100M |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.