nl_command
stringlengths 14
387
| bash_code
stringlengths 0
532
|
---|---|
Archive "/path/to/files" on host "remotemachine" authentifying as user "user" and compressing data during transmission, copy symlinks as symlinks. | rsync -avlzp user@remotemachine:/path/to/files /path/to/this/folder |
grep from bottom of file | tac your.log | grep stuff |
find all files not ending in ".html" | find . -type f -not -name "*.html" |
find all the files in the file system that start with "win" and searched only in the mounted file systems | find / -mount -name 'win*' |
Write "\n/usr/local/boost_1_54_0/stage/lib" to standard output and append to "/etc/ld.so.conf" | echo -e "\n/usr/local/boost_1_54_0/stage/lib" | sudo tee -a /etc/ld.so.conf |
Find files under current directory that contains the string '/bin/ksh' | find . -type f -exec grep -iH '/bin/ksh' {} \; |
Find all *.* files not within .git directory and run $SED_CMD -i "s/$1/$2/g" on each of them | find . -type f -name "*.*" -not -path "*/.git/*" -print0 | xargs -0 $SED_CMD -i "s/$1/$2/g" |
Replace all occurrence of "toreplace" with "replaced" in all files under /home/www | find . -maxdepth 1 -type f -print0 | xargs -0 sed -i 's/toreplace/replaced/g' |
Change the owner and group of "testfile.txt" to "root" | sudo chown root:root testfile.txt |
Find all files/directories under /myfiles following symlinks if needed | find -L /myfiles |
Symlinks all of package`s installed files into the Homebrew prefix with overwrite. | brew link --overwrite python |
Find all files under current directory matching the pattern '[error,access,error_log,access_log,mod_jk.log]*.[0-9]*' in their names | find -name '[error,access,error_log,access_log,mod_jk.log]*.[0-9]*' -type f |
Find all SGID files in entire file system | find / -perm +g=s |
List all files under current directory that are greater than 10000000x512 bytes in size | find . -type f -size +10000000 -print|xargs ls -ld|more |
Print argument "$1" "$number" times | yes $1 | head -$number |
Recursively change the owner group of "/var/www" of to "www-data" | sudo chown -R www-data:www-data /var/www |
Remove all files in and below the current directory whose names begin with "not" | find . -name not\* -print0 | xargs -0 rm |
find all the files in the folder ~/Music which begin with "Automatically Add" | find ~/Music/ -name "Automatically Add*" |
Save the date 222 days before today to the variable 'date_222days_before_TodayDay' | date_222days_before_TodayDay=$ |
create directories a b c d e | mkdir a b c d e |
find all the files in the entire file system that have been modified exactly 7 days before which end with "conf" | find / -name "*conf" -mtime 7 |
Remove all files that were older than 3 days | find . -type f -mtime +3 –exec rm –f {} \; |
prune all the files in the current directory, only current directory (.) is the output | find . -prune |
Find all file paths under current directory, sort them numerically and show last 10 lines of output with only their paths | find . -type f -printf '%T@ %p\n' | sort -n | tail -10 | cut -f2- -d" " |
List all files and directories residing in the current directory and below | find -print0 | xargs -0 ls |
display all the configuration files in the etc folder | find /etc -name '*.conf' |
Remove file with inode number 31246 | find . -inum 31246 -exec rm [] ';' |
Changes to the directory where 'ssh' executable is located. | cd $(dirname $); |
recursively change user of the direct public_html and all files into it to user owner | chown -R owner:owner public_html |
Find all top level directories under current directory that doesn't contain a file/directory named 'bin' | comm -3 < < |
display the number of lines in all the files in the current folder | find . -exec wc -l {} \; |
List all regular files under the current directory and below it | find . -type f | xargs ls -l |
Execute "your_script.sh" passing all "sqlite.db" files from the current directory tree as arguments to it | find . -name 'sqlite.db' | xargs your_script.sh |
List all leaf directories of the current directory tree | find -depth -type d |sed 'h; :b; $b; N; /^\\/.*\n\1$/ { g; bb }; $ {x; b}; P; D' |
List files larger than 10MB under /var/log /tmp that haven't changed in a month | find /tmp /var/tmp -size +30M -mtime 31 -ls |
Search the "test1" directory recursively for regular files | find test1 -type f -print |
Find all directories under maximum 1 level down the current directory and set their permission to 700 recursively | find . -maxdepth 1 -type d -exec chmod -R 700 {} \; |
display all the directories in the current folder which start with processor followed by digit and ends with .1 or .2 | find . -type d -regextype posix-egrep -regex '\./processor[[:digit:]]*/10\.(1|2)' |
Find all files under /myfiles with 647 permission | find /myfiles -type f -perm -647 |
Read one character from standard input into variable 'c' | read -n 1 c |
Find directories that are directly under $workspace_ts directory (no-subdirectories) and were modified less than 30 days ago | find $workspace_ts -mindepth 1 -maxdepth 1 -type d -mtime -30 |
find all the files in the current folder which belong to the user root. | find . -user root -perm -4000 -print |
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 |
display all the files in the current folder which are bigger than 100MB and save the output list to the file /root/big.txt | find \ |
find all the ".sh" files in the current folder | find -iname *.SH |
Find all regular files under '/home/john/scripts' directory tree excluding files with '.ksh' extension | find /home/john/scripts -type f -not -name "*.ksh" -print |
Make directories "project/{lib/ext,bin,src,doc/{html,info,pdf},demo/stat/a}" as needed and do not cause an error if it exists | mkdir -p project/{lib/ext,bin,src,doc/{html,info,pdf},demo/stat/a} |
Change the owner of all ".txt" files in directory tree "/mydir" to "root" | find /mydir -type f -name "*.txt" -execdir chown root {} ';' |
display all text files in a folder | find $target -type f -iname "*.txt" |
Find all files/directories named 'photo.jpg' under current directory tree | find -name photo.jpg |
Go to /the/project/root//data, which in most filesystems/operating systems will be the same as cd /the/project/root/data | cd /the/project/root//data |
Locate all "copyright" files under and below /usr/share/doc | find /usr/share/doc -name "copyright" |
Delete all regular files under $DIR directory tree that have been modified before file $a | find "$DIR" -type f \! -newer "$a" -exec rm {} + |
find all the php files in the current folder | find . -name “*.[php|PHP]” -print |
Find any files in the current directory and its sub-directories that were last accessed more than 7 days or are larger than 10 * 1024 * 2 blocks in size, that is larger than 20480 blocks. | find . -atime +7 -o -size +`expr 10 \* 1024 \* 2` -print |
display all empty files in home folder | find ~ -empty |
Find all files with the SUID bit set, starting from / | find / -perm -u+s |
Make directories to "x/p/q" as needed | mkdir -p x/p/q |
search for files which are writable by either their owner or their group | find . -perm /u+w,g+w |
Find all *.data files under jcho directory | find jcho -name *.data |
Find files whose pathnames end in "config" | find . -path '*/*config' |
display all the directories in the current folder which are atleast one level deep | find . -mindepth 1 -type d -print0 |
Strip all '\' and newlines from $output and save the result to variable 'output' | output=$ |
display a long listing of all the files in the current folder which have been modified in the last 24 hours | find . -mtime -1 | xargs ls -ld |
Copy "fileName.txt" to all directories listed in "allFolders.txt" - names may not contain spaces. | cat allFolders.txt | xargs -n 1 cp fileName.txt |
Locates 'gcc' executable file, strips last two parts of the full path, adds '/lib' to the end and saves result in 'libdir' variable. | libdir=$(dirname $(dirname $(which gcc)))/lib |
Remove "-" from the contents of "/proc/sys/kernel/random/uuid" and save output to variable "comment" | comment=$ |
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 & 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 |
Copy and always overwrite all files in "/zzz/zzz" to "/xxx/xxx" | yes | cp -rf /zzz/zzz/* /xxx/xxx |
Delete all the files found in the current directory tree whose names begin with "heapdump" | find . -name heapdump*|xargs rm |
Find files with group write permission and remove the permission | find . -perm -20 -print | xargs chmod g-w |
Recursively copy "emptydir" to "destination/newdir" | rsync --recursive emptydir/ destination/newdir |
Print lines 10000 to 10010 from input "seq 1 100000" | seq 1 100000 | sed -n '10000,10010p' |
Find all files in /home/kos and below whose names end in ".tmp" | find /home/kos -name *.tmp -print |
display all the log files in the folder /var/log, print0 is used to handle files with only spaces in their names or which have newlines in their names and discard all the errors | find /var/log -name "*.log" -print0 2>/dev/null |
Output only the filetype suffix of "foo.tar.gz", in this case "gz" | echo "foo.tar.gz" | rev | cut -d"." -f1 | rev |
forcibly and verbosely create symbolic links in directory "~/Library/LaunchAgents" to all files located in /usr/local/opt/mongodb/ and that have filename extension ".plist" | ln -sfv /usr/local/opt/mongodb/*.plist ~/Library/LaunchAgents |
List all aliencoders.[0-9]+ files/directories under /home/jassi/ directory | find /home/jassi/ -name "aliencoders.[0-9]+" |& xargs ls -lrt | awk '{print $9}' |
find all the "error_log" files in the folder "/home" which are bigger than 5MB and force delete them | find /home -size +5000000b -name "error_log" -exec rm -rf {} \; |
Find the total size of all the ".avi" files in all the sub-folders below "/mnt/iso" | find /mnt/iso -name *.avi -printf "%s\n" | paste -sd+ - | bc |
Reverse the space separated words in "aaaa eeee bbbb ffff cccc" | echo "aaaa eeee bbbb ffff cccc"|tr ' ' '\n'|tac|tr '\n' ' ' |
Count non-blank lines in a file 'foo.c' | cat foo.c | sed '/^\s*$/d' | wc -l |
Finds strings with text "searched-string" recursively in all files of current folder. | grep -r "searched-string" . |
Remove all "CVS" directories from the current directory tree, ignoring the case | find . -iname CVS -type d | xargs rm -rf |
Convert all image.pdf files to image.png files under ./polkadots | find ./polkadots -name 'image.pdf' -exec convert -transparent white -fuzz 10% {} image.png \; -print |
find regular files and directories that have been modified in the last seven days | find . -mtime -7 -type f |
Copy the directory hierarchy of the current directory to "destdir" | find . -type d | cpio -pdvm destdir |
Copy file or folder linked to by "file" to "file" | cp -rf --remove-destination `readlink file` file |
search for the host "slc02oxm.us.oracle.com" in all the xml files in the current folder and display the files which has the matched content | find -name “*.xml” -exec grep -l “slc02oxm.us.oracle.com” {} \; |
Find all directories under current directory whose paths are 5 characters long | find . -regextype posix-extended -type d -regex ".{5}" |
Display the contents of /var/log/syslog one page at a time, pausing for user interaction between each. | more /var/log/syslog |
List all files with their modification time in entire file system that are newer than the file $newerthan and older than the file $olderthan in regards of modification time and sort them according to file modification time | find / -type f -name "*" -newermt "$newerthan" ! -newermt "$olderthan" -printf "%T+\t%p\n" | sort |
find any files or directories called ".svn" under the current directory and run a recursive delete (without prompting) command on each one. | find . -iname .svn -exec bash -c 'rm -rf {}' \; |
Recursively change the owner and group of all files in the current directory to "apache" | find . -maxdepth 1 -not -name "." -print0 | xargs --null chown -R apache:apache |
Get domain names from file '1.txt' and request TXT DNS record for each one | cat 1.txt | xargs dig TXT |
Serach for all the files containing grep in man pages | find /usr/share/man/ -regex .*grep* |
Search all the .c and .h files in the current directory tree for "expr" | find -name '*.[ch]' | xargs grep -E 'expr' |
Create empty files (or update timestamps if they exist) with names matching each word in variable "correctFilePathAndName" | echo -e "$correctFilePathAndName" | xargs touch |
create a zip of all the files in the current folder which are bigger than 100Kb and do not go more than 2 levels during search | find . -maxdepth 2 -size +100000 -exec bzip2 {} \; |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.