nl_command
stringlengths 14
387
| bash_code
stringlengths 0
532
|
---|---|
Search in current directory downwards all files whose owner is aa1 and grop is grp . | find . \ -print |
List all regular files in the current directory tree that were modified less than 60 minutes ago | find . -mmin -60 -type f -exec ls -l {} + |
Sort and compare files "$def.out" and "$def-new.out" | diff <(sort $def.out) <(sort $def-new.out) |
search for the file "foobar.txt" in the folder "/home/mywebsite" | find /home/mywebsite -type f -name "foobar.txt" |
Will run checksums recursively from the current directory, and give back grouped filenames of all identical checksum results. | find ./ -type f -print0 | xargs -0 -n1 md5sum | sort -k 1,32 | uniq -w 32 -d --all-repeated=separate | sed -e 's/^[0-9a-f]*\ *//;' |
delete all the log files in the current folder | find ./ -name '*.log' | xargs rm |
Recursively change the owner and group of all files in the current directory to "apache" | ls | xargs chown -R apache:apache |
Make a POST request to "http://dweet.io/dweet/for/cycy42" with data "PiIP" set to the IP address of the system | wget --post-data="PiIP=$" http://dweet.io/dweet/for/cycy42 |
Find all files under /usr/tom that matches the extended regex '*.pl| *.pm' in their names and also matches the regex <PATTERN> in their contents | find /usr/tom | egrep '*.pl| *.pm' | xargs cat | grep <PATTERN> |
Recursively change the owner to "${JBOSS_USER}" of "$JBOSS_LOG_DIR" | chown -R ${JBOSS_USER}: $JBOSS_LOG_DIR |
Make directories and parent directories as needed of "$1" with "\r" removed | mkdir -p $(echo -e $1 |sed $'s/\r//') |
Removes empty folder 'symlink'. | rm -d symlink |
Delete characters in columns 36 through 40 from the output of "finger" | finger | sed 's/\(.\{35\}\)...../\1/' |
Removes all empty folders under '/path/to/the/folder' path. | find /path/to/the/folder -depth -type d -print0 | xargs -0 rmdir |
Find files with extension .conf in the /etc directory tree | find /etc -name "*.conf" |
find all the directories in the home folder do not search in sub directories | find /home -maxdepth 1 -type d |
List .log files from the current directory tree | find . -name "*.log" -exec echo {} \; |
Find files in the current directory tree whose names match regular expression "^.*~$\|^.*#$" | find -regex "^.*~$\|^.*#$" |
Returns exit status 0. | foo=$(false)$(true) |
Compress all files under current directory tree with gzip | find . -type f -print0 | xargs -0r gzip |
update the permission of all the files in the folder /u/netinst to 500 | find /u/netinst -print | xargs chmod 500 |
Find all files/directories named 'findcommandexamples.txt' in the entire filesystem | find / -iname findcommandexamples.txt |
Print the real path of "$F" where each symbolic link component must exist | echo "$(dirname $(readlink -e $F))/$(basename $F)" |
Print common characters in variable "$a" and "$b" | comm -12 <(echo $a|awk -F"\0" '{for (i=1; i<=NF; i++) print $i}') <(echo $b|awk -F"\0" '{for (i=1; i<=NF; i++) print $i}')|tr -d '\n' |
Save number of lines with any-cased 'merge' from $COMMIT_EDITMSG file in 'MERGE' variable | MERGE=$ |
Find files under current directory that contains the string '/bin/ksh' | find . -type f -print | xargs grep -il 'bin/ksh' |
Find file `Chapter1' on the system | find / -name Chapter1 -type f -print |
Save the short host name appended with ".mysqldb" in variable "DBPREFIX" | DBPREFIX="$(hostname -s).mysqldb" |
find all the error, access, ssl_engine and rewrite logs which are bigger than 300MB and are less then 5GB in the folder /opt | find /opt \ -size +300000k -a -size -5000000k |
Find all files/directories that contain the string literal '`$VERSION`' in their names under current directory tree | find . -name '*`$VERSION`*' |
search all the files in the folder "myfiles" which have the word "blue" in their name | find /myfiles -name '*blue*' |
Find recursively the latest modified file in the current directory | find . -type f | xargs ls -ltr | tail -n 1 |
Add variable 'v' with value '5' to a temporary environment, list this environment using 'less' to interactively view it. | v=5 env|less |
Print each character in "Hello" as a hexadecimal value | echo -n "Hello" | od -A n -t x1 |
Save the directory name of the canonical path to the current script in variable "MY_DIR" | MY_DIR=$(dirname $(readlink -f $0)) |
Move files from $sourcePath to $destPath that have not been modified in the last 10 days | find $sourcePath -type f -mtime +10 -name "*.log" -exec mv {} $destPath \; |
display all the regular files in the current folder and do not search in sub folders | find "$dir" -maxdepth 1 -type f |
Convert Unix `cal` output to latex table code. | cal | sed '1d;2{h;s/./ /g;x};/^\s*$/b;G;s/\n/ /;s/^...\(.\{15\}\).*/\1/;s/.../ &\t\&/g;s/\&$/\\\\/' |
Remove the file with inode number 752010 | find -inum 752010 -exec rm {} \; |
Calculate the md5 sum of "exampleString" | echo -n 'exampleString' | md5sum |
Create symbolic link "$1/link" to the absolute path of "$2" | ln -s "$(readlink -e "$2")" "$1/link" |
Print the path to all *.so files under current directory and search for mysymbol in their symbol tables | find . -type f -print -exec sh -c "readelf -s {} | grep mysymbol" \; |
Recursively counts non-blank lines in all files in a current folder, that match regex '\.php|\.as|\.sql|\.css|\.js', but skip folders './pma', './blog', './punbb', './js/3rdparty' and files like '*.svn'. | find . -path './pma' -prune -o -path './blog' -prune -o -path './punbb' -prune -o -path './js/3rdparty' -prune -o -print | egrep '\.php|\.as|\.sql|\.css|\.js' | grep -v '\.svn' | xargs cat | sed '/^\s*$/d' | wc -l |
Find all files/directories not with the name 'query_to_avoid' under current directory | find \! -name "query_to_avoid" |
Gets MAC address of p2p0 network interface. | ifconfig p2p0 | grep -o -E '{5}[[:xdigit:]]{1,2}' |
Find recursively all regular files changed within the last 5 minutes starting from directory b | find b -type f -cmin -5 |
display all the ip addresses in all the files that are present in /etc folder | find /etc -type f -exec cat '{}' \; | tr -c '.[:digit:]' '\n' | grep '^[^.][^.]*\.[^.][^.]*\.[^.][^.]*\.[^.][^.]*$' |
Forcibly create symlink named as '/cygdrive/c/Users/Mic/mypics' to the directory '/cygdrive/c/Users/Mic/Desktop/PENDING - Pics/' | ln -sf '/cygdrive/c/Users/Mic/Desktop/PENDING - Pics/' '/cygdrive/c/Users/Mic/mypics' |
Search all files in the current directory tree, except GIT files, for "string-to-search" | find . -name .git -prune -o -print | xargs grep "string-to-search" |
Save the md5 sum of $twofish to variable 'twofish' | twofish=`echo -n $twofish | md5sum | tr -d " -"` |
Create 6-letter named temporary directory in a folder path that is provided as the first positional parameter, and save the path to it in a variable 'tmp' | tmp=$(mktemp -d $/XXXXXX) |
returns the first 100 bytes in the file | head -c 100 file |
Grab the output of "basename" and echo it to stdout, which basename would do by default anyway. | echo $ |
Print file names of all files ending with '*.csv' in '/home/ABC/files/' directory | ls /home/ABC/files/*.csv | rev | cut -d/ -f1 | rev |
Exit the shell on the first error encountered | set -o errexit |
Create compressed archive from "my_large_file_1" and "my_large_file_2" and split into files of size 1024 MiB with prefix "myfiles_split.tgz_" | tar cz my_large_file_1 my_large_file_2 | split -b 1024MiB - myfiles_split.tgz_ |
Change ownership of "/data/db" to the current user | sudo chown `whoami` /data/db |
Find all files/directories under current directory with a Depth-First search | find dir -depth |
Search all of /usr for any directory named 'My Files', for each directory found, copy it to /iscsi preserving full paths and attributes. | find /usr -type d -name My\ Files -exec rsync -avR '{}' /iscsi \; |
Move all *.log files under $sourcePath that were modified more than 10 days ago to a zip archive $zipFile with only file names | find $sourcePath -type f -mtime +10 -name "*.log" | xargs zip -jmT $zipFile -@ |
Append all regular files modified in the last 24 hours to the "$archive.tar" tar archive | find . -mtime -1 -type f -print0 | xargs -0 tar rvf "$archive.tar" |
Change to folder where the oracle binary is. | cd "$(dirname "$")" |
Find all files/directories under current directory | find -print |
search all jpg images in current folder and rename them | find . -type f -name "*.jpg" -print0 | xargs -0 rename "s/Image_200x200_(\d{3})/img/" |
Print user and group information of all users logged in | who | awk '{print $1}' | xargs -n 1 id |
find all the text files in the folder /home/calvin and do not search beyond 2 levels | find /home/calvin/ -maxdepth 2 -name “*.txt” |
Compress all files with '.txt' extension under current directory | echo *.txt | xargs gzip -9 |
List ".java" files that have the same contents | md5sum *.java | sort | uniq -d -w32 |
Run 'join' on file1 and file2, using a literal tab character as field separator. | join -t $'\t' file1 file2 |
show all files in the current directory and all subdirectories | find . -print |
Find all files/directories under current directory that were accessed 30 minutes ago | find -amin 30 |
search for the file "process.txt" in the entire file system | find / -iname 'process.txt' -print |
List the largest file in long list format of all the files under the current directory | find . -type f -ls | sort -nrk7 | head -1 #unformatted |
search all the ".sh" files in the /usr folder and follow the symbolic links to their original file | find /usr -follow -name '*.sh' |
find all tools generated files a.out , *.o and core dump files which not required to us these all junk files & delete from current directory . | find . \( -name a.out -o -name '*.' -o -name 'core' \) -exec rm {} \; |
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 |
Recursively finds all files and prints all strings with 'text-to-find-here' from that files, preceding matched string with filename. | find ./ -type f -exec grep -H 'text-to-find-here' {} \; |
Find all TXT files in the current directory and copy them to directory "$HOME/newdir" | find "$HOME" -name '*.txt' -type f -print0 | sort -zu | xargs -0 cp -t "$HOME/newdir" |
Saves invoked command 'check_script_call=$(history |tail -1|grep myscript.sh )' in variable 'check_script_call', preceeding by its number in history. | check_script_call=$(history |tail -1|grep myscript.sh ) |
Gets IP addresses of all active network interfaces and saves to 'ip' variable. | ip=$(ifconfig | grep -oP "(?<=inet addr:).*?(?=Bcast)") |
Find directories named `doc' in /usr and below | find /usr -name doc -type d |
Enable history expansion in a script | set -H |
Recursively add ".jpg" to all files in the current directory tree | find . -type f -exec mv '{}' '{}'.jpg \; |
Removes first and last parts of path $path and saves the result in 'finalName' variable. | finalName=$(dirname ${path#*/}) |
Find all files in and below all subdirectories of the current directory | find . -mindepth 2 |
Report file systems disk usage in kilobytes. | df -k |
Create a symbolic link in the current directory to "$file" | ln -s "$file" |
search all mp3 files in the folder "/home/you" which have been modified yesterday | find /home/you -iname "*.mp3" -daystart -type f -mtime 1 |
Recursively copies "$1" to "$2". | cp -R "$1" "$2" |
Merge lines from "file_1" and "file_2" and format the output as a table with tab separators | paste file_1 file_2 | column -s $'\t' -t |
search for files which are writable by either their owner or their group | find . -perm /u+w,g+w |
find all the perl files in the current folder and search for a pattern | find . -name '*.pl' | xargs grep -L '^use strict' |
Make directories "mnt" and "point" | mkdir mnt point |
update the permission of all the php files in current directory and save the output to a file | find . -name '*.php' -exec chmod 755 {} \; | tee logfile.txt |
display all normal/regular files in current directory | find . -type f |
Saves bytes count of the value of '$each' variable. | a=$(echo $each | wc -c) |
Find all files in $dir directory without going into sub-directories | find "$dir" -maxdepth 1 -type f |
Removes all files from current folder but 5 newest ones. | rm `ls -t | awk 'NR>5'` |
Create a symbolic link to "$file" named "/tmp/allfiles" | ln $file /tmp/allfiles |
Find all files that belongs to group 'root' under / directory and show a few lines of output from the beginning | find / -group root | head |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.