nl_command
stringlengths 14
387
| bash_code
stringlengths 0
532
|
---|---|
Move all files/directories under current directory to ~/play | find . -exec mv '{}' ~/play/ \; |
Search for files/directories which are writable by both their owner and their group | find . -perm -220 |
List all files/directories under current directory using comma (,) as the delimiter for different fields in the output | find . -ls|awk 'BEGIN{OFS=","}$1=$1' |
Remove `core' files whose status was changed more than 4 days ago | find `pwd` -name core -ctime +4 -execdir /bin/rm -f {} \; |
find all the files in the entire file system that have been accessed exactly 50 days ago | find / -atime 50 |
Pipe an empty line to ssh-keygen. | printf "" | ssh-keygen -b 1024 -f ball -t dsa |
display all files in current folder which have been modified in the last 60 minutes | find -mmin 60 |
find regular files under the current directory, whose name ends in .mbox, piping the output to the GNU Parallel command that will rename each file to not have a file extension. | find . -type f -wholename \*.mbox | parallel mv {} {.} |
Decompress and extract '/usr/src/redhat/SOURCES/source-one.tar.gz' | gzip -dc /usr/src/redhat/SOURCES/source-one.tar.gz | tar -xvvf - |
Search for files greater than 20MB under your home directory (/home/user) | find ~ -size +20M |
Find all files in maximum 1 level down the current directory that were modified less than 1 day ago from today | find -maxdepth 1 -type f -daystart -mtime -1 |
Display all lines contained in 'dax-weekly.csv' in reverse order. | cat dax-weekly.csv | awk '{a[i++]=$0} END {for print a[j--] }' |
Find files by type | find -type type_descriptor |
Search *.txt files under and below /directory/containing/files for "pattern_to_search" | find /directory/containing/files -type f -name "*.txt" -exec grep -H 'pattern_to_search' {} + |
Assign the alias rm100m to a find command that removes any .tar file larger than 100M. | alias rm100m="find / -type f -name *.tar -size +100M -exec rm -i {} \;" |
Locate all files named 'restore.php' in the current directory and 3 levels below | find . -maxdepth 4 -name 'restore.php' |
Search for files/directories with the case insensitive pattern anaconda.* in /var/log directory and create an archive of the last file found | find /var/log/ -iname anaconda.* -exec tar -cvf file.tar {} \; |
Find all .gz archives in the current directory tree | find . -name '*.gz' |
Find text in whole directory tree | find . -type f | xargs grep "text" |
Replace all commas with tab characters in 'filename.csv' and page interactively through the result. | sed "s/,/\t/g" filename.csv | less |
Search for the string 'git' in all the files under current directory tree excluding paths and names that contain the string 'git' | find . -not -path "*git*" -not -name '*git*' |grep git |
find all files in home folder which have been modified after a timestamp | find ~ -newer /tmp/timestamp |
Print count of unique lines in all files like 'list_part*' | cat list_part* | sort --unique | wc -l |
List an empty environment | env -i |
Move all regular files under current directory to ./newdir | find ./ -type f -print | xargs -i mv -f {} ./newdir |
Find all files/directories with space in their names under $1 directory | find $1 -name '* *' |
Extract any line in sorted file "A" that does not appear in "B", "C", or "D" | cat B C D | sort | comm -2 -3 A - |
Print content of 'a' file, showing all non-printing characters including TAB characters, and displaying $ at the end of each line. | cat -vet a |
Recursively search for all files with names ending with "_test.rb", renaming them to end with "_spec.rb", using at most 4 concurrent processes. | find . -name "*_test.rb" | xargs -P 4 rename s/_test/_spec/ |
Split "date.csv" into files with at most 100 lines each | split -l 100 date.csv |
Print file size and user name with color support for each file in the current directory tree | tree -Csu |
Find all files with '.txt' extension under $dir directory non-recursively and sort them numerically | find "$dir" -maxdepth 1 -type f -iname '*.txt' | sort -n |
Display long listing of all the files/directories owned by the user 'me' under '/tmp' directory tree | find /tmp -user me -ls |
display all the java script files in a folder | find src/js -name '*.js' |
Find links that point to nothing To find links that point to nothing, use the perl interpreter with find, like this: | find / -type l -print | perl -nle '-e || print'; |
find all the empty in the current folder do not search in sub directories | find . -maxdepth 1 -type d -empty |
Recursively find all files in the directory "posns" and split each one into files of at most 10000 lines each | find posns -type f -exec split -l 10000 {} \; |
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 |
Find all empty directories under $somedir and copy /my/configfile into those directories | find "$somedir" -type d -empty -exec cp /my/configfile {} \; |
Create a bzip2 archive of all .txt files from the "dir" directory tree | find dir/ -name '*.txt' | tar -c --files-from=- | bzip2 > dir_txt.tar.bz2 |
locate large files (> 100 MB) in /home/ for 'cleaning' | find /home -type f -size +100M -print0 |xargs -0 rm |
Count the number of lines in each .java file in the current directory tree | find . -name "*.java" -exec wc -l {} \; |
Find all files under /home/username/public_html/sites/default/files and set their permission to 660 | find /home/username/public_html/sites/default/files -type f -exec chmod 660 {} + |
Mount "nifs" filesystem "/dev/mapper/myldm" on "/mnt" as read only | mount -t ntfs -o ro /dev/mapper/myldm /mnt |
List all files in the /myfiles directory tree | find /myfiles -exec ls -l {} ; |
Search for files in the current user's home directory and below for files that have not been accessed for more than 100 days and ask the user for permission to delete each file, one by one. | find ~/ -atime +100 -exec rm -i {} \; |
change owner of the file file.sh to user root | $sudo chown root file.sh |
Copies file 'fileName.txt' to each of directories listed in the 'allFolders.txt' list. | cat allFolders.txt | xargs -n 1 cp fileName.txt |
find the path of a specfic video file in the current directory | find ./ -name "foo.mp4" -printf "%h\n" |
Move all files from "src/test/" to "dest" displaying progress | rsync -a --progress --remove-source-files src/test/ dest |
Write standard output and error to the console and append to file "log" | ./aaa.sh 2>&1 | tee -a log |
Remove the "123_" prefix from all filenames of .txt files in current directory. | rename 's/^123_//' *.txt |
Disables overwriting existing files | set -o noclobber |
Find all .txt files of user Tecmint under /home directory | find /home -user tecmint -iname "*.txt" |
Find & calculate total number of caractor in all .txt file from current directory | find . -type f -name '*.txt' -exec wc -c {} \; | awk '{total += $1} END{print total}' |
Export variable "JAVA_HOME" as symlink resolved absolute path of "/usr/bin/javac" with "/bin/javac" removed | export JAVA_HOME=$ |
Installs all packages from a current folder, excluding ones that match pattern '*glob*'. | yum install --exclude='*glob*' *.rpm |
Find files larger than 100MB in /var/www and exclude files with /download/ in their path from the output | find /var/www/ -type f -name "*" -size +100M -exec du -h '{}' \;|grep -v /download/ |
Recursively removes all files like '*.pyc' in a current folder. | rm **/*.pyc |
Print "This is a sentence." by replacing all consecutive space characters with a single newline character | echo "This is a sentence." | tr -s " " "\012" |
find all the files in the entire file system that start with the word top and have 3 letters next to it. | find / -name 'top???' |
Merge already sorted files "file*.txt" and split the result into files of at most 100000 lines each with a prefix "sorted_file" | sort --merge file*.txt | split -l 100000 - sorted_file |
Use the uncompressed contents of "blah.gz" as input to "some_command" | cat blah.gz | gunzip | some_command |
Find all files/directories in directories/files taken from the glob pattern '/folder/path/*' recursively that have not been modified in the last 2 hours and delete them | find /folder/path/* -mmin +120 -delete |
Search directory trees /usr/local/man and /opt/local/man for files whose names begin with 'my' | find /usr/local/man /opt/local/man -name 'my*' |
find all posix-extended regex "[a-f0-9\-]\{36\}\.jpg" files | find . -regextype posix-extended -regex "[a-f0-9\-]\{36\}\.jpg" |
find all the regular/normal files in the current folder and rename them to html files | find main-directory -type f -exec mv -v '{}' '{}'.html \; |
Set the executable bit for all users on all .sh scripts from directory trees lib, etc, debian | find lib etc debian -name "*.sh" -type f | xargs chmod +x |
Copy all .png files from the home directory tree to imagesdir/ | find ~/ -name *.png -exec cp {} imagesdir \; |
Find all *.tex regular files under current directory | find . -type f -name "*.tex" |
display all scala files in the directory "src/main" | find . -path "*src/main*" -type f -iname "*\.scala*" |
Save 'echo whatever you "want your" command to be' in history | history -s 'echo whatever you "want your" command to be' |
Compress "Hello world", base64 encode, and save to variable "FOO" | FOO=$ |
Use 'less' to nicely display control characters from the outupt of 'grep'. | grep -b -o $'\x0c' filename | less |
Lists '/tmp/hashmap.$1' file or folder '/tmp/hashmap.$1' content one file per line. | ls -1 /tmp/hashmap.$1 |
Set the exit code($?) to '0'. | true |
find all executable files in /home directory. | find /home -type f -perm /a=x |
Split "input_file" into files of at most 100 lines each with prefix "output_file" | split -l 100 input_file output_file |
Read a line from standard input into variable "REPLY" with prompt "> $line " | read -p "> $line " |
List all files in the current directory tree that were last modified on the 3rd of March, 2010 or later | find -newermt "mar 03, 2010" -ls |
search for a function in all python files in the current folder | find . -name '*.py' | xargs grep some_function |
display all the directories in the current folder excluding those that have the name "node_modules" | find . ! -name "node_modules" -type d |
Find all files/directories in entire file system that have "write" bit set for either the owner, the group, or others | find / -perm /a+w |
Find all *.c files in /usr/src bigger than 100k | find /usr/src -name '*.c' -size +100k -print |
Move all files and directories in the current directory to "/tmp/blah/" | mv * /tmp/blah/ |
remove all the files in the current folder which have not been changed in the last 30*24 hours | find ./ -ctime +30 -type f -exec rm -f {} \; |
Delete files containing whitespaces | find . -name "* *" -exec rm -f {} \; |
Shows state of 'extglob' shell option. | shopt -o extglob |
Read a line of standard input with prompt "My prompt: " and save it to variable "varname" | read -e -p "My prompt: " varname |
find all the files in the home folder which end with ".tex" | find ~ -iname '*.tex' |
set alias "mycd" for command "cd `echo $1`" | alias mycd="cd `echo $1`" |
Recursively change the ownership of all files in "/Users/xxx/Library/Developer/Xcode/Templates" to "xxx" | sudo chown -R xxx /Users/xxx/Library/Developer/Xcode/Templates |
Write "ee" to standard output and as input to command "foo" | echo 'ee' | tee /dev/tty | foo |
display a long list of all the directories which have files ending with ".todo" | find "$STORAGEFOLDER" -name .todo -printf '%h\n' | xargs ls -l |
Search the /myfiles directory tree for files last modified 2 days ago | find /myfiles -mtime 2 |
Print a colon-separated list of all directories from the $root directory tree, except those matching pattern ".[a-z]*" | find "$root" -name ".[a-z]*" -prune -o -type d -printf '%p:' |
Removes alias with 'sudo' name. | unalias sudo |
Find recursively all regular .txt files in the current directory tree except README.txt | find . -type f -name "*.txt" ! -name README.txt -print |
Remove all files in and below the current directory whose names begin with "not" | find . -name not\* | xargs -d '\n' rm |
Use "$BYTES" amount of RAM for "$SECONDS" seconds with no output | cat <(yes | tr \\n x | head -c $BYTES) <(sleep $SECONDS) | grep n |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.