nl_command
stringlengths 14
387
| bash_code
stringlengths 0
532
|
---|---|
Delete files under $LOCATION that match $REQUIRED_FILES in their names and were modified more than 360 minutes ago | find $LOCATION -name $REQUIRED_FILES -type f -mmin +360 -delete |
Print file system disk space usage in posix and human readable format, format as a table | df -Ph | column -t |
Suffix all files and folders in the current directory with "_SUF" | ls | xargs -I {} mv {} {}_SUF |
display the amount of disk space used by all the log files in the folder /usr/local/apache/logs/ | find /usr/local/apache/logs/ -type f -name "*_log"|xargs du -csh |
Run "./configure" with a new environment variable CC set to the full path of the command 'gcc' | CC=$(which gcc) ./configure |
Change owner to "root" and group to "wheel" of "adbind.bash" | sudo chown root:wheel adbind.bash |
create directory new_dir | mkdir new_dir |
Copy permissions from "version2/somefile" to "version1/somefile" | chmod --reference version2/somefile version1/somefile |
Decompresses file. | bzip2 -d /tmp/itunes20140618.tbz |
Recursively copies everything from '/zzz/zzz/' to the '/xxx/xxx' overwriting the existing files and answering 'yes' on each request for overwriting. | yes | cp -rf /zzz/zzz/* /xxx/xxx |
Find .jpg files owned by user daniel in the current directory and its sub-directories but ignore any file beginning with "autumn". | find . -user daniel -type f -name *.jpg ! -name autumn* |
Search the system for the file 'myfile' ignoring permission denied errors | find . -name myfile |& grep -v 'Permission denied' |
Change folder to the one where $0 link target file is located. | cd $(dirname $(readlink -f $0)) |
Check if the directory tree whose name is given as variable $somedir contains no regular files | find "$somedir" -type f -exec echo Found unexpected file {} \; |
Find root's Ruby files accessed in the last two minutes | find /apps/ -user root -type f -amin -2 -name *.rb |
Search for occurrences of string "main(" in the .c files from the current directory tree | find . -name "*.c" -print | xargs grep "main(" |
Search the files from the current directory tree for "foo" | find . -exec grep foo {} \; |
extract the content of the file doc.gz and split it into pieces per 1000 lines compressed with gzip | zcat doc.gz | split -l 1000 --filter='gzip > $FILE.gz' |
Pushes to the dirs stack directory path of the current script, or current directory path if executed from bash shell. | pushd $(dirname $0) |
find all the files in the current folder that end with the word bar | find -name *bar |
Creates file by template 'aws-sync-XXXXX' in a current folder and stores file name in a 'dir' variable. | dir="$(mktemp aws-sync-XXXXX)" |
Search the current directory recursively for files with the exact permissions u=rwx,g=rx,o=rx | find . -perm u=rwx,g=rx,o=rx |
Convert "some random\nbytes" to "%" separated hexadecimal byte values | echo -ne 'some random\nbytes' | xxd -plain | tr -d '\n' | sed 's/\/%\1/g' |
Remove all .sh files in the current directory tree whose names begin with "new" | find . -name "new*.sh" -exec rm -f '{}' \; |
Find all *.txt files/directories in entire file system | find / -name "*.txt" |
Find all *.gz files/directories under asia and emea directory | find asia emea -name \*.gz -print0 | xargs -0 |
Find all TXT files in the current directory and copy them to directory "$HOME/newdir" | find "$HOME" -name '*.txt' -type f -not -path "$HOME/newdir/*" -print0 | xargs -0 cp -t "$HOME/newdir" |
List root's regular files with permissions 4000 | find / -type f -user root -perm -4000 -exec ls -l {} \; |
Find all files under /somefolder matching the extended case insensitive regex '\./$' in their paths | find -E /somefolder -type f -iregex '\./$' |
Clean up all zombie processes by sending SIGTERM signal to their parent process, which requests them to terminate. | kill $ |
Find all files named "file.ext" within the current folder and print the path where each one is located | find `pwd` -name "file.ext" -exec dirname {} \; |
find the path of a specfic video file in the current directory | find . -name foo.mp4 | sed 's|/[^/]*$||' |
Report root file system disk usage human-readable. | df -h / |
Mount remote "cifs" filesystem "//server/source/" on "/mnt/source-tmp" with username "Username" and password "password" | mount -t cifs //server/source/ /mnt/source-tmp -o username=Username,password=password |
replace the name php_admin_flag to #php_admin_flag in all the .htaccess files in the folder /home/nobody/public_html | find /home/nobody/public_html -type f -name .htaccess -exec replace "php_admin_flag" "#php_admin_flag" -- {} \; |
find all files in the current directory do not display the files which are not readable | find . ! -readable -prune |
Display the contents of file 'filename' excluding lines starting with # or empty/space-only lines, waiting for user interaction after each page. | grep -v '^$\|^#\|^\s*\#' filename | grep -v "^[[:space:]]*$" | more |
Find all regular files that reside in the current directory tree and were last modified more than 1 day ago | find . -type f -mtime +1 |
find all pdf files in the current folder | find . -name “*.pdf” -print |
Search for all files in the current directory recursively whose names begin with "Linkin Park" | find . -name "Linkin Park*" |
Copy all .png files from the home directory tree to imagesdir/ | find ~/ -name *.png -exec cp {} imagesdir \; |
List all directories in current directory, works even if they have weird names or names starting with a dash. | find -maxdepth 1 -type d | awk -F"./" '{print $2}' |
Find all files under images directory | find images -type f |
Count the number of files in the directory trees whose pathnames match pattern '/dev/sd*[a-z]' | find /dev/sd*[a-z] | wc -l |
Finds shell options with 'login' in name. | shopt | grep login |
Recursively copies "$1" to "$2". | cp -R "$1" "$2" |
List all files/directories under current directory | find -ls |
Move "tobecopied/tobeexcluded" to the current directory | mv tobecopied/tobeexcluded . |
display all the files in the folder /home which do not belong to the group test | find /home -not -group test |
split uncompressed content of the file biglogfile.gz into pieces per 500000 lines | zcat biglogfile.gz | split -l500000 --filter='gzip > $FILE.gz' |
Gets list of IP addresses of all network interfaces. | /sbin/ifconfig | sed -ne $'/127.0.0.1/ ! { s/^[ \t]*inet[ \t]\\{1,99\\}\\\\{0,1\\}\\[ \t\/].*$/\\2/p; }' |
Change the owner to "owner" and group to "nobody" of "public_html" | chown owner:nobody public_html |
Report file systems disk usage in 1GB blocks. | df -BG |
Find and clear UTF-8 files with BOM | find . -type f -exec sed '1s/^\xEF\xBB\xBF//' -i.bak {} \; -exec rm {}.bak \; |
set alias "X" for command "| cut -d' ' -f2" | alias -g X="| cut -d' ' -f2" |
Search for lines that have zero or more whitespace characters before "http://" and number the uniquely sorted output | grep '^[[:space:]]*http://' | sort -u | nl |
display all instances of the .profile file in the entire file system | find / -name .profile -print |
Print every found file like '*.cfg' under '/path/to/files/' directory followed by its content, and wait 2 seconds after each printed file | find /path/to/files -type f -name \*.cfg -print -exec cat {} \; -exec sleep 2 \; |
Remove trailing white spaces from all files under current directory ignoring directories wtih *.git* in their paths and keep backups of the originals | find . -type f -not -iwholename '*.git*' -print0 | xargs -0 sed -i .bak -E "s/[[:space:]]*$//" |
delete all the regular files in the temp folder which have not been modified in the last 24 hours + at the end gives bulk input to the rm command | find /tmp/ -type f -mtime +1 -exec rm {} + |
display all the files in the folders /etc /srv excluding the paths /etc/mtab and /srv/tftp/pxelinux.cfg | find /etc /srv \( -path /srv/tftp/pxelinux.cfg -o -path /etc/mtab \) -prune -o -print |
display a list of all files in the folder passed as argument to a script | find $@ -ls |
Replace commas (',') with newlines in $MOUNT_OPTS and search for the regex '^acl$' | echo $MOUNT_OPTS | tr , \\\n | grep '^acl$' -q |
Create symlinks to all /home/folder1/*.txt files with the same name in current directory | find /home/folder1/*.txt -type f -exec ln -s {} \; |
Exclude directory from find . command | find . -name '*.js' | grep -v excludeddir |
Find all files in the current directory tree whose pathnames match pattern '*/1/lang/en.css' | find . -path ‘*/1/lang/en.css’ -print |
find all the header files in /usr/include which have been modified in the last 400 days | find /usr/include -type f -mtime -400 -name "*.h" |
Reports count of characters in the value of ${FOO_NO_WHITESPACE} variable as follows: "length==<counted number of characters>" | echo -e "length==$" |
search for a word in all the files in the current directory and display the list of matched files. | find . -type f -exec grep -l 'needle' {} \; |
Find and print the names of all files found in the current directory and all of its sub-directories. | find . |
Read hexadecimal bytes from device "/dev/midi1" | od -vtx1 /dev/midi1 |
find the ten biggest files | find /home -type f -exec du -s {} \; | sort -r -k1,1n | head |
Archive "/media/Incoming/music/" to "/media/10001/music/" on host "server" and skip files that are newer in the destination, delete any files in the destination not in the source, and compress data during transmission | rsync -avzru --delete-excluded /media/Incoming/music/ server:/media/10001/music/ |
Find files by type | find -type type_descriptor |
List unique series of 3 characters in file "$1" prefixed by the number of occurrences and sorted from most frequent to least frequent | fold -w3 "$1" | sort | uniq -c | sort -k1,1nr -k2 |
Recursively search for all directories containing "foo" under the current directory, renaming them to replace "foo" with "Bar" | find . -type d -iname '*foo*' -depth -exec rename 's@Foo@Bar@gi' {} + |
Print appended data in "/var/log/syslog" as the file grows | tail -f /var/log/syslog |
find all text files in the current directory and compress them to a cpio file | find . -name '*.txt' | cpio -pdm /path/to/destdir |
Find all files/directories named 'photo.jpg' under current directory tree | find -name photo.jpg |
Compare files in "/tmp/dir1" and "/tmp/dir2", treating absent files as empty and all files as text | diff -Nar /tmp/dir1 /tmp/dir2/ |
Remount the root file system with read and write permission | mount -o rw,remount -t rootfs / |
Gets IP addresses of all network interfaces. | ifconfig | grep ad.*Bc | cut -d: -f2 | awk '{ print $1}' |
Find all .txt files in the user's home directory and below. | find ~/ -name '*.txt' |
Find all files under /somefolder matching the extended case insensitive regex '\./(.*\.error.*|second.*log|.*FFPC\.log)$' in their paths | find -E /somefolder -type f -iregex '\./(.*\.error.*|second.*log|.*FFPC\.log)$' |
Remove all files except the ones listed in "MANIFEST" | find -type f -printf %P\\n | sort | comm -3 MANIFEST - | xargs rm |
show all the files in the current folder excluding those from the directories whose name starts with "git" | find . -type d -name '.git*' -prune -o -type f -print |
create a list of all files in all subdirectories | find . -type f -exec md5 {} \; |
recursively change owner and group of the directory /opt/antoniod/ to user and group antoniod | chown -R antoniod:antoniod /opt/antoniod/ |
Delete empty files and print their names | find . -empty -delete -print |
display all directories in current folder excluding those that are present in .git folder | find . -iregex '.*/.git/.*' -prune -o -type d -name 'CVS' |
Find & Substitute Only 2nd Occurrence of a Word Using sed s//2 in all .txt files | find . -type f -name "*.txt" -exec sed 's/Linux/Linux-Unix/2' thegeekstuff.txt |
search for the file job.hostory in the folder "/data/Spoolln" | find /data/SpoolIn -name job.history |
View gzip's help documentation | gzip --help | less |
List each file or directory in the current directory prefixed by its filesize in bytes and sorted from smallest to largest | du -a --max-depth=1 | sort -n |
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 |
Replace all newlines with spaces in standard input | sed -z 's/\n/ /'g |
Counts lines in each of *.php files in current folder with subfolders and prints total count as well. | find . -name '*.php' | xargs wc -l | sort -r |
Construction with additional '-exec true' to be used if both commands need to run regardless of their success or failure. | find . -name "*.txt" \ -exec grep banana {} \; |
list files in /u/bill that were last read from 2 to 6 minutes ago | find /u/bill -amin +2 -amin -6 |
Find all directories under minimum 1 level down the $GIVEN_DIR directory with null character as the delimiter | find "$GIVEN_DIR" -type d -mindepth 1 -print0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.