nl_command
stringlengths 14
387
| bash_code
stringlengths 0
532
|
---|---|
Search the entire file hierarchy for files larger than 100 megabytes and delete them. | find / -size +100M -exec /bin/rm {} \; |
Find which ruby files under current directory contain the string 'jump' | find . -name '*.rb' -exec grep -H jump {} \; |
Sort "," delimited lines in "file" by the first field preserving only unique lines | sort -u -t, -k1,1 file |
split compressed content of the file www into pieces per 1073741824 bytes named as "backup.tar.NNN" | tar czf - www|split -b 1073741824 - www-backup.tar. |
Set up a remote port forward from port 10022 on host "server" to port 22 on localhost | ssh -R 10022:localhost:22 device@server |
Remove all files whose names begin with "no-such-thing" in the /home/peter directory tree | find /home/peter -name no-such-thing* |xargs rm |
Write out the entire directory hierarchy from the current directory | find . -print |
Correct permissions for directories in the web directory | find /your/webdir/ -type d -print0 | xargs -0 chmod 755 |
Find all regular files starting from level 3 of directory tree ~/container and move them to the current directory's parent | find ~/container -mindepth 3 -type f -exec mv {} .. \; |
Save long listing of all files listed in file 'filenames.txt' to 'listing' variable | listing=$(ls -l $) |
Print file information of the executable file of command "gcc" | ls `which gcc` -al |
find all the files ending with "~" in current folder and move them to temp folder | find -name '*~' -print0 | xargs -0 -I _ mv _ /tmp/ |
To descend at most one levels of directories below the command line arguments pass the -maxdepth 1 option. This will avoid deleting nested directories: | find . -maxdepth 1 -type d -iname ".[^.]*" -print0 | xargs -I {} -0 rm -rvf "{}" |
Set the variable "me" to the name of the running script, or shell, login shells have a hyphen appended to the beginning of the name, such as "-bash". | me=`basename -- "$0"` |
Split "<file_name>" into files of at most 1024 MiB in size | split -b 1024m <file_name> |
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' |
Print the IP addresses for the current host name | hostname -I |
Display bash function definition of "foobar" | set | sed -n '/^foobar /,/^}/p' |
find all files in the current directory that are less than 1 byte size | find . -size -1c -print |
display all the files ending with ".foo" excluding those that are in the directory ".snapshot" | find . -name .snapshot -prune -o -name '*.foo' -print |
Get only the latest version of file from the 'custlist*' files under current directory | find . -name custlist\* | perl -ne '$path = $_; s?.*/??; $name = $_; $map{$name} = $path; ++$c; END { print $map{(sort(keys))[$c-1]} }' |
find the file "myfile.txt" in the folder /home/user/myusername/ | find /home/user/myusername/ -name myfile.txt -print |
Rename recursively all files in the current directory tree that are called "article.xml" to "001_article.xml" | find . -name "article.xml" -exec rename 's/article/001_article/;' '{}' \; |
Save the first line of "$j" into variable "k" in ksh | echo $j | read k |
Delete files older than 31 days | find ./ -mtime +31 -delete |
find file end with '.txt' in current directory. | find . -name "*.txt" |
Display process information once, adding "__CUSTOM_LINE_MARKER" at the end of each line. | top -n1 | sed 's/\$/\1__CUSTOM_LINE_MARKER/g' |
Find all *.txt files/directories under current directory and execute process command for each of them | find . -name '*.txt' -exec process {} \; |
Shows state of shell option 'extglob'. | shopt extglob |
Rename all files and directories under current directory tree by converting the names to small letters without descending into 'CVS' directory | find . -name CVS -prune -o -exec mv '{}' `echo {} | tr '[A-Z]' '[a-z]'` \; -print |
Prints process tree of the current process with parent processes. | pstree -s $$ |
List all *.txt files/directories under current directory | find . -name *.txt -exec ls {} \; |
List all *.txt files/directories under current directory | find . -name '*.txt' -exec echo "{}" \; |
Compare "file1" and "file2" line by line with 3 lines of unified context | diff -u file1 file2 |
Remove all .txt files with spaces in names in and below the current directory | find -name "*\ *.txt" | xargs rm |
Find all the regular files under $DIR directory tree which have been modified before the file $a excluding the file $a and delete them | find "$DIR" -type f \! -newer "$a" \! -samefile "$a" -delete |
Print the directory name of the full real path to the current script | echo "dirname/readlink: $(dirname $)" |
Dump "filename" as 2 byte wide hexadecimal and printable characters | od -xc filename |
Make a copy of the entire contents of SRCFOLDER called "DESTFOLDER", if DESTFOLDER exists, the copy will be placed within it. | cp -R SRCFOLDER DESTFOLDER/ |
Allow all users to execute "myscript.sh" | chmod a+x myscript.sh |
Unzip "file.gz" and print each line with the 5th " or | separated field greater than 5 | zcat file.gz | awk -F'[|"]' '$5>5' |
Find all hidden files | find /tmp -type f -name ".*" |
Print the last space separated word from "a b c d e" | echo "a b c d e" | tr ' ' '\n' | tail -1 |
Change the permission to 755 for all directories under current directory | find . -type d | xargs chmod -v 755 |
Finds all files in $LOCATION, prints file names, overwrite files with random content $TIMES times, and finally remove them. | find $LOCATION -print -exec shred $TIMES -u '{}' \; |
Search directory /path/to/check/ for regular files | find /path/to/check/* -maxdepth 0 -type f |
Generate HTML <a> links to files under the /public/html/cosi directory tree whose name is "wiki.phtml" | find /public/html/cosi -name "wiki.phtml -exec echo "<a href=\"{}\">{}</a>" \; |
List all .jpg files in the home directory tree | find . -name "*.jpg" -exec ls {} \; |
Prints path to folder that contains file "/path/to/vm.vmwarevm/vm.vmx". | echo /path/to/vm.vmwarevm/vm.vmx | xargs dirname |
Mount a partition in "$IMAGE" with offset "$OFFSET" to "media/$DEST" as read only using a loop device | mount -o ro,loop,offset=$OFFSET -t auto $IMAGE /media/$DEST |
Remove all .txt files in and below the current directory | find . -name "*.txt" -print0 | xargs -0 rm |
display a long listing of all images with the name "articles" in the current folder | find . -iname "Articles.jpg" -print0 | xargs -0 ls -l |
find files in the /usr/src directory with pattern` *.c that larger than 100 Kilobytes | find /usr/src -name '*.c' -size +100k -print |
Find all files/directories under current directory | find . |
Display mime type of file specified by variable "file" | file -ib "$file" |
Enables 'dotglob' shell option. | shopt -s dotglob |
Find x* files/directories under /tmp directory whose status was changed less than 1 day ago | find /tmp/ -ctime -1 -name x* |
Move all directories in the current directory tree that have been modified in the last day to "/path/to/target-dir" | find . -type d -mtime -0 -exec mv -t /path/to/target-dir {} + |
Sort the lines of the file 'temp.txt' and change it in-place | sort temp.txt -otemp.txt |
Compress all files under /source directory tree using gzip with best compression method | find /source -type f -print0 | xargs -0 -n 1 -P $CORES gzip -9 |
Delete all __temp__* files/directories under current directory tree | find . -depth -name '__temp__*' -exec rm -rf '{}' \; |
find all the files in the file system which have been modified in the last 30*24 hours | find / -mtime -30 -print |
Print 10 "#" characters in a row | yes '#' | head -n 10 | tr -d '\n' |
find all tools generated files a.out , *.o and core dump files which not required to us these all junk files & delete from current directory . | find . \ -exec rm {} \; |
This find command ignore the case when searching for file name , to ignore the case in this example all .py & .PY file will search | find . -type f -iname "*.py" |
Search for 'Attached: Yes' in all regular files under '/proc/scsi' directory tree matching the path '/proc/scsi/usb-storage' and show only the matched filenames | find /proc/scsi/ -path '/proc/scsi/usb-storage*' -type f | xargs grep -l 'Attached: Yes' |
Lists all top-level files in a '/home/dreftymac/' folder. | ls /home/dreftymac/ |
Remount "/mnt/mountpoint" as read only | mount /mnt/mountpoint -oremount,ro |
Create a copy of the current working directory structure in the usr/project directory, | find . -type d -print|sed 's@^@/usr/project/@'|xargs mkdir |
Search the /home/user1 directory tree for files whose names end in ".bin" | find /home/user1 -name "*.bin" |
Move all *.php~ files under current directory to /mydir | find . -iname "*.php~" -exec mv {} /mydir \; |
Make directories "/tmp/A", "/tmp/B", "/tmp/C", and "/tmp/ dir with spaces" | mkdir /tmp/A /tmp/B /tmp/C "/tmp/ dir with spaces" |
Delete all empty directories under root | find root -type -d -empty -delete |
Find all files/directories under $1 which have at least read permission for their owner and set read permission for group for these files/directories | find "$1" -perm -u+r -print0 | xargs chmod g+r |
Find all hard links to file /path/to/file that exist under the current directory tree | find . -samefile /path/to/file |
Archive files in "/mnt/source-tmp" to "/media/destination" | rsync -a /mnt/source-tmp /media/destination/ |
Find all files under $1, calculate their md5sums and redirect the results to $1__checksums.md5 | find "$1" -type f -exec md5sum {} \; > "$1"__checksums.md5 |
Print the last 10 commands in history | history | tail |
Find all files in the current directory tree whose size is greater than 1MB, and move them to the "files" folder | find . -size +1M -print0 | xargs -0 -I '{}' mv '{}' files |
Print lines in the sorted contents of "file2" that are not in the sorted contents of "file1" | comm -13 <(sort file1) <(sort file2) |
Delete files in /var/tmp/stuff and below that have not been modified in over 90 days | find /var/tmp/stuff -mtime +90 -execdir /bin/rm {} \+ |
Split "$in_file" excluding the first line into files of at most 100000 lines each with numeric suffixes of length 5 and the prefix $in_file"_" | awk '{if {print}}' $in_file | split -d -a 5 -l 100000 - $in_file"_" |
Set permissions for files in `foldername' to 777 | find foldername -exec chmod a+rwx {} ";" |
create a cpio archive of the entire contents the current directory while preserving the permissions, times, and ownership of every file and sub-directory | find . -depth -print | cpio -o -O /target/directory |
Find and print the full pathname of all PDF files in the current directory and its sub-directories. | find . -name "*.pdf" -print |
Search all directories starting from the root directory for "filename" | find / -iname "filename" |
Search the current directory tree for files whose names do not end in ".exe" and ".dll" | find . -not -name "*.exe" -not -name "*.dll" -type f |
find all the files in the entire file system that have been accessed in the last 60 days ago | find / -amin -60 |
Recursively print all directories in the current directory tree | tree -d |
Print content of all files found regarding seach options '[whatever]' | find [whatever] -exec cat {} \; |
Recursively finds all *.txt files and prints strings with "text_pattern" ignoring text distincts. | find . -name "*.txt" | xargs grep -i "text_pattern" |
Print which files differ in "dir_one" and "dir_two" recursively and sort the output | diff -qr dir_one dir_two | sort |
Find all files/directories named 'java' under /usr directory | find /usr -name java |
search for the file in the entire file system which has the words "filename" in its name | find / -name ”*filename*” |
Remove all files that contain the word GUI in entire file system | find / -type f -print0 | xargs -0 grep -liwZ GUI | xargs -0 rm -f |
Changes the group of defined file. | chgrp |
Continuously write "Hidden" separated by null terminators over the entire "/dev/sdb" disk | yes "Hidden" | tr '\n' '\0' | dd of=/dev/sdb |
Search the current directory recursively for files last modified within the past 24 hours ignoring .swp files and paths ./es* and ./en* | find . -mtime 0 -not \( -name '*.swp' -o -regex '\./es.*' -o -regex '\./en.*' \) |
Change the owner of all files in the current directory tree excluding those who match "./var/foo*" to "www-data" | find . -not -iwholename './var/foo*' -exec chown www-data '{}' \; |
display the file name and the file type of all the files in the current directory | find . -printf "%y %p\n" |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.