nl_command
stringlengths 14
387
| bash_code
stringlengths 0
532
|
---|---|
Find all *.zip files under current directory and unzip them in the same directory as the files | find . -name '*.zip' -exec sh -c 'unzip -d "`dirname \"{}\"`" "{}"' ';' |
Fetches the newest version of Homebrew and all formulae from GitHub and perform any necessary migrations. | brew update |
run script filename.sh as root with preserved user environment | su -cp filename.sh |
Find all *.txt files under current directory, change their permission to 666 and copy them to /dst/ directory | find . -name \*.txt -exec chmod 666 {} \; -exec cp {} /dst/ \; |
run script "runProgram.sh" as user jetty | su - jetty ./runprogram.sh |
Find all files/directories that contain 'packet' in their names excluding directories that are bigger than 1500 bytes in size | find . -iregex ".*packet.*" ! -type d -size +1500c |
Archive directory "tata" to directory "tata2", compressing data during copy. | rsync -avz tata/ tata2/ |
Find all *.page files/directories under current directory and run ~/t.sh for each of them with the file path as argument, then sort the output | find . -iname *.page -exec ~/t.sh {} \; | sort |
Print lines unique and common to sorted files "file1" and "file2" | comm file1 file2 |
Gets MAC address of 'eth0' network interface. | ifconfig eth0 | grep -o -E '{5}[[:xdigit:]]{1,2}' |
Creates temporary file in a TMPDIR folder with name like tmp.XXXXXXXXXX. | mktemp |
Find .java files in the current directory tree that contain 'TODO', and print their names | find . -name "*.java" -exec grep -Hin TODO {} + | basename `cut -d ":" -f 1` |
Find all regular files in minimum 1 level down the $dir directory | find "$dir" -mindepth 1 -type f |
Print out the full path name of "mypathname" with dots resolved | readlink -ev mypathname |
Move all files and directories in the current directory to "/foo" | mv `ls` /foo |
display all the files in the current folder which have colon in their name | find . -name "*:*" |
Find all directories under '/var/www' directory tree excluding '/var/www/web-release-data' and '/var/www/web-development-data' directories and their sub-directories | find /var/www -type d \( ! -wholename "/var/www/web-release-data/*" ! -wholename "/var/www/web-development-data/*" \) |
Creates temporary file, replacing XXXXXXXXXXXXXXXXXXXXXXX with equal length suffix. | mktemp /tmp/banana.XXXXXXXXXXXXXXXXXXXXXXX.mp3 |
Remove trailing white spaces and replace CRLF with LF in all files under current directory ignoring .git and .svn directories | find . -not \( -name .svn -prune -o -name .git -prune \) -type f -exec sed -i 's/[:space:]+$//' \{} \; -exec sed -i 's/\r\n$/\n/' \{} \; |
Change the timestamp of symbolic link "somesymlink" to current date/time | touch -h somesymlink |
Find all files/directories under current directory | find -print |
Print the cp commands that would be required to copy all *.data files under /source_path to /target_path by appending the parent directory names in the source paths to the beginning of each of the target file names | find /source_path -name \*.data | while read -r filename; do printf "print version: cp %s %s\n" "${filename}" "$(printf "%s\n" "${filename}" | sed "s/^.*[/]\[/]\$/\/target_path\/\1_\2/")"; done |
display all the files in current folder which are bigger than 10KB | find . -size +10k |
Prints long listing of the current directory, sorted from oldest to newest, with appended indicators. | $ ls -Fltr |
Find all directories in /path/to/dir/ without going into sub-directories | find /path/to/dir/ -mindepth 1 -maxdepth 1 -type d |
find all jpg files in the folder which are in the path "/201111/" and sort them based on name | find */201111/* -name "*.jpg" | sort -t '_' -nk2 |
Recursively finds all files and prints only names of files that contain "word" and suppressing error messages . | find . | xargs grep 'word' -sl |
display all the files in the entire file system | find / -name "*" — print |
find all the files that have been changed exactly 24 hours ago | find . -ctime 1 -type f |
find all the files in the current directory whose size is equal to exactly 126MB. | find . -size 126M |
Assigns MAC address 00:80:48:BA:d1:30 to interface eth0. | ifconfig eth0 hw ether 00:80:48:BA:d1:30 |
Search the /path directory tree for files missing g+w and o+w bits | find /path ! -perm /022 |
Print the current directory tree with file sizes | tree -s |
Find all files under current directory and set read-write permission for owner and group and no permission for other for those directories | find . -type f -exec chmod ug=rw,o= {} \; |
Search the current directory tree for all files except SVN ones | find . -not -iwholename '*.svn*' |
Make directories "$@" and replace "mkdir: created directory " with "$USER created folder " in the output | mkdir "$@" |sed -e"s/mkdir: created directory /$USER created folder /" |
prints a number stored among text in $filename | echo $filename | egrep -o '[[:digit:]]{5}' | head -n1 |
Save "something" into variable "param" in ksh | echo something | read param |
Display operating system type, ie. GNU/Linux | uname -o |
Make directory "~/temp" | mkdir ~/temp |
Change permissions to 755 for all directories in the /path/to/dir directory tree | find /path/to/dir -type d -exec chmod 755 {} \; |
tar all files in the current folder and ask for user confirmation before creating the tar ball | find . -ok tar rvf backup {} \; |
find files which have all permissions to all the users in the current directory | find . -type f -perm 0777 -print |
Calculate the total disk usage for each ".jpg" file on the system and prepend the system host name to the output | find "$PWD" / -iname '*.jpg' -exec du -s {} + | sed "s/^/$(hostname): /" |
Find all files starting from / that belong to user1 | find / -user user1 |
Delete files with inode number specified by [inode-number] under current directory | find . -inum [inode-number] -exec rm -i {} \; |
Find and delete all files with a used disk size of 0 | rm `du * | awk '$1 == "0" {print $2}'` |
display top 11 files along with the last access date for all the files in the file system | find / -type f -printf "\n%AD %AT %p" | head -n 11 |
Search in the current directory and all sub-directories except ./D and any further sub-directories also named D for the file named hi.dat | $ find . \ -o -name hi.dat |
search for all the files in the folder /home which have sticky bit set and have the permissions 553 | find /home -perm 1553 |
Find all files/directories under minimum 2 level down the current directory and set their permission to 700 | find . -mindepth 2 | xargs chmod 700 |
Save the last modified time of file 'file_name' to variable 'STAMP' | STAMP=`date -r file_name` |
Move all files matching patterns "*.old", ".old", ".*.old" from the current directory to directory "../old/" | find . ! -name . -prune -name '*.old' -exec mv {} ../old/ \; |
show all the directories in the current folder | find . -type d |
Merge content of decompressed files "$part0", "$part1", and so on | sort -m < < ... |
Calculate the md5sum of each ".py" file under "/path/to/dir/", sort the output, and calculate the md5sum of that | find /path/to/dir/ -type f -name "*.py" -exec md5sum {} + | awk '{print $1}' | sort | md5sum |
Create a symbolic link in the current directory to "$file" | ln -s "$file" |
Replace all occurrences of word "foo" with "bar" in *.c and *.h files from the current directory tree | find -name '*.[ch]' -exec sed -i 's/\<foo\>/bar/g' {} + |
For each line in list.txt, output the line adding "FAIL" if the same line appears in fail.txt, and "PASS" otherwise - lines in fail.txt must be in the same order as they appear in list.txt. | sed 's/$/ FAIL/' fail.txt | join -a 1 -e PASS -j 1 -o 1.1,2.2 list.txt - |
Count the number of users logged in | who | wc -l |
Display human-readable file type description of ascii.txt | file ascii.txt |
copy the entire contents of the current directory to another directory, while preserving the permissions, times, and ownership of every file and sub-directory | find . | cpio -pdumv /path/to/destination/dir |
Copy the directory hierarchy from "original" to "new" | find original -type d -exec mkdir new/{} \; |
Fint all *.txt files/directories in entire file system without descending to other file system and without error reporting | find / -name "*.txt" -xdev 2> /dev/null |
Find all '*~' files under current directory | find ./ -name '*~' |
Execute "wget -qO- http://fake.link/file.txt" every 5 seconds | watch -n 5 wget -qO- http://fake.link/file.txt |
find regular files whose filename is "your_pattern", suppressing all error messages. | find / -type f -name "your_pattern" 2>/dev/null |
find files which full path name is foo/bar under foo directory and print | find foo -path foo/bar -print |
Search for "#define" in all files in the current directory, excluding backup files *~, *.orig, *.bak | find . -maxdepth 1 ! -regex '.*~$' ! -regex '.*\.orig$' \ ! -regex '.*\.bak$' -exec grep --color "#define" {} + |
Search in current directory downwards all files whic have permission 777 . | find . -perm 777 -print |
Find all directories under and below directory "folder_name", and change their permissions to 775 | find folder_name -type d -exec chmod 775 ‘{}’ \; |
Truncate all non-empty regular files under the current directory | find . -type f -maxdepth 1 -not -empty -print0 | xargs -0i cp /dev/null {} |
delete recursively, without prompting, any files or directories under the current directory that case insensitively match the filename ".svn" | find . -iname .svn -print0 | xargs -0 rm -rf |
change cgi files to mode 755 | find htdocs cgi-bin -name "*.cgi" -type f -exec chmod 755 {} \; |
Find all directories under /path/to/base/dir and change their permission to 755 | find /path/to/base/dir -type d -print0 | xargs -0 chmod 755 |
find regular file named foo.txt under root / directory. | find / -name foo.txt -type f -print |
find all files in the current folder which are of size 0 bytes. | find . -type f -empty |
Save a comma separated list of all $MY_DIRECTORY/*/ directories to variable 'FOLDER' | FOLDERS=`ls -dm $MY_DIRECTORY/*/ | tr -d ' '` |
Search for "pattern" in "file" and separate each line with '" "' | cat file | grep pattern | paste -sd'~' | sed -e 's/~/" "/g' |
display long listing of all the regular hidden files in the folder Musica | find Música/* -type f -name ".*" -exec ls -l {} \; |
Find all .java files under and below the current directory | find . -name '*.java' |
display all the home folder which end with the extension "sxw" and which have been accessed in the last 3*24 hours and which belong to the user bruno | find /home -type f -name "*.sxw" -atime -3 -user bruno |
Save the md5 sum hash of "${my_iso_file}" to variable "md5" | md5=`md5sum ${my_iso_file} | awk '{ print $1 }'` |
display all the normal/regular files in the current folder | find . -type f |
Recursively copy "dir_b" to "dir_a" and delete any new files in "dir_a" | rsync -u -r --delete dir_b dir_a |
Force create a symbolic link named "currentDir" to "newDir" without dereferencing "currentDir" | ln -sfn newDir currentDir |
remove all text files from the current folder | find -name "*.txt" | xargs rm |
Saves listing of a current folder in 'var' variable. | var=$ |
Count the number of files/directories with '.php' extension under current directory tree and change the permissions to 755 | find . -name "*.php" -exec chmod 755 {} \; -exec /bin/echo {} \; | wc -l |
Copy a file xyz.c to all the .c files present in the C directory and below | find ./C -name "*.c" | xargs -n1 cp xyz.c |
Sort file.txt ignoring the last 10 characters of each line. | sort file.txt | rev | uniq -f 10 | rev |
find all the regular/normal files in the current folder which belong to the user "sedlav" | find . -user sedlav -type f |
Show files in /home owned by group `test' | find /home -group test |
List all files under current directory matching the regex '.*\' | find . -type f -regex '.*\' -exec ls {} \; |
Search for files/directories with the case insensitive pattern anaconda.* in var/log directory and create an archive of all the files found | find var/log/ -iname "anaconda.*" -exec tar -rvf file.tar {} \; |
List all files/directories in entire file system | find / -print |
display a list of all the normal/regular files in the file system ,excluding the folder proc which have the suid or sgid bit set | find / -path /proc -prune -o -type f -perm +6000 -ls |
Search the current directory tree for files whose name is ".note", case insensitive | find . -iname '.note' |
Remove all *.sql files in the $backup_path directory that were last modified more than 5 days ago | find $backup_path/*.sql -mtime +5 -exec rm -f {} \; |
display all the directories in the current folder excluding those that are present in the aa directory tree | find . -type d -name aa -prune |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.