nl_command
stringlengths 14
387
| bash_code
stringlengths 0
532
|
---|---|
Monitor all processes whose command contains 'http'. | top -p $ |
Silently read a single character into variable "REPLY" | read -n1 -s |
use regex with find command | find . -regextype posix-egrep -regex '\./[a-f0-9\-]{36}\.jpg' |
Compose filepath as folder path where file $SRC is located, and lowercase filename of $SRC file, and save it in 'DST' variable | DST=`dirname "${SRC}"`/`basename "${SRC}" | tr '[A-Z]' '[a-z]'` |
find all the regular/normal files in the folder "myfiles" which have the permission 647. | find /myfiles -type f -perm -647 |
Search the current directory tree for TXT files skipping hidden ones | find . -type f \( -iname "*.txt" ! -iname ".*" \) |
display all the files ending with ".foo" excluding those that are in the directory ".snapshot" | find . -name .snapshot -prune -o -name '*.foo' -print |
Display the first 10 lines of the byte hex dump with no file offset data for "/bin/ls" | od -t x1 -An /bin/ls | head |
Count the number of unique lines in sorted file "a.txt" compared to sorted file "b.txt" | comm -23 a.txt b.txt | wc -l |
Find all *.mp3 files in file system with more than 10MB and delete them using rm command | find / -type f -name *.mp3 -size +10M -exec rm {} \; |
display all the files in the kat folder | find kat -printf "%f\n" |
Find all files/directories named 'date' under /usr | find /usr -name date |
Copy all files unconditionally and directories in directory tree "myfiles" to "target-dir" preserving directory hierarchy and modification time | find myfiles | cpio -pmud target-dir |
Find all regular files or symlinks in the entire file system | find / -mount -depth \ -print |
Find all files and directories that do not match the pattern given as the $controlchars variable | find . ! -name "$controlchars" |
Find all files owned by group `root' in the current directory tree and change their user to `temp' | find . -group root -print | xargs chown temp |
Remove the last file extension from "filename.gz" | echo "filename.gz" | sed 's/^/./' | rev | cut -d. -f2- | rev | cut -c2- |
Find all directories in level 1 down the $queue directory | echo "$queue" | xargs -I'{}' find {} -mindepth 1 -maxdepth 1 -type d |
For each line in file2 whose first field appears as a first field in file1, print an output line constructed following the specified -o format. | join -11 -21 -o1.1,1.2,1.3,2.3 file1 file2 |
find all the word press configuration php files in the folder /var/www and do not search beyond two levels | find /var/www/ -name wp-config.php -maxdepth 2 |
Find all files under and below the current working directory with the word California in the file | find . -type f -exec grep California {} \; -print |
Archive all files (not directories) in "folder1" to "copy_of_folder1" specifying to include files info.txt and data.zip | rsync -a -f"+ info.txt" -f"+ data.zip" -f'-! */' folder1/ copy_of_folder1/ |
Print unique lines of sorted file "b" compared with sorted file "a" | comm -13 a b |
See what files are executable by the file's owner and group | find -type f -perm -110 |
Delete all files under '/home/backups' directory tree with '.tgz' or '.gz' extension (case insensitive) that were modified more thant 60 days ago | find /home/backups -type f -iregex '.*\.t?gz$' -mtime +60 -exec rm {} \; |
Remove all regular files from the current directory tree whose names do not end with "ignore1" or "ignore2" | find . -type f -not -name '*ignore1' -not -name '*ignore2' | xargs rm |
change group of the file myfile to group friends | chown :friends myfile |
Starts new window named 'win0' in detached tmux session 'vims', opens file 'foo' within. | tmux new-window -t vims -d -n "win0" "vim foo" |
Search /usr/local for subdirectories whose names end with a number 0-9 | find /usr/local -maxdepth 1 -type d -name '*[0-9]' |
Set permissions to 2770 for all directories in the current directory tree | find . -type d -exec chmod 2770 {} + |
Find all files/directories containing 'farm' in their names under '/usr/share' directory tree | find /usr/share -name '*farm*' |
modify the permissions of all the folders in a directory | find /path/to/dir -type d -exec chmod 755 {} \; |
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 all *.csv files under /foo/bar and move them to some_dir | find /foot/bar/ -name '*.csv' -print0 | xargs -0 mv -t some_dir |
search for bash and rsync files in the entire file system excluding search in /usr folder and discard all the errors | find / -path /usr -prune -o \ -print 2>/dev/null |
find all the regular/normal files in the /path folder and delete them | find /path -type f -delete |
Replace the "openssl" command executable with a symbolic link to "/usr/local/ssl/bin/openssl" | sudo ln -sf /usr/local/ssl/bin/openssl `which openssl` |
Print summary of new/missing files, and which files differ between folder1 and folder2. | diff -arq folder1 folder2 |
Find all files/directories under /home/bozo/projects directory that were modified 1 day ago | find /home/bozo/projects -mtime 1 |
Copy all files under director 'foo' whose name doesn't contain 'Music' to directory 'bar'. | find foo -type f ! -name '*Music*' -exec cp {} bar \; |
Prints out all the logged-in users along with their group information. | groups $ |
Find recursively all files whose names begin with "foo" | find . -name "foo*" |
Remove files that are less than 1MB in size under current directory | find . -type f -size -1M -exec rm {} + |
Connect to port 1234 of specified IP address or hostname as ssh user "user", and copy all visible files in /var/www/mywebsite/dumps/ on this host to local directory /myNewPathOnCurrentLocalMachine - this directory must already exist on local host. | scp -P 1234 user@[ip address or host name]:/var/www/mywebsite/dumps/* /var/www/myNewPathOnCurrentLocalMachine |
Find all files on the system that are world writeable | find / -perm -0002 |
Filter the contents of 'file' through sed commands written in 'commandfile', displaying the result. | sed -f commandfile file |
Find all files under directory tree /path/to/dir whose permissions are not 644 | find /path/to/dir ! -perm 644 |
Recursively finds strings with the whole word 'word-1' or 'word-2' in any file under 'directory-path', following symlinks, and prints found strings. | egrep -w -R "word-1|word-2” directory-path |
Search for all files that end in ".conf" | find / -type f -name "*.conf" |
Archive directory "/mnt/data" to "/media/WD_Disk_1/current_working_data/", deleting any extraneous files in destination, compress data during copy. | rsync -az --delete /mnt/data/ /media/WD_Disk_1/current_working_data/; |
search for all the rpm files in the file system which reside in the same partition as that of the root | find / -xdev -name "*.rpm" |
Split the output of "tar [your params]" into files of at most 500 MiB in size and use prefix "output_prefix" | tar [your params] |split -b 500m - output_prefix |
Filter out current date in current time zone from the GMT+30 and GMT+20 representations of current date and show the last one | echo -e "$\n$" | grep -v $ | tail -1 |
display all the files in the current folder that have been modified in the last 24 hours | find -mtime -1 |
Find files/directories that does not have write permssion for group | find /path ! -perm /020 |
Print the full real path of "/dev/disk/by-uuid/$1" followed by "is mounted" | echo $(readlink -f /dev/disk/by-uuid/$1) is mounted |
Test if the tar file in "file.tar.gz" is corrupt | gunzip -c file.tar.gz | tar t > /dev/null |
Synchronize "xxx-files" to "different-stuff/xxx-files" recursively preserving metadata with a bandwidth limit of 2000 KiB/s | rsync -pogtEtvr --progress --bwlimit=2000 xxx-files different-stuff |
display all the files in the current folder | find . | xargs echo |
Run command with all the file/directory path under whatever directory as arguments | find whatever -print0 | xargs -0 command |
Copies newest file under the current folder to the '/tmp/' | cp $(ls -1tr * | tail -1) /tmp/ |
Search for the string "ERROR" in all XML files in the current working directory tree | find . -name "*.xml" -exec grep "ERROR" /dev/null '{}' \+ |
display all the .sh scripts and perl files in the current folder | find . -type f \( -iname "*.sh" -or -iname "*.pl" \) |
Finds strings with text "searched-string" recursively in all files of current folder and prints names of files with matched strings. | grep -r -l "foo" . |
Print numbers from 1 to 30 with equalized 0 padding | seq -w 30 |
Unzip and untar "tarball.tar.gz" | zcat tarball.tar.gz | tar x |
Print which files differ in "dir1" and "dir2" recursively | diff -qr dir1 dir2 |
Removes all empty folders with modification time more that 10 minutes ago from $homeDirData folder. | find $homeDirData -type d -mmin +10 -print0 | xargs -0 rmdir |
Remove all *.swp files under current directory | find . -name "*.swp"|xargs rm |
Find regular files matching pattern "*oraenv*" and excecute the "file" utility for each of them | find . -name "*oraenv*" -type f -exec file {} \; |
Removes all top-level empty folders within the current folder. | ls | xargs rmdir |
List first 20 files under current directory | find . -type f |xargs ls -lS |head -20 |
Unzip all *.zip files below the current directory | find -name '*.zip' | xargs -n 1 unzip |
Find all regular files whose names contain a case insensitive pattern composed of space separated positional arguments and display a long listing of them | find . -type f -iname '*'"$*"'*' -ls |
Find all files under media/ directory and change their permission to 600 | find media/ -type f -exec chmod 600 {} \; |
search for all the files in the folder /data/images which have been modified after /tmp/start and before /tmp/end | find /data/images -type f -newer /tmp/start -not -newer /tmp/end |
Find files in the current directory tree that match pattern "*sub*" | find ./ -name "*sub*" |
Find the 5 largest regular files in the current directory and below. | find -type f -exec du -Sh {} + | sort -rh | head -n 5 |
List all environment variables containing 'USER' in their name or value that would result in running a command with 'sudo env'. | sudo env |grep USER |
find directories under the $LOGDIR directory where there has been no modifications within the last 24 hours and compresses the files. | find $LOGDIR -type d -mtime +0 -exec compress -r {} \; |
Set permissions of all directories under "/opt/lampp/htdocs" to 755 | find /opt/lampp/htdocs -type d -exec chmod 755 {} \; |
Execute "date" every second | watch -n 1 date |
search all the files in the current folder excluding those that are present in the folder test and using regex | find . -name test -prune -regex ".*/my.*p.$" |
Search for files whose name is "filename" and whose permissions are 777 | find / -perm 777 -iname "filename" |
find all the text files in the current folder | find . -type f -name '*.txt' -print |
Find all regular files named postgis-2.0.0 under your home directory | find ~/ -type f -name "postgis-2.0.0" |
List all files without descending into subdirectories | find * -type f -print -o -type d -prune |
Find all files/directories named modules under current directory | find . -name modules |
Print lines in file 'file' that do not match any word specified in file 'blacklist' | grep -w -v -f blacklist file |
Search the current directory recursively for MOV files, following symlinks | find . -iname "*.mov" -follow |
Search for the files that are owned by user rooter or by user www-data | find -user root -o -user www-data |
Find all directories under /home that doesn't contain a file/directory named 'bin' | find /home -type d ! -exec test -e '{}/bin' \; -print |
search for the files which contain the word start in their name excluding search in ./proc, ./sys, ./run folders | find . -path ./proc -prune -or -path ./sys -prune -or -path ./run -prune -or -iname '*start*' -print |
display all the ".c" files which have been modified in the last 10 minutes | find /home/david -amin -10 -name '*.c' |
Process each file beginning with "file" in the current directory as an argument to "bash script.sh" | find -type f -maxdepth 1 -name 'file*' -print0 | sort -z | xargs -0 bash script.sh |
Find files ending in "f" | find . -path '*f' |
search for the file test2 in the current folder | find -name test2 |
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 {} \; |
Count number of lines in "Sample_51770BL1_R1.fastq.gz" | zcat Sample_51770BL1_R1.fastq.gz | wc -l |
Find files modified in the last 5 minutes starting from the current directory | find . -mmin -5 |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.