nl_command
stringlengths 14
387
| bash_code
stringlengths 0
532
|
---|---|
Creates temporary file name and saves path to it in 'TMP_FILE' variable. | TMP_FILE="$" |
Print the names and sizes of all regular files from the current directory tree | find . -type f -printf "%f %s\n" |
display all the regular/normal files in the /root folder which are bigger than 500MB | find /root -type f -size +500M -printf "The %p file is greater than 500MB\n" |
Rename "fghfilea" to "jklfilea" | mv fghfilea jklfilea |
Execute "mysqladmin -u root -pXXXXX processlist | grep tablename" every second and append output to "/root/plist.log" | watch -n 1 "mysqladmin -u root -pXXXXX processlist | grep tablename" | tee -a /root/plist.log |
Find all files/directories under current directory which have read-write permission for owner and only read permission for group and others | find -perm -644 |
display all the files in the current folder along with the modification time and display file names of the last 10 modified files | find . -type f -printf '%T@ %p\n' | sort -n | tail -10 | cut -f2- -d" " |
find all files with pattern` '*song*abc2009*.jpg' and replace "abc2009" with "def2010" | find . -name '*song*abc2009*.jpg' | sed 's/\(^.*song.*\)abc2009\(.*.jpg\)$/mv "&" "\1def2010\2"/' | sh |
Report available space on the file system containing /tmp in kilobytes. | df -k /tmp | tail -1 | awk '{print $4}' |
Find files with 002 permission in entire file system and print them with the string 'has world write permissions' printed at last | echo $ has world write permissions |
lines.txt contains a list of line numbers, one entry per line - output only these lines from text.txt omitting the rest of the file. | cat -n text.txt | join -o2.2 lines.txt - |
Create a symbolc link named "latest" to the last modified file or directory in "target-directory" | ln -s target-directory/`ls -rt target-directory | tail -n1` latest |
Archive all directories in /path/to/directory/* to files with .tar.gz extension transforming the full paths to relative paths | find /path/* -maxdepth 0 -type d -exec sudo tar -zcpvf {}.tar.gz {} \; |
find all the swap files in the current folder and delete them | find . -name "*~" -exec rm {} \; |
find all normal/regular files in current folder which end with "~" or which begin and end with "#" and and and delete them | find . -maxdepth 1 -type f -name '*~' -delete -or -name '#*#' -delete |
display a long list of all the jpg files in the home folder(plus at the end is used to give bulk data as input) | find ~ -iname '*.jpg' -exec ls {} + |
Removes all files from current folder but 3 newest ones | ls -tQ | tail -n+4 | xargs rm |
Page through both standard output and standard error of 'make'. | make 2>&1 | less |
set a crontab to create or update the timestamp of "washere2" in the current directory every 30 minutes. | echo "30 * * * * touch $(pwd)/washere2" | crontab |
Read a single character from standard input into variable "key" without backslash escapes and using an interactive shell with the prompt $'Are you sure (Y/n) : ' and default value $'Y' | read -rp $'Are you sure (Y/n) : ' -ei $'Y' key |
Find all files and directories in the current directory tree except those whose name is "dirname", case insensitive | find ./ -iname ! -iname dirname |
find all files in current folder which are more than 300MB | find . -size +300M |
Find all the .c files in the current directory tree that contain the string ‘stdlib.h’ | find . -name '*.c' | xargs grep 'stdlib.h' |
Make directories "a/b/c" as needed without causing an error if it exists | mkdir -p a/b/c |
find all jpg files in current folder | find . -type f -name "*.JPG" |
change the permissions of all the directories in the current folder, print0 is used for handling files with newlines in their file name | find . -type d -print0 | xargs -0 chmod 2775 |
Search for "pattern" in "file" and join each line by a space | cat file | grep pattern | paste -sd' ' |
Recursively change the owner of all files in "/home/test" to "test" | sudo chown -R test /home/test |
force remove all the c files in the current folder, print0 is used to handle all files with new lines in their names or files with only spaces in their name | find . -name "*.c" -print0 | xargs -0 rm -rf |
Find directories that are directly under $workspace_ts directory and were modified less than 30 days ago | find $workspace_ts -mindepth 1 -maxdepth 1 -type d -mtime -30 |
Gets IP address of 'eth0' network interface. | ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{print $1}' |
Represent the current time as seconds since epoch and save it to variable 'TODAY' | TODAY=$(date -d "$(date +%F)" +%s) |
change the owner of all the regular/normal files which belong to the root user to "tom" in the current folder | find .-type f -user root -exec chown tom {} \; |
Find all directories under /home/username/tmp and set their permission to 770 | find /home/username/tmp -type d -exec chmod 770 {} + |
Find all files under /path and calculate their md5sum | find /path -type f -print0 | xargs -0 md5sum |
Print a single line of numbers from "001" to "100" | yes | grep y | sed 100q | awk '{printf}'; echo |
Unsets array member with index 2. | unset array[2] |
change the group to "new_group" and permissions to 770 for all the files in the current folder | find . -name "*" -exec chgrp -v new_group '{}' \; -exec chmod -v 770 '{}' \; |
Recursively change owner to "tomcat6" of "webapps", "temp", "logs", "work", and "conf" | chown -R tomcat6 webapps temp logs work conf |
Saves path to the $SCRIPT file in the SCRIPTPATH variable. | set SCRIPTPATH=`dirname "$SCRIPT"` |
Find all symbolic links containg 'vim' in their names under '/usr/bin' directory tree | find /usr/bin -name '*vim*' -type l |
search in the current folder for the file "myletter.doc" | find . -name myletter.doc -print |
Find all regular files in the "$dir" directory | find $dir -maxdepth 1 -type f |
Write output of "sudo ls -hal /root/" to "/root/test.out" | sudo ls -hal /root/ | sudo tee /root/test.out > /dev/null |
display all regular/normal files in the folder /Users/david/Desktop/ | find /Users/david/Desktop/-type f |
Mount "tmpfs" filesystem to "/path/to/dir" | mount none -t tmpfs /path/to/dir |
list all files under the current directory called cookies.txt | find -name cookies.txt |
Search for the regex expanded by the variable $SEARCH in all regular files under $DIR directory tree | find "$DIR" -type f -exec grep -q "$SEARCH" {} + ; |
show all the files in the entire file system which are bigger than 100MB | find / -size +100M |
Change permissions of all files ending in ".php" under the current directory to 755 and print a '+' for each file | find . -name '*.php' -exec chmod 755 {} \; -exec echo '+' \; |
Delete all directories in the TBD directory that were modified more than 1 day ago | find /TBD -mtime +1 -type d | xargs rm -f -r |
list all the directories in the folder httpdocs | find httpdocs -type d |
Find users whose names begin with "ab" and ends with "1" | who | cut -d ' ' -f 1 | grep -e '^ab' -e '1$' |
find all the word press configuration php files in the folder /var/www | find /var/www/ -name wp-config.php |
Output two lines of "-tcp" | yes -- -tcp | head -n 2 |
Print file system disk space usage and grand total for the root file system with sizes in powers of 1000 | df -H --total / |
display the help of find command | find --help |
Print the name of "file1" if this file is newer than "file2" | find file1 -prune -newer file2 |
Remove newlines from the output of "./series.bc" and pipe into "sed 's.\\..g'" | ./series.bc | tr -d '\n' | sed 's.\\..g' |
change the permissions of all the directories in the current folder | find . -type d -exec chmod 2775 {} \; |
Remove files matching pattern '*-*x*.*' from the current directory tree | find -name '*-*x*.*' | xargs rm -f |
Select everything selected by * without descending into any directories | find * -maxdepth 0 |
Execute "myfile" on all regular files from the current directory tree | find . -type f -exec bash -c 'myfile "{}"' \; |
Calculate the sum of all the numbers from 1 to 10 | seq 10|jq -s add |
remove all the files in the folder "myfiiles" which have not been accessed in the last 30*24 hours | find /myfiles -atime +30 -exec rm {} ; |
Prints current directory name | pwd | sed 's#.*/##' |
In the current shell, interpret 'incl.sh' which is in the directory pointed by variable DIR | source "$DIR/incl.sh" |
display all regular/normal files which have been modified in the last 30 minutes | find -type f -and -mmin -30 |
Gets IP address of eth0 network interface. | ifconfig eth0 | grep addr: | awk '{ print $2 }' | cut -d: -f2 |
Display detailed usage help of the 'cp' (copy) command. | cp --help |
Print host name followed by ":" and the contents of "/sys/block/sda/size" | echo "$(hostname):$(cat /sys/block/sda/size)" |
Find all files under /mnt/naspath directory without descending into .snapshot directory that were modified in last 24 hours with null character as the delimiter | find /mnt/naspath -name .snapshot -prune -o \ |
Print a line of 10 '#' characters | seq -f "#" -s '' 10 |
Finds recursively all files in '/path/' that contain 'pattern', and prints matched strings with string number and file name. | grep -rnw '/path/' -e 'pattern' |
Runs 'tty' command in a subshell that is opened by built-in function 'true'. | true | echo `tty | sed 's:/dev/::'` |
Remove all files named tmp or ending in .xx that have not been accessed for seven or more 24-hour periods | find / \( -name tmp -o -name '*.xx' \) -atime +7 -exec rm {} \; |
Print numerically sorted list of unique strings from 'ip_addresses' file, with number of occurrences of each string. | sort -n ip_addresses.txt | uniq -c |
Extract any line in "fileA" which does not appear as the first word of any line in "fileB" | comm -23 < < |
Recursively search for everything under the current directory, displaying human-readable file type description for each entry. | find . -exec file {} \; |
change the permission of all the directories to 755 in the current folder | find -type d -exec chmod 755 {} \; |
Split "$1" into files of at most "$2" or default 10000 using a numeric suffix of length 6 and suffix "${tdir}/x" | split -l ${2:-10000} -d -a 6 "$1" "${tdir}/x" |
Write "2-1" to standard output and to "/sys/bus/usb/drivers/usb/unbind" | echo '2-1' |sudo tee /sys/bus/usb/drivers/usb/unbind |
Print a sorted list of regular files from directory tree /folder/of/stuff | find /folder/of/stuff -type f | sort |
Make directory "/etc/cron.15sec" | mkdir /etc/cron.15sec |
find all the files in the file system whcih have been modified in the last 1 day | find / -mtime -1 |
List all directories starting from root that have sticky bit set | find / -type d -perm -1000 -exec ls -ld {} \; 2> /dev/null |
Append "\r" on each line of file "input" and display the printable characters | sed 's/$/\r/g' input |od -c |
Disables shell option 'nullglob'. | shopt -u nullglob |
set alias "psgrep" for command "ps -ef | grep" | alias psgrep="ps -ef | grep" |
Print the file size and directory size in human readable format of the current directory tree 2 levels deep | tree --du -h -L 2 |
display the contents of all the files in the current folder which have the name "dummy" and discard all the errors while searching | find / -type f -name dummy 2>/dev/null -exec cat {} \; |
List all files under and below the directory given as variable $FULFILLMENT | find $FULFILLMENT -ls |
Report file systems disk space usage pretty formatted. | df -Ph | column -t |
Read a line from standard input and save each word in the bash array variable "first" | read -a first |
display all the text files from the current folder and skip searching in skipdir1 and skipdir2 folders | find . \ -print |
Find command will display top 5 small files from curent directory . most probably you will get ZERO bytes files . | find . -type f -exec ls -s {} \; sort -n |head -5 |
Print the paths of the directories from the paths expanded by the glob pattern /path/to/directory/* | find /path/to/directory/* -maxdepth 0 -type d |
Find all files on your system that are world writable | find / -wholename '/proc' -prune -o -type f -perm -0002 -exec ls -l {} \; |
Fiind and remove multiple files such as *.mp3 or *.txt | find . -type f -name "*.txt" -exec rm -f {} \; |
Find all *.py files/directories under current directory | find . -name \*.py -print |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.