nl_command
stringlengths 14
387
| bash_code
stringlengths 0
532
|
---|---|
display all regular/normal files in current folder | find . -type f |
Search for files/directories which are writable by both their owner and their group | find . -perm -g+w,u+w |
Print '-ok is an action so an implicit -print is not applied' with confirmation from the user for each file or directory found by the name 'file' under current directory tree | find -name file -ok echo '-ok is an action so an implicit -print is not applied' \; |
search for all the files which have not been modified in the last 6 months in current folder and display the total disk usage of them in MB | find ~/tmp -type f -mtime 0 -exec du -ks {} \; | cut -f1 | awk '{total=total+$1}END{print total/1024}' |
change the extension of all the ".abc" files in the folder "/the/path" to ".edefg" and do not change in the sub directories | find /the/path -depth -name "*.abc" -exec rename 's/\.abc$/.edefg/' {} + |
display all the files in the home folder which are smaller than 500 bytes | find ~ -size -500b |
Save the full path of command "~/f" to variable "foo" | foo=`which ~/f` |
Find all files/directories under $1 which have at least write permission for their owner and set write permission for group for these files/directories | find "$1" -perm -u+w -print0 | xargs chmod g+w |
Find *.java files under current directory and compress them to myfile.tar (unsafe) | find . -type f -name "*.java" | xargs tar cvf myfile.tar |
Print "hello" followed by the current user name | echo hello `whoami` |
Saves real path of the folder containing the current script | DIR=$(dirname "$(readlink -f \"$0\")") |
Mount the "linprocfs" filesystem on "/proc" | mount -t linprocfs none /proc |
Make directories "mnt" and "point" | mkdir mnt point |
delete all the files in the current folder which do not belong to any user | find . -nouser | xargs rm |
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 {} ; |
display all the directories in the folder /usr/share | find /usr/share -type d |
Cuts off last part from the path $dir, and deletes resulted folder if empty. | rmdir "$(dirname $dir)" |
change the permission of all php files in current folder | find . -name "*.php" -print0 -fprint > | xargs -0 chmod 755 |
find files in /tmp directory that named are core and deletes them | find /tmp -name core -type f -print | xargs /bin/rm -f |
Removes all files from current folder but 3 newest ones | ls -tQ | tail -n+4 | xargs rm |
Read a line of standard input with prompt "Enter your choice: " in an interactive shell and save the response to variable "choice" | read -e -p "Enter your choice: " choice |
Find all *.foo files under current directory and print their contents | cat $ |
Find all files in $dir directory without going into sub-directories | find "$dir" -maxdepth 1 -type f |
Format email message in file specified by "$2" to fit in 80 characters split at spaces and send to "$EMAIL" and a BCC to "[email protected]" from "$MAILBCC" with subject "$SUBJECT" | fold -s "$2" | mailx -s "$SUBJECT" -b "[email protected]" "$EMAIL" -r "$MAILBCC" |
Pipe the output of "program1" to both "program2" and "program3" | program1 | tee > > |
search all jpg files in current folder | find . -type f -name "*.jpg" |
Find all *.cpp files in the current directory tree that contain "sub" in their names | find . -name "*sub*.cpp" |
Find files named "AssemblyInfo.cs" in the current directory and below, and run "git diff" on them | find . -name "AssemblyInfo.cs" -print0 | xargs -0 git diff -- |
Find all the files which are accessed in last 1 hour | find / -amin -60 |
Recursively changes group ownership of everything within a current folder and having group 'X_GNAME' to 'Y_GNAME'. | find . -group X_GNAME -exec chgrp Y_GNAME {} + |
Print file size with the file name | find . -name '*.ear' -exec du -h {} \; |
Find recursively all regular files changed within the last 5 minutes starting from directory b | find b -type f -cmin -5 |
display all files in the current folder with the name test excluding those that are present in the sub folders of the test folder | find . -name test -prune |
Find all m? directories under current directory and run ./fixmbox with all of the directory paths as its arguments | find . -name 'm?' -type d -exec ./fixmbox {} + |
Copy all directories recursively from "source/" to "destination/" excluding all files | rsync -a --include='*/' --exclude='*' source/ destination/ |
Save the greater version number of "$1" and "$2" into variable "ver" | ver=`echo -ne "$1\n$2" |sort -Vr |head -n1` |
Removes 'latest' folder if empty. | rmdir latest |
Opens gcc info manual and goes to a node pointed by index entry "funroll-loops". | info gcc --index-search=funroll-loops |
Copy the entire "/lib" and "/usr" directory including symlinks from "[email protected]" to "$HOME/raspberrypi/rootfs" and delete files after the transfer | rsync -rl --delete-after --safe-links [email protected]:/{lib,usr} $HOME/raspberrypi/rootfs |
display all file names in current folder | find . -printf '%p ' |
Counts non-blank lines in all *.py files in a current folder. | grep -v '^\s*$' *.py | wc |
Archive "/source/backup" to "/destination" with compression during transfer | rsync -ravz /source/backup /destination |
Count the number of lines in each .java file in the current directory tree | find . -name "*.java" -exec wc -l {} \; |
change the group of all the files in the file system which belong to the group with the gid 999 | find / -group 999 -exec chgrp NEWGROUP {} \; |
Calculate the md5 sum of "a" | echo "a" | md5sum |
Find all Subscription.java files/directories under current directory and enter into the parent directory of the first one found | cd `find . -name Subscription.java | xargs dirname` |
Find all directories under dir whose names are 33 characters long | find dir -name '?????????????????????????????????' |
find all the files ending with "clj" in the current folder and search for a pattern | find . -name *.clj | xargs grep -r resources |
Find all files in the current directory tree whose pathnames match pattern "./sr*sc" | find . -path "./sr*sc" |
reverse input with comma deliminators | echo "a,b,c" | tr '\n' ',' | tac -s "," | sed 's/,$/\n/' |
Print the list of all files under the current directory and below | find . |
Find and delete all hard links in the /home directory to file1 | find /home -xdev -samefile file1 -print0 | xargs -0 rm |
Find all files named `file1' starting from / | find / -name file1 |
Find all files/directories that are not newer than Jul 01 by modification time | find /file/path ! -newermt "Jul 01" |
display all the files in the current folder. | find . |
Remove the "^M" characters from all *.ext files under /home directory | find /home -type f -name "*.ext" -exec sed -i -e "s/\x0D$//g" {} \; |
Find all *.rb files/directories under current directory | find . -name '*.rb' |
get a PID of a process with name 'test.sh &' | jobs -l | grep 'test.sh &' | grep -v grep | awk '{print $2}' |
display all the details of empty files in current folder | find . -size 0 -printf '%M %n %u %g %s %Tb\n \b%Td %Tk:%TM %p\n' |
Recursively change the owner and group of "/var/antoniod-data/" to "antoniod" | chown -R antoniod:antoniod /var/antoniod-data/ |
Returns 0 if user $1 belongs to group $2. | groups $1 | grep -q "\b$2\b" |
find non-hidden files that were are modified in the last 15 minutes. | find . -mmin -15 \ |
search for all the text files and display the long listing of these files from that directory | find . -name "*.txt" -execdir ls -la {} ";" |
find all *.java files/directories under current directory | find . -name \*.java |
Gets MAC addresses of all IP4 network interfaces. | ifconfig -a | awk '/^[a-z]/ { iface=$1; mac=$NF; next } /inet addr:/ { print mac }' | grep -o -E '{5}[[:xdigit:]]{1,2}' |
archive all the normal/regular files in the current directory which have been modified in the last 24 hours. | find . -mtime -1 -type f -exec tar rvf "$archive.tar" '{}' \; |
Search the current directory recursively for regular files with the read permission set for everybody | find -type f ! -perm -444 |
Prints strings with text "texthere" in all files recursively in a current folder. | grep -r "texthere" . |
Read a line from standard input with prompt "Are you sure you wish to continue?" | read -p "Are you sure you wish to continue?" |
Get the number of "use" statements in all PHP files, ordered | find . -type f -name "*.php" -exec grep --with-filename -c "^use " {} \; | sort -t ":" -k 2 -n -r |
replaces the last occurrence of 'a' with 'c' in file | tac file | sed '/a/ {s//c/; :loop; n; b loop}' | tac |
find all the files in current folder ending with "ini" and display all files which contain several patterns | find . -name *.ini -exec sh -c "grep -q PROJECT_A {} && grep -q CONFIG_A {} && echo {}" \; |
Remove containing directories from variable 'path' ie. "/some/specific/directory" becomes "directory". | path=$(basename $path) |
Display current system's kernel name, kernel release and version, and machine architecture | uname -srvm |
Globally sets the maximum number of lines to held in window history as 10000. | tmux set-option -g history-limit 10000 |
delete all the directories empty directories in the current folder | find . -type d -empty -delete |
Dump "testscript.sh" as 2 byte hexadecimale, printable characters, and octal values | od -xcb testscript.sh |
Dump the character output of "echo 'hi'" | echo 'hi' | od -c |
Show the list of directories in the /mnt/raid directory tree | find /mnt/raid -type d -print |
Force create a symbolic link without dereferencing named "alpha" to "alpha_2" | ln -nsf alpha_2 alpha |
Change permissions to 644 recursively only for files | find . -type f -exec chmod 644 {} \; |
Find all 400 permission files under /data directory | find /data -type f -perm 400 -print |
find the MyCProgram.c under the current directory and run the md5sum command against it | find -iname "MyCProgram.c" -exec md5sum {} \; |
Find all *.ogg (case insensitive) files/directories under your home directory that are greater than 20MB in size | find $HOME -iname '*.ogg' -size +20M |
Find all .js files in the current directory tree that do not contain a whitespace | find . -type f -name '*.js' \( -exec grep -q '[[:space:]]' {} \; -o -print \) |
Generate the Spanish alphabet and number each character | echo -e {{a..n},ñ,{o..z}}"\n" | nl |
Mount partition with label "WHITE" on "/mnt/WHITE" | mount -L WHITE /mnt/WHITE |
Find all *.pdf.marker files under ${INPUT_LOCATION} and move them to ${OUTPUT_LOCATION} also move any *.pdf files with the same name under current directory to ${OUTPUT_LOCATION} | find ${INPUT_LOCATION}/ -name "*.pdf.marker" | xargs -I file mv file $ ${OUTPUT_LOCATION}/. |
explicitly list all files in the current directory | find . -print |
Find apparent size of a target directory | du -hs /path/to/directory |
delete all the regular files in the temp folder which have not been modified in the last 24 hours | find /tmp/ -type f -mtime +1 -exec rm {} \; |
Find all *.rb files under current directory and count their line numbers ensuring white space safety on file name/path. | find . -name "*.rb" -type f -print0 | xargs -0 wc -l |
Gets IP address of 'en1' network interface. | ifconfig en1 | awk '{ print $2}' | grep -E -o "{3}[0-9]{1,3}" |
remove all the files in the current working directory which have a specifc inode number | find . -inum $inum -exec rm {} \; |
Delete all empty directories under current directory | find -type d -empty |
Enables 'nullglob' shell option. | shopt -s nullglob |
Create symlinks to all /home/folder1/*.txt files and 'folder1_' directory with the same name in a target directory named '+' | find /home/folder1/*.txt -type f -exec ln -s {} "folder1_" +\; |
Find all directories name nasa in the current directory and below. | find . -name nasa -type d |
Prints process tree for each process owned by user 'username'. | ps -aux | awk '/^username/{print $2}' | xargs pstree |
Lists all files in a current folder, separating names with comma. | ls | xargs -I {} echo {}, | xargs echo |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.