nl_command
stringlengths 14
387
| bash_code
stringlengths 0
532
|
---|---|
Serach in current directory downwards all files which have not been modified since last 7 days | find . -mtime +7 -print |
Overwirte file '/path/to/your/file' with random content, showing progress while execution. | shred -v -n 1 /path/to/your/file #overwriting with random data |
Search the current directory tree for .VER files | find . -name "*.VER" |
Search all .c files from the current directory tree for "keyword", ignoring the case | find . -name "*.c" -exec grep -i "keyword" {} ";" |
Find all *.txt files/directories under your home directory | find ~ -name "*.txt" -print |
find all files in the folder "myfiles" which are exactly 5 bytes | find /myfiles -size 5 |
Reverse the space separated words in "35 53 102 342" | echo 35 53 102 342|tr ' ' '\n'|tac|tr '\n' ' ' |
Print lines in the sorted contents of "a.txt" that are not in the sorted contents of "b.txt" | comm -23 < < |
find all files in the current folder that end with ",txt" | find . -name "*,txt" |
Find a hostname that resolves to IP '173.194.33.71' | dig +short -x 173.194.33.71 |
extract archive stored in $1 | tar -zxvf $1 |
Print the list of the current directory's subdirectories | find . -maxdepth 1 -mindepth 1 -type d -printf '%f\n' |
Enables 'globstar' (recursive globbing) shell option. | shopt -s globstar |
Find files named "blabla" in the current directory tree and print the number of lines in each of them | find ./ -name "blabla" -exec wc -l {} ; |
Force create a symbolc link named "/usr/local/bin/fpt" to "/usr/local/bin/findpdftext" | sudo ln -s -f "/usr/local/bin/findpdftext" "/usr/local/bin/fpt" |
On host "server_b", connect as ssh user "user" and copy "/my_folder/my_file.xml" to directory "/my_new_folder/". | scp user@server_b:/my_folder/my_file.xml user@server_b:/my_new_folder/ |
Find all .txt files under the current directory and below | find -name \*.txt |
Copy "src/prog.js" and "images/icon.jpg" to "/tmp/package/" keeping relative path names | rsync -Rv src/prog.js images/icon.jpg /tmp/package/ |
list files found under the current directory ending in "txt" or ending in "html" | find . -name '*.txt' -o -name '*.html' |
set alias "prettyjson" for command 'python -m json.tool' | alias prettyjson='python -m json.tool' |
find all the normal/regular files in the folder "pathfolder" excluding all hidden files and display the count | find pathfolder -maxdepth 1 -type f -not -path '*/\.*' | wc -l |
Lists all files that matches path pattern with wildcards. | ls -l /lib*/ld-linux*.so.2 |
display all the regular/normal files in the folder /path/ which have not been modified today | find /path/ -type f -daystart -mtime +0 |
Find all regular files with space in their names under current directory and rename them by replacing all spaces with _ | find -name "* *" -type f | rename 's/ /_/g' |
Print a list of differing files | diff -q /dir1 /dir2|cut -f2 -d' ' |
Find all regular files in the "$dir" directory | find $dir -maxdepth 1 -type f |
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" . |
Display all symlinks and their targets in the current directory | find -P . -maxdepth 1 -type l -exec echo -n "{} -> " \; -exec readlink {} \; |
List the files in "archive.tar.gz" | gzip -l archive.tar.gz |
create a tar ball of all pdf files in current folder | find . -name *.pdf | xargs tar czvf /root/Desktop/evidence/pdf.tar |
display all the files in the home folder which begin with "arrow" and end with "xbm" | find ~ -name 'arrow*.xbm' |
Create a symbolic lnk named "$1/link" to "$dir" | ln -s "$dir" "$1/link" |
Save directory "../../lib" relative to the executable "gcc" to variable "libdir" | libdir=$(dirname $(dirname $(which gcc)))/lib |
Gets IP address of first network interface which name matches pattern "venet0:0\|eth0". | ifconfig | grep -A2 "venet0:0\|eth0" | grep 'inet addr:' | sed -r 's/.*inet addr:([^ ]+).*/\1/' | head -1 |
Find all the .c files in the current directory tree that contain the string ‘stdlib.h’ | find . -name ‘*.c’ | xargs egrep stdlib.h |
Read a line from standard input with prompt "Enter your choice: ", arrow keys enabled, and "yes" as the default input, and save the response to variable "choice" | read -e -i "yes" -p "Enter your choice: " choice |
Print the given file name's extensions. | echo "$NAME" | cut -d'.' -f2- |
Print 'empty' if aaa/ is an empty directory | [ -z "$" ] && echo "empty" |
search all the files in the current folder using name patterns | find . -name 'a(b*' -print |
create directory /path/to/destination | mkdir /path/to/destination |
Immediately terminate all processes whose command or arguments match "myProcessName" | ps -ef | grep myProcessName | grep -v grep | awk '{print $2}' | xargs kill -9 |
Delete all .svn files/directories under current directory | find . -name .svn -exec rm -rf '{}' \; |
Print list of disk and mountpoint of disks matching "/dev/sd*" into "mount_point" as a background task | mount | grep -i "/dev/sd.*" | awk '{ print NR "\t" $1 "\t" $3 }' > mount_output & |
List environment variable values whose name matches '^\w*X\w*' | set | grep -P '^\w*X\w*(?==)' | grep -oP '(?<==).*' |
Set variable 'vara' to 3 | source < |
Find all files under the current directory that are not the same file as "/home/nez/file.txt" | find . -maxdepth 1 -not -samefile /home/nez/file.txt |
Set timestamp of old_file.dat to specified timestamp. | touch -t 200510071138 old_file.dat |
Find all files starting from the current directory which are exactly 100MB in size | find . -size 100M |
Search for the regex "\$wp_version =" in all the regular files that end with '/wp-includes/version.php' in their paths in directories/files taken from the glob pattern '/var/www/vhosts/*/httpdocs' and show the matched lines along with the file names | find /var/www/vhosts/*/httpdocs -type f -iwholename "*/wp-includes/version.php" -exec grep -H "\$wp_version =" {} \; |
Find all the files in the current directory recursively whose permissions are 644 and show the first 10 of them | find . -perm 0644 | head |
Find all .txt files under the current directory and below | find . -name "*.txt" |
Enables 'dotglob' shell option. | shopt -s dotglob |
search in the home folder for all the files with the name "monfichier" | find /home/ -name monfichier |
List all *.c files in entire file system | find / \! -name "*.c" -print |
find all the swap files in the current folder and delete them | find . -name "*~" -delete |
List files in the current directory and below | find -ls |
Delete files in $DIR_TO_CLEAN that are older than $DAYS_TO_SAVE days | find "$DIR_TO_CLEAN" -mtime +$DAYS_TO_SAVE | while read FILE; do rm "$FILE"; done |
Find files/directories under current directory excluding the path ./src/emacs | find . -path ./src/emacs -prune -o -print |
Move all files matching patterns "*.old", ".old", ".*.old" from the current directory to directory "../old/" | find . ! -name . -prune -name '*.old' -exec mv {} ../old/ \; |
List all directories found in the current directory and below. | find . -type d |
Fetch a script from the web and interpert it in the current shell, without writing the script to disk. | source < |
Remove all files with names like "vmware-*.log" from the current directory tree | find . -name vmware-*.log | xargs -i rm -rf {} |
View contents of files matching "/usr/share/doc/mysql-server-5.0/changelog*.gz" in "less" | zcat /usr/share/doc/mysql-server-5.0/changelog*.gz | less |
Create a symbolic link in directory "~/newlinks" for each file listed in "results2.txt" | cat results2.txt | xargs -I{} ln -s {} ~/newlinks |
Search non-recursively directory tree `MyApp.app' for directories whose name is 'Headers' and delete them in an optimized way | find MyApp.app -name Headers -type d -prune -exec rm -rf {} + |
Search the current directory tree for files whose names end in "rb" or "js" and which contain string "matchNameHere" | find . -regextype posix-ergep -regex ".*(rb|js)$" -exec grep -l matchNameHere {} \; |
Counts lines of 'command' output. | command | wc -l |
find all the text files in the current folder | find . -name "*.txt" -print |
Print a hex dump byte to byte of the output of "echo Aa" | echo Aa | od -t x1 |
Search the files from the current directory tree for "chrome" | find . | xargs grep 'chrome' -ls |
Saves space separated content of $RAW_LOG_DIR in FILES variable | FILES=`cat $RAW_LOG_DIR | xargs -r` |
Resolve symbolic link of path of "python2.7" | readlink $(which python2.7) |
Perform a white space safe search for all files/directories under current directory | find . -print0 | xargs -0 |
find all the text files in the current folder | find . — name "*.txt" — print |
Search for the case insensitive pattern 'search for me' in all files with '.p', '.w' and '.i' extension under current directory tree without descending into '.svn' and 'pdv' directories | find . \( \( -name .svn -o -name pdv \) -type d -prune \) -o \( -name '*.[pwi]' -type f -exec grep -i -l "search for me" {} + \) |
Findx all files having text "texthere" recursively in a current folder, and prints only file names with matching strings. | find -type f -exec grep -l "texthere" {} + |
Recursively changes group ownership on everything in the 'public_html' folder to 'website' group. | chgrp --recursive website public_html |
Find all SGID set files in the file system | find / -perm /g=s |
same as above example with -exec , in this example with -OK it should ask for confirmation before executing the rm command . that is called user intractive command | find . -name core -ok rm {} \; |
Find all regular files named 'Waldo' under ~/Books directory tree | find ~/Books -type f -name Waldo |
Print the full name of "$USER" | finger $USER |head -n1 |cut -d : -f3 |
Find all the files in the current directory with “linkin park” in their names | find . -maxdepth 1 -iname "*linkin park*" |
find all normal/regular files in the entire file system having the word "filename" in their name. | find / -type f -iname "filename" |
Find all files under /path and below executable by `group' or `other' | find /path -perm /011 |
Find all regular files that reside in the current directory tree and were last modified more than 5 days ago | find . -type f -mtime +5 |
find directories under the $LOGDIR directory where there have been no modifications for 5 days and deletes them. | find $LOGDIR -type d -mtime +5 -exec rm -f {} \; |
Remove empty directories from the current directory tree | find . -depth -empty -type d -delete |
Print a NULL-separated list of all hidden regular files from the home directory | find $HOME -maxdepth 1 -type f -name '.*' -print0 |
Remove the files from the home directory tree that were last accessed more than 100 days ago, with confirmation | find ~/ -atime +100 -exec rm -i {} ; |
Find files/directories containing 'test' in their names and display the directory contents before the directories themselves | find -name "*test*" -depth |
Display differences between directories dir1 and dir2. | diff -r dir1/ dir2/ |
Find all files/directories under current directory | find | xargs |
find files in root directory that names are game | find / -name game |
Remove all files containing 'sample' in their names under '/home/user/Series' directory tree | find /home/user/Series/ -iname '*sample*' -exec rm {} \; |
display all scala files in the directory "src/main" | find . -type f -regex ".*src/main.*\.scala$" |
Find all *.mov files under current directory and list their paths with their names | find . -iname "*.mov" -printf "%p %f\n" |
Output all lines from file1 except those present in file2, assuming both files are sorted. | diff file2 file1 | grep '^>' | sed 's/^>\ //' |
Print numbers from 1 to 100 | seq 1 100 |
find all the files in the folder ./machbook and change the owner of them to the user with id "184" | find ./machbook -exec chown 184 {} \; |
Prints number of files with extension "${EXTENSION}" in the "${SEARCHPATH}" directory. | echo "Number files in SEARCH PATH with EXTENSION:" $ |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.